Add a test for crypto_aead without any additional data

This commit is contained in:
Frank Denis 2014-06-30 16:23:34 -07:00
parent 6ea70839df
commit 9154d7416e
2 changed files with 30 additions and 0 deletions

View File

@ -67,5 +67,31 @@ int main(void)
}
c[i] ^= (i + 1U);
}
crypto_aead_chacha20poly1305_encrypt(c, &clen, m, sizeof m, NULL, 0U,
NULL, nonce, firstkey);
if (clen != sizeof m + crypto_aead_chacha20poly1305_abytes()) {
printf("clen is not properly set (adlen=0)\n");
}
for (i = 0U; i < sizeof c; ++i) {
printf(",0x%02x", (unsigned int) c[i]);
if (i % 8 == 7) {
printf("\n");
}
}
printf("\n");
if (crypto_aead_chacha20poly1305_decrypt(m2, &m2len, NULL, c, sizeof c,
NULL, 0U,
nonce, firstkey) != 0) {
printf("crypto_aead_chacha20poly1305_decrypt() failed (adlen=0)\n");
}
if (m2len != sizeof c - crypto_aead_chacha20poly1305_abytes()) {
printf("m2len is not properly set (adlen=0)\n");
}
if (memcmp(m, m2, sizeof m) != 0) {
printf("m != m2 (adlen=0)\n");
}
return 0;
}

View File

@ -2,3 +2,7 @@
,0x62,0xa4,0x67,0x7d,0xab,0xf4,0xe3,0xd2
,0x4b,0x87,0x6b,0xb2,0x84,0x75,0x38,0x96
,0xe1,0xd6
,0xe3,0xe4,0x46,0xf7,0xed,0xe9,0xa1,0x9b
,0x62,0xa4,0x69,0xe7,0x78,0x9b,0xcd,0x95
,0x4e,0x65,0x8e,0xd3,0x84,0x23,0xe2,0x31
,0x61,0xdc