mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-24 12:36:01 -07:00
Coverage exclusion when relevant
This commit is contained in:
parent
82c806ec07
commit
f812967fb8
@ -37,6 +37,7 @@ crypto_aead_chacha20poly1305_encrypt(unsigned char *c,
|
||||
unsigned char slen[8U];
|
||||
|
||||
(void) nsec;
|
||||
/* LCOV_EXCL_START */
|
||||
#ifdef ULONG_LONG_MAX
|
||||
if (mlen > ULONG_LONG_MAX - crypto_aead_chacha20poly1305_ABYTES) {
|
||||
if (clen != NULL) {
|
||||
@ -45,6 +46,7 @@ crypto_aead_chacha20poly1305_encrypt(unsigned char *c,
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
||||
crypto_stream_chacha20(block0, sizeof block0, npub, k);
|
||||
crypto_onetimeauth_poly1305_init(&state, block0);
|
||||
|
@ -61,6 +61,7 @@ crypto_sign(unsigned char *sm, unsigned long long *smlen,
|
||||
{
|
||||
unsigned long long siglen;
|
||||
|
||||
/* LCOV_EXCL_START */
|
||||
if (crypto_sign_detached(sm, &siglen, m, mlen, sk) != 0 ||
|
||||
siglen > crypto_sign_ed25519_BYTES) {
|
||||
if (smlen != NULL) {
|
||||
@ -69,6 +70,8 @@ crypto_sign(unsigned char *sm, unsigned long long *smlen,
|
||||
memset(sm, 0, mlen + crypto_sign_ed25519_BYTES);
|
||||
return -1;
|
||||
}
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
||||
memmove(sm + siglen, m, mlen);
|
||||
if (smlen != NULL) {
|
||||
*smlen = mlen + siglen;
|
||||
|
@ -112,6 +112,7 @@ safe_read(const int fd, void * const buf_, size_t count)
|
||||
static int
|
||||
randombytes_salsa20_random_random_dev_open(void)
|
||||
{
|
||||
/* LCOV_EXCL_START */
|
||||
struct stat st;
|
||||
static const char *devices[] = {
|
||||
# ifndef USE_BLOCKING_RANDOM
|
||||
@ -133,6 +134,7 @@ randombytes_salsa20_random_random_dev_open(void)
|
||||
} while (*device != NULL);
|
||||
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -145,7 +147,7 @@ randombytes_salsa20_random_init(void)
|
||||
|
||||
if ((stream.random_data_source_fd =
|
||||
randombytes_salsa20_random_random_dev_open()) == -1) {
|
||||
abort();
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
}
|
||||
errno = errno_save;
|
||||
}
|
||||
@ -183,11 +185,11 @@ randombytes_salsa20_random_stir(void)
|
||||
#ifndef _WIN32
|
||||
if (safe_read(stream.random_data_source_fd, m0,
|
||||
sizeof m0) != (ssize_t) sizeof m0) {
|
||||
abort();
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
}
|
||||
#else /* _WIN32 */
|
||||
if (! RtlGenRandom((PVOID) m0, (ULONG) sizeof m0)) {
|
||||
abort();
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
}
|
||||
#endif
|
||||
COMPILER_ASSERT(sizeof stream.key == crypto_auth_hmacsha512256_BYTES);
|
||||
|
@ -102,6 +102,7 @@ safe_read(const int fd, void * const buf_, size_t count)
|
||||
static int
|
||||
randombytes_sysrandom_random_dev_open(void)
|
||||
{
|
||||
/* LCOV_EXCL_START */
|
||||
struct stat st;
|
||||
static const char *devices[] = {
|
||||
# ifndef USE_BLOCKING_RANDOM
|
||||
@ -123,6 +124,7 @@ randombytes_sysrandom_random_dev_open(void)
|
||||
} while (*device != NULL);
|
||||
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -132,7 +134,7 @@ randombytes_sysrandom_init(void)
|
||||
|
||||
if ((stream.random_data_source_fd =
|
||||
randombytes_sysrandom_random_dev_open()) == -1) {
|
||||
abort();
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
}
|
||||
errno = errno_save;
|
||||
}
|
||||
@ -203,14 +205,14 @@ randombytes_sysrandom_buf(void * const buf, const size_t size)
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
if (safe_read(stream.random_data_source_fd, buf, size) != (ssize_t) size) {
|
||||
abort();
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
}
|
||||
#else
|
||||
if (size > 0xffffffff) {
|
||||
abort();
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
}
|
||||
if (! RtlGenRandom((PVOID) buf, (ULONG) size)) {
|
||||
abort();
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ sodium_init(void)
|
||||
}
|
||||
sodium_runtime_get_cpu_features();
|
||||
if (crypto_onetimeauth_pick_best_implementation() == NULL) {
|
||||
return -1;
|
||||
return -1; /* LCOV_EXCL_LINE */
|
||||
}
|
||||
randombytes_stir();
|
||||
_sodium_alloc_init();
|
||||
|
@ -88,7 +88,7 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
|
||||
|
||||
_cpuid(cpu_info, 0x0);
|
||||
if ((id = cpu_info[0]) == 0U) {
|
||||
return -1;
|
||||
return -1; /* LCOV_EXCL_LINE */
|
||||
}
|
||||
_cpuid(cpu_info, 0x00000001);
|
||||
#ifndef HAVE_EMMINTRIN_H
|
||||
|
@ -61,7 +61,7 @@ sodium_memzero(void * const pnt, const size_t len)
|
||||
SecureZeroMemory(pnt, len);
|
||||
#elif defined(HAVE_MEMSET_S)
|
||||
if (memset_s(pnt, (rsize_t) len, 0, (rsize_t) len) != 0) {
|
||||
abort();
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
}
|
||||
#elif defined(HAVE_EXPLICIT_BZERO)
|
||||
explicit_bzero(pnt, len);
|
||||
@ -215,7 +215,7 @@ _sodium_alloc_init(void)
|
||||
page_size = (size_t) si.dwPageSize;
|
||||
#endif
|
||||
if (page_size < CANARY_SIZE) {
|
||||
abort();
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
}
|
||||
randombytes_buf(canary, sizeof canary);
|
||||
|
||||
@ -360,7 +360,7 @@ _sodium_malloc(const size_t size)
|
||||
return NULL;
|
||||
}
|
||||
if (page_size <= sizeof canary || page_size < sizeof unprotected_size) {
|
||||
abort();
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
}
|
||||
size_with_canary = (sizeof canary) + size;
|
||||
unprotected_size = _page_round(size_with_canary);
|
||||
|
Loading…
Reference in New Issue
Block a user