~ubuntu-branches/debian/lenny/dropbear/lenny

« back to all changes in this revision

Viewing changes to libtomcrypt/demos/test/cipher_hash_test.c

  • Committer: Bazaar Package Importer
  • Author(s): Gerrit Pape
  • Date: 2005-05-25 22:38:17 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050525223817-fdl653extybmz1zb
Tags: 0.45-3
* debian/dropbear.init: init script prints human readable message in case
  it's disabled (closes: #309099).
* debian/dropbear.postinst: configure: restart service through init script
  instead of start.
* debian/dropbear.prerm: set -u -> set -e.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
int cipher_hash_test(void)
6
6
{
7
 
   int x;
 
7
   int           x;
 
8
   unsigned char buf[4096];
 
9
   unsigned long n;
 
10
   prng_state    nprng;
8
11
   
9
12
   /* test ciphers */
10
13
   for (x = 0; cipher_descriptor[x].name != NULL; x++) {
15
18
   for (x = 0; hash_descriptor[x].name != NULL; x++) {
16
19
      DO(hash_descriptor[x].test());
17
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
   }
18
39
   
19
40
   return 0;
20
41
}