mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
More test + lcov exclusions
This commit is contained in:
@@ -63,7 +63,7 @@ PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
|
||||
crypto_auth_hmacsha256_final(&hctx, U);
|
||||
|
||||
memcpy(T, U, 32);
|
||||
|
||||
/* LCOV_EXCL_START */
|
||||
for (j = 2; j <= c; j++) {
|
||||
crypto_auth_hmacsha256_init(&hctx, passwd, passwdlen);
|
||||
crypto_auth_hmacsha256_update(&hctx, U, 32);
|
||||
@@ -73,6 +73,7 @@ PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
|
||||
T[k] ^= U[k];
|
||||
}
|
||||
}
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
||||
clen = dkLen - i * 32;
|
||||
if (clen > 32) {
|
||||
|
||||
@@ -43,7 +43,7 @@ alloc_region(escrypt_region_t * region, size_t size)
|
||||
MAP_ANON | MAP_PRIVATE,
|
||||
#endif
|
||||
-1, 0)) == MAP_FAILED)
|
||||
base = NULL;
|
||||
base = NULL; /* LCOV_EXCL_LINE */
|
||||
aligned = base;
|
||||
#elif defined(HAVE_POSIX_MEMALIGN)
|
||||
if ((errno = posix_memalign((void **) &base, 64, size)) != 0)
|
||||
@@ -77,7 +77,7 @@ free_region(escrypt_region_t * region)
|
||||
if (region->base) {
|
||||
#ifdef MAP_ANON
|
||||
if (munmap(region->base, region->size))
|
||||
return -1;
|
||||
return -1; /* LCOV_EXCL_LINE */
|
||||
#else
|
||||
free(region->base);
|
||||
#endif
|
||||
|
||||
@@ -1057,6 +1057,7 @@ int main(void)
|
||||
unsigned long long smlen;
|
||||
unsigned long long mlen;
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
for (i = 0U; i < (sizeof test_data) / (sizeof test_data[0]); i++) {
|
||||
memcpy(skpk, test_data[i].sk, crypto_sign_SEEDBYTES);
|
||||
@@ -1113,6 +1114,25 @@ int main(void)
|
||||
}
|
||||
printf("%u tests\n", i);
|
||||
|
||||
i--;
|
||||
for (j = 1U; j < 8U; j++) {
|
||||
sig[63] ^= (j << 5);
|
||||
if (crypto_sign_verify_detached(sig,
|
||||
(const unsigned char *)test_data[i].m,
|
||||
i, test_data[i].pk) != -1) {
|
||||
printf("detached signature verification should have failed\n");
|
||||
continue;
|
||||
}
|
||||
sig[63] ^= (j << 5);
|
||||
}
|
||||
|
||||
memset(pk, 0, sizeof pk);
|
||||
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