Mercurial > dropbear
comparison libtomcrypt/testprof/cipher_hash_test.c @ 389:5ff8218bcee9
propagate from branch 'au.asn.ucc.matt.ltm.dropbear' (head 2af95f00ebd5bb7a28b3817db1218442c935388e)
to branch 'au.asn.ucc.matt.dropbear' (head ecd779509ef23a8cdf64888904fc9b31d78aa933)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 03:14:55 +0000 |
parents | 1b9e69c058d2 |
children | f849a5ca2efc |
comparison
equal
deleted
inserted
replaced
388:fb54020f78e1 | 389:5ff8218bcee9 |
---|---|
1 /* test the ciphers and hashes using their built-in self-tests */ | |
2 | |
3 #include <tomcrypt_test.h> | |
4 | |
5 int cipher_hash_test(void) | |
6 { | |
7 int x; | |
8 unsigned char buf[4096]; | |
9 unsigned long n; | |
10 prng_state nprng; | |
11 | |
12 /* test ciphers */ | |
13 for (x = 0; cipher_descriptor[x].name != NULL; x++) { | |
14 DO(cipher_descriptor[x].test()); | |
15 } | |
16 | |
17 /* test hashes */ | |
18 for (x = 0; hash_descriptor[x].name != NULL; x++) { | |
19 DO(hash_descriptor[x].test()); | |
20 } | |
21 | |
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)); | |
28 n = sizeof(buf); | |
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"); | |
35 exit(EXIT_FAILURE); | |
36 } | |
37 prng_descriptor[x].done(&nprng); | |
38 } | |
39 | |
40 return 0; | |
41 } | |
42 | |
43 /* $Source: /cvs/libtom/libtomcrypt/testprof/cipher_hash_test.c,v $ */ | |
44 /* $Revision: 1.3 $ */ | |
45 /* $Date: 2005/05/05 14:35:59 $ */ |