Select Git revision
test-git-commit.sh
chacha-test.c 26.30 KiB
/* chacha-test.c
Test program for the ChaCha stream cipher implementation.
Copyright (C) 2013 Joachim Strömbergson
Copyright (C) 2012, 2014 Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#include "testutils.h"
#include "chacha.h"
#include "chacha-internal.h"
static int
memzero_p (const uint8_t *p, size_t n)
{
size_t i;
for (i = 0; i < n; i++)
if (p[i])
return 0;
return 1;
}
/* Test with simple structure of the salsa20 input, to aid
debugging. */
static void
test_chacha_core(void)
{
const uint32_t input[16] =
{
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
/* Second block will have carry from first counter word propagate
to next word. */
0xffffffff, 13, 14, 15,
};
const struct tstring *expected
= SHEX("32f216b0eddeee3b bade2bf5a4c0b3b3"
"0aab2d67b09b2a63 6127fc965d831b2c"
"ddc9e25ca7841f3e 938e3566a7702a0b"
"7f80559e639ef6da 6d39627abc7da6b1"
"0090a54241e68b6b d870f3b60adcaf89"
"09d3c7b8a8c76aa3 941d726c649636db"