mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-23 20:15:19 -07:00
aegis256: Support mac verification when m is NULL
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
parent
f537541a0a
commit
0a31dd5a31
@ -221,14 +221,22 @@ crypto_aead_aegis256_decrypt_detached(unsigned char *m, unsigned char *nsec, con
|
||||
memcpy(src, ad + i, adlen & 0xf);
|
||||
crypto_aead_aegis256_enc(dst, src, state);
|
||||
}
|
||||
for (i = 0ULL; i + 16ULL <= mlen; i += 16ULL) {
|
||||
crypto_aead_aegis256_dec(m + i, c + i, state);
|
||||
if (m != NULL) {
|
||||
for (i = 0ULL; i + 16ULL <= mlen; i += 16ULL) {
|
||||
crypto_aead_aegis256_dec(m + i, c + i, state);
|
||||
}
|
||||
} else {
|
||||
for (i = 0ULL; i + 16ULL <= mlen; i += 16ULL) {
|
||||
crypto_aead_aegis256_dec(dst, c + i, state);
|
||||
}
|
||||
}
|
||||
if (mlen & 0xf) {
|
||||
memset(src, 0, 16);
|
||||
memcpy(src, c + i, mlen & 0xf);
|
||||
crypto_aead_aegis256_dec(dst, src, state);
|
||||
memcpy(m + i, dst, mlen & 0xf);
|
||||
if (m != NULL) {
|
||||
memcpy(m + i, dst, mlen & 0xf);
|
||||
}
|
||||
memset(dst, 0, mlen & 0xf);
|
||||
state[0] = _mm_xor_si128(state[0], _mm_loadu_si128((__m128i *) dst));
|
||||
}
|
||||
|
@ -2144,6 +2144,11 @@ tv(void)
|
||||
printf("Verification of test vector #%u with a truncated tag failed\n",
|
||||
(unsigned int) i);
|
||||
}
|
||||
if (i == 0 && crypto_aead_aegis256_decrypt(NULL, NULL,
|
||||
NULL, ciphertext, ciphertext_len,
|
||||
ad, ad_len, nonce, key) != 0) {
|
||||
printf("Verification of test vector #%u's tag failed\n", (unsigned int) i);
|
||||
}
|
||||
if (crypto_aead_aegis256_decrypt(decrypted, &found_message_len, NULL, ciphertext,
|
||||
ciphertext_len, ad, ad_len, nonce, key) != 0) {
|
||||
printf("Verification of test vector #%u failed\n", (unsigned int) i);
|
||||
|
Loading…
Reference in New Issue
Block a user