From 666fd4323bcc99165353de7c6841df3d34a30378 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 2 Feb 2015 21:19:41 +0100 Subject: [PATCH] Add a test for crypto_stream_salsa20_xor_ic() --- test/default/stream2.c | 14 +++++++++++++- test/default/stream2.exp | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test/default/stream2.c b/test/default/stream2.c index b3c5ac59..c50bbccf 100644 --- a/test/default/stream2.c +++ b/test/default/stream2.c @@ -17,7 +17,19 @@ unsigned char h[32]; int main(void) { 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); for (i = 0; i < 32; ++i) printf("%02x", h[i]); diff --git a/test/default/stream2.exp b/test/default/stream2.exp index 5fa208c1..23054b75 100644 --- a/test/default/stream2.exp +++ b/test/default/stream2.exp @@ -1 +1,2 @@ 662b9d0e3463029156069b12f918691a98f7dfb2ca0393c96bbfc6b1fbd630a2 +0cc9ffaf60a99d221b548e9762385a231121ab226d1c610d2661ced26b6ad5ee