Add a test for crypto_stream_salsa20_xor_ic()

This commit is contained in:
Frank Denis 2015-02-02 21:19:41 +01:00
parent cdf863c731
commit 666fd4323b
2 changed files with 14 additions and 1 deletions

View File

@ -17,7 +17,19 @@ unsigned char h[32];
int main(void) int main(void)
{ {
int i; int i;
crypto_stream_salsa20(output, 4194304, noncesuffix, secondkey); crypto_stream_salsa20(output, sizeof output, noncesuffix, secondkey);
crypto_hash_sha256(h, output, sizeof output);
for (i = 0; i < 32; ++i)
printf("%02x", h[i]);
printf("\n");
assert(sizeof output > 4000);
crypto_stream_salsa20_xor_ic(output, output, 4000, noncesuffix, 0U, secondkey);
for (i = 0; i < 4000; ++i)
assert(output[i] == 0);
crypto_stream_salsa20_xor_ic(output, output, 4000, noncesuffix, 1U, secondkey);
crypto_hash_sha256(h, output, sizeof output); crypto_hash_sha256(h, output, sizeof output);
for (i = 0; i < 32; ++i) for (i = 0; i < 32; ++i)
printf("%02x", h[i]); printf("%02x", h[i]);

View File

@ -1 +1,2 @@
662b9d0e3463029156069b12f918691a98f7dfb2ca0393c96bbfc6b1fbd630a2 662b9d0e3463029156069b12f918691a98f7dfb2ca0393c96bbfc6b1fbd630a2
0cc9ffaf60a99d221b548e9762385a231121ab226d1c610d2661ced26b6ad5ee