Add some coverage exclusions

This commit is contained in:
Frank Denis
2026-04-09 23:00:05 +02:00
parent 8490eeb0d5
commit a09f7ed21a
18 changed files with 34 additions and 28 deletions
@@ -46,10 +46,12 @@ aegis128l_mac(uint8_t *mac, size_t maclen, uint64_t adlen, uint64_t mlen, aes_bl
}
if (maclen == 16) {
/* LCOV_EXCL_START */
tmp = AES_BLOCK_XOR(state[6], AES_BLOCK_XOR(state[5], state[4]));
tmp = AES_BLOCK_XOR(tmp, AES_BLOCK_XOR(state[3], state[2]));
tmp = AES_BLOCK_XOR(tmp, AES_BLOCK_XOR(state[1], state[0]));
AES_BLOCK_STORE(mac, tmp);
/* LCOV_EXCL_STOP */
} else if (maclen == 32) {
tmp = AES_BLOCK_XOR(state[3], state[2]);
tmp = AES_BLOCK_XOR(tmp, AES_BLOCK_XOR(state[1], state[0]));
@@ -237,7 +239,7 @@ decrypt_detached(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *mac,
aegis128l_mac(computed_mac, maclen, adlen, mlen, state);
ret = -1;
if (maclen == 16) {
ret = crypto_verify_16(computed_mac, mac);
ret = crypto_verify_16(computed_mac, mac); /* LCOV_EXCL_LINE */
} else if (maclen == 32) {
ret = crypto_verify_32(computed_mac, mac);
}
@@ -48,10 +48,12 @@ aegis256_mac(uint8_t *mac, size_t maclen, uint64_t adlen, uint64_t mlen, aes_blo
}
if (maclen == 16) {
/* LCOV_EXCL_START */
tmp = AES_BLOCK_XOR(state[5], state[4]);
tmp = AES_BLOCK_XOR(tmp, AES_BLOCK_XOR(state[3], state[2]));
tmp = AES_BLOCK_XOR(tmp, AES_BLOCK_XOR(state[1], state[0]));
AES_BLOCK_STORE(mac, tmp);
/* LCOV_EXCL_STOP */
} else if (maclen == 32) {
tmp = AES_BLOCK_XOR(AES_BLOCK_XOR(state[2], state[1]), state[0]);
AES_BLOCK_STORE(mac, tmp);
@@ -220,7 +222,7 @@ decrypt_detached(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *mac,
aegis256_mac(computed_mac, maclen, adlen, mlen, state);
ret = -1;
if (maclen == 16) {
ret = crypto_verify_16(computed_mac, mac);
ret = crypto_verify_16(computed_mac, mac); /* LCOV_EXCL_LINE */
} else if (maclen == 32) {
ret = crypto_verify_32(computed_mac, mac);
}
@@ -159,7 +159,7 @@ crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c,
int ret;
if (mlen > crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
ret = crypto_aead_xchacha20poly1305_ietf_encrypt_detached
(c, c + mlen, NULL, m, mlen, ad, adlen, nsec, npub, k);
@@ -50,7 +50,7 @@ crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state,
keylen = 32;
} else if (key == NULL) {
if (keylen > 0) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
}
crypto_hash_sha256_init(&state->ictx);
@@ -50,7 +50,7 @@ crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
keylen = 64;
} else if (key == NULL) {
if (keylen > 0) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
}
crypto_hash_sha512_init(&state->ictx);
@@ -91,7 +91,7 @@ crypto_box_curve25519xchacha20poly1305_easy_afternm(unsigned char *c,
const unsigned char *k)
{
if (mlen > crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
return crypto_box_curve25519xchacha20poly1305_detached_afternm(
c + crypto_box_curve25519xchacha20poly1305_MACBYTES, c, m, mlen, n, k);
@@ -103,7 +103,7 @@ crypto_box_curve25519xchacha20poly1305_easy(
const unsigned char *n, const unsigned char *pk, const unsigned char *sk)
{
if (mlen > crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
return crypto_box_curve25519xchacha20poly1305_detached(
c + crypto_box_curve25519xchacha20poly1305_MACBYTES, c, m, mlen, n, pk,
@@ -697,6 +697,7 @@ ge25519_sub(ge25519_p1p1 *r, const ge25519_p3 *p, const ge25519_cached *q)
fe25519_add(r->T, t0, r->T);
}
/* LCOV_EXCL_START */
void
ge25519_tobytes(unsigned char *s, const ge25519_p2 *h)
{
@@ -710,6 +711,7 @@ ge25519_tobytes(unsigned char *s, const ge25519_p2 *h)
fe25519_tobytes(s, y);
s[31] ^= fe25519_isnegative(x) << 7;
}
/* LCOV_EXCL_STOP */
/*
r = a * A + b * B
@@ -52,7 +52,7 @@ static inline int
blake2b_set_lastblock(blake2b_state *S)
{
if (S->last_node) {
blake2b_set_lastnode(S);
blake2b_set_lastnode(S); /* LCOV_EXCL_LINE */
}
S->f[0] = -1;
return 0;
@@ -489,20 +489,20 @@ argon2_initialize(argon2_instance_t *instance, argon2_context *context)
int result = ARGON2_OK;
if (instance == NULL || context == NULL) {
return ARGON2_INCORRECT_PARAMETER;
return ARGON2_INCORRECT_PARAMETER; /* LCOV_EXCL_LINE */
}
/* 1. Memory allocation */
if ((instance->pseudo_rands = (uint64_t *)
malloc(sizeof(uint64_t) * instance->segment_length)) == NULL) {
return ARGON2_MEMORY_ALLOCATION_ERROR;
return ARGON2_MEMORY_ALLOCATION_ERROR; /* LCOV_EXCL_LINE */
}
result = allocate_memory(&(instance->region), instance->memory_blocks);
if (ARGON2_OK != result) {
argon2_free_instance(instance, context->flags);
return result;
argon2_free_instance(instance, context->flags); /* LCOV_EXCL_LINE */
return result; /* LCOV_EXCL_LINE */
}
/* 2. Initial hashing */
@@ -165,7 +165,7 @@ argon2_decode_string(argon2_context *ctx, const char *str, argon2_type type)
} else if (type == Argon2_i) {
CC("$argon2i");
} else {
return ARGON2_INCORRECT_TYPE;
return ARGON2_INCORRECT_TYPE; /* LCOV_EXCL_LINE */
}
CC("$v=");
DECIMAL_U32(version);
@@ -175,17 +175,17 @@ argon2_decode_string(argon2_context *ctx, const char *str, argon2_type type)
CC("$m=");
DECIMAL_U32(ctx->m_cost);
if (ctx->m_cost > UINT32_MAX) {
return ARGON2_INCORRECT_TYPE;
return ARGON2_INCORRECT_TYPE; /* LCOV_EXCL_LINE */
}
CC(",t=");
DECIMAL_U32(ctx->t_cost);
if (ctx->t_cost > UINT32_MAX) {
return ARGON2_INCORRECT_TYPE;
return ARGON2_INCORRECT_TYPE; /* LCOV_EXCL_LINE */
}
CC(",p=");
DECIMAL_U32(ctx->lanes);
if (ctx->lanes > UINT32_MAX) {
return ARGON2_INCORRECT_TYPE;
return ARGON2_INCORRECT_TYPE; /* LCOV_EXCL_LINE */
}
ctx->threads = ctx->lanes;
+1 -1
View File
@@ -46,7 +46,7 @@ argon2_ctx(argon2_context *context, argon2_type type)
memory_blocks = context->m_cost;
if (memory_blocks < 2 * ARGON2_SYNC_POINTS * context->lanes) {
memory_blocks = 2 * ARGON2_SYNC_POINTS * context->lanes;
memory_blocks = 2 * ARGON2_SYNC_POINTS * context->lanes; /* LCOV_EXCL_LINE */
}
segment_length = memory_blocks / (context->lanes * ARGON2_SYNC_POINTS);
+2 -2
View File
@@ -166,9 +166,9 @@ crypto_pwhash_str_alg(char out[crypto_pwhash_STRBYTES],
return crypto_pwhash_argon2id_str(out, passwd, passwdlen,
opslimit, memlimit);
}
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
/* NOTREACHED */
return -1;
return -1; /* LCOV_EXCL_LINE */
}
int
@@ -73,7 +73,7 @@ crypto_secretbox_easy(unsigned char *c, const unsigned char *m,
const unsigned char *k)
{
if (mlen > crypto_secretbox_MESSAGEBYTES_MAX) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
return crypto_secretbox_detached(c + crypto_secretbox_MACBYTES,
c, m, mlen, n, k);
@@ -79,7 +79,7 @@ crypto_secretbox_xchacha20poly1305_easy(unsigned char *c,
const unsigned char *k)
{
if (mlen > crypto_secretbox_xchacha20poly1305_MESSAGEBYTES_MAX) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
return crypto_secretbox_xchacha20poly1305_detached
(c + crypto_secretbox_xchacha20poly1305_MACBYTES, c, m, mlen, n, k);
@@ -126,7 +126,7 @@ crypto_secretstream_xchacha20poly1305_push
COMPILER_ASSERT(crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX
<= crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX);
if (mlen > crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
crypto_stream_chacha20_ietf(block, sizeof block, state->nonce, state->k);
crypto_onetimeauth_poly1305_init(&poly1305_state, block);
@@ -202,7 +202,7 @@ crypto_secretstream_xchacha20poly1305_pull
}
mlen = inlen - crypto_secretstream_xchacha20poly1305_ABYTES;
if (mlen > crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
crypto_stream_chacha20_ietf(block, sizeof block, state->nonce, state->k);
crypto_onetimeauth_poly1305_init(&poly1305_state, block);
+1 -1
View File
@@ -186,7 +186,7 @@ randombytes_buf_deterministic(void * const buf, const size_t size,
#if SIZE_MAX > 0x4000000000ULL
COMPILER_ASSERT(randombytes_BYTES_MAX <= 0x4000000000ULL);
if (size > 0x4000000000ULL) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
#endif
crypto_stream_chacha20_ietf((unsigned char *) buf, (unsigned long long) size,
+2 -2
View File
@@ -166,7 +166,7 @@ static void
sodium_base64_check_variant(const int variant)
{
if ((((unsigned int) variant) & ~ 0x6U) != 0x1U) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
}
@@ -209,7 +209,7 @@ sodium_bin2base64(char * const b64, const size_t b64_maxlen,
}
}
if (b64_maxlen <= b64_len) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
if ((((unsigned int) variant) & VARIANT_URLSAFE_MASK) != 0U) {
while (bin_pos < bin_len) {
+2 -2
View File
@@ -682,7 +682,7 @@ sodium_free(void *ptr)
total_size = page_size + page_size + unprotected_size + page_size;
_mprotect_readwrite(base_ptr, total_size);
if (sodium_memcmp(canary_ptr, canary, sizeof canary) != 0) {
_out_of_bounds();
_out_of_bounds(); /* LCOV_EXCL_LINE */
}
# ifndef HAVE_PAGE_PROTECTION
if (sodium_memcmp(unprotected_ptr + unprotected_size, canary,
@@ -759,7 +759,7 @@ sodium_pad(size_t *padded_buflen_p, unsigned char *buf,
xpadlen -= unpadded_buflen % blocksize;
}
if ((size_t) SIZE_MAX - unpadded_buflen <= xpadlen) {
sodium_misuse();
sodium_misuse(); /* LCOV_EXCL_LINE */
}
xpadded_len = unpadded_buflen + xpadlen;
if (xpadded_len >= max_buflen) {