1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-23 20:15:19 -07:00

Check crypto_onetimeauth() streaming interface

This commit is contained in:
Frank Denis 2014-09-16 10:19:32 -07:00
parent eacb7c7f2b
commit 81aa4ef4a3
2 changed files with 15 additions and 0 deletions

View File

@ -24,6 +24,7 @@ unsigned char a[16];
int main(void) int main(void)
{ {
crypto_onetimeauth_state st;
int i; int i;
crypto_onetimeauth(a, c, 131, rs); crypto_onetimeauth(a, c, 131, rs);
@ -32,6 +33,18 @@ int main(void)
if (i % 8 == 7) if (i % 8 == 7)
printf("\n"); printf("\n");
} }
memset(a, 0, sizeof a);
crypto_onetimeauth_init(&st, rs);
crypto_onetimeauth_update(&st, c, 100);
crypto_onetimeauth_update(&st, c + 100, 31);
crypto_onetimeauth_final(&st, a);
for (i = 0; i < 16; ++i) {
printf(",0x%02x", (unsigned int)a[i]);
if (i % 8 == 7)
printf("\n");
}
assert(crypto_onetimeauth_bytes() > 0U); assert(crypto_onetimeauth_bytes() > 0U);
assert(crypto_onetimeauth_keybytes() > 0U); assert(crypto_onetimeauth_keybytes() > 0U);
assert(strcmp(crypto_onetimeauth_primitive(), "poly1305") == 0); assert(strcmp(crypto_onetimeauth_primitive(), "poly1305") == 0);

View File

@ -1,2 +1,4 @@
,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5 ,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5
,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9 ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9
,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5
,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9