1
/* test the ciphers and hashes using their built-in self-tests */
5
int cipher_hash_test(void)
8
unsigned char buf[4096];
13
for (x = 0; cipher_descriptor[x].name != NULL; x++) {
14
DO(cipher_descriptor[x].test());
18
for (x = 0; hash_descriptor[x].name != NULL; x++) {
19
DO(hash_descriptor[x].test());
22
/* test prngs (test, import/export */
23
for (x = 0; prng_descriptor[x].name != NULL; x++) {
24
DO(prng_descriptor[x].test());
25
DO(prng_descriptor[x].start(&nprng));
26
DO(prng_descriptor[x].add_entropy((unsigned char *)"helloworld12", 12, &nprng));
27
DO(prng_descriptor[x].ready(&nprng));
29
DO(prng_descriptor[x].pexport(buf, &n, &nprng));
30
prng_descriptor[x].done(&nprng);
31
DO(prng_descriptor[x].pimport(buf, n, &nprng));
32
DO(prng_descriptor[x].ready(&nprng));
33
if (prng_descriptor[x].read(buf, 100, &nprng) != 100) {
34
fprintf(stderr, "Error reading from imported PRNG!\n");
37
prng_descriptor[x].done(&nprng);