Test chacha20 with length == 0

This commit is contained in:
Frank Denis
2014-09-16 10:32:04 -07:00
parent 81aa4ef4a3
commit cee8af9b66
2 changed files with 5 additions and 1 deletions
@@ -101,7 +101,7 @@ chacha_encrypt_bytes(chacha_ctx *x, const u8 *m, u8 *c, unsigned long long bytes
unsigned long long i;
if (!bytes) {
return;
return; /* LCOV_EXCL_LINE */
}
j0 = x->input[0];
j1 = x->input[1];
+4
View File
@@ -35,6 +35,10 @@ static void tv(void)
} while (++i < (sizeof tests) / (sizeof tests[0]));
memset(out, 0x42, sizeof out);
assert(crypto_stream_chacha20_xor(out, out, 0U, nonce, key) == 0);
assert(crypto_stream_chacha20_xor_ic(out, out, 0U, nonce, 1U, key) == 0);
crypto_stream_chacha20_xor(out, out, sizeof out, nonce, key);
sodium_bin2hex(out_hex, sizeof out_hex, out, sizeof out);
printf("[%s]\n", out_hex);