mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
More tests
This commit is contained in:
@@ -417,6 +417,7 @@ int blake2b_salt_personal( uint8_t *out, const void *in, const void *key, const
|
||||
int
|
||||
blake2b_pick_best_implementation(void)
|
||||
{
|
||||
/* LCOV_EXCL_START */
|
||||
#if (defined(HAVE_AVX2INTRIN_H) && defined(HAVE_TMMINTRIN_H) && defined(HAVE_SMMINTRIN_H)) || \
|
||||
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64)))
|
||||
if (sodium_runtime_has_avx2()) {
|
||||
@@ -441,4 +442,5 @@ blake2b_pick_best_implementation(void)
|
||||
blake2b_compress = blake2b_compress_ref;
|
||||
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
@@ -547,6 +547,7 @@ int initialize(argon2_instance_t *instance, argon2_context *context) {
|
||||
|
||||
int argon2_pick_best_implementation(void)
|
||||
{
|
||||
/* LCOV_EXCL_START */
|
||||
#if (defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H)) || \
|
||||
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
|
||||
if (sodium_runtime_has_ssse3()) {
|
||||
@@ -557,4 +558,5 @@ int argon2_pick_best_implementation(void)
|
||||
fill_segment = fill_segment_ref;
|
||||
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
@@ -244,6 +244,29 @@ int main(void)
|
||||
assert(crypto_pwhash_memlimit_sensitive() > 0U);
|
||||
assert(strcmp(crypto_pwhash_primitive(), "argon2i") == 0);
|
||||
|
||||
assert(crypto_pwhash_opslimit_interactive() == crypto_pwhash_OPSLIMIT_INTERACTIVE);
|
||||
assert(crypto_pwhash_memlimit_interactive() == crypto_pwhash_MEMLIMIT_INTERACTIVE);
|
||||
assert(crypto_pwhash_opslimit_moderate() == crypto_pwhash_OPSLIMIT_MODERATE);
|
||||
assert(crypto_pwhash_memlimit_moderate() == crypto_pwhash_MEMLIMIT_MODERATE);
|
||||
assert(crypto_pwhash_opslimit_sensitive() == crypto_pwhash_OPSLIMIT_SENSITIVE);
|
||||
assert(crypto_pwhash_memlimit_sensitive() == crypto_pwhash_MEMLIMIT_SENSITIVE);
|
||||
|
||||
assert(crypto_pwhash_argon2i_saltbytes() == crypto_pwhash_saltbytes());
|
||||
assert(crypto_pwhash_argon2i_strbytes() == crypto_pwhash_strbytes());
|
||||
assert(strcmp(crypto_pwhash_argon2i_strprefix(), crypto_pwhash_strprefix()) == 0);
|
||||
assert(crypto_pwhash_argon2i_opslimit_interactive() ==
|
||||
crypto_pwhash_opslimit_interactive());
|
||||
assert(crypto_pwhash_argon2i_opslimit_moderate() ==
|
||||
crypto_pwhash_opslimit_moderate());
|
||||
assert(crypto_pwhash_argon2i_opslimit_sensitive() ==
|
||||
crypto_pwhash_opslimit_sensitive());
|
||||
assert(crypto_pwhash_argon2i_memlimit_interactive() ==
|
||||
crypto_pwhash_memlimit_interactive());
|
||||
assert(crypto_pwhash_argon2i_memlimit_moderate() ==
|
||||
crypto_pwhash_memlimit_moderate());
|
||||
assert(crypto_pwhash_argon2i_memlimit_sensitive() ==
|
||||
crypto_pwhash_memlimit_sensitive());
|
||||
|
||||
sodium_free(salt);
|
||||
sodium_free(str_out);
|
||||
sodium_free(str_out2);
|
||||
|
||||
@@ -1181,6 +1181,14 @@ int main(void)
|
||||
printf("detached signature verification should have failed\n");
|
||||
}
|
||||
|
||||
memset(sig, 0xff, 32);
|
||||
sig[0] = 0xdb;
|
||||
if (crypto_sign_verify_detached(sig,
|
||||
(const unsigned char *)test_data[i].m,
|
||||
i, pk) != -1) {
|
||||
printf("detached signature verification should have failed\n");
|
||||
}
|
||||
|
||||
if (crypto_sign_keypair(pk, sk) != 0) {
|
||||
printf("crypto_sign_keypair() failure\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user