comparison libtomcrypt/testprof/dsa_test.c @ 415:8b9aba1d5fa4 channel-fix

merge of '73fe066c5d9e2395354ba74756124d45c978a04d' and 'f5014cc84558f1e8eba42dbecf9f72f94bfe6134'
author Matt Johnston <matt@ucc.asn.au>
date Tue, 06 Feb 2007 16:00:18 +0000
parents 0cbe8f6dbf9e
children f849a5ca2efc
comparison
equal deleted inserted replaced
414:c53a26c430e5 415:8b9aba1d5fa4
3 #ifdef MDSA 3 #ifdef MDSA
4 4
5 int dsa_test(void) 5 int dsa_test(void)
6 { 6 {
7 unsigned char msg[16], out[1024], out2[1024]; 7 unsigned char msg[16], out[1024], out2[1024];
8 unsigned long x; 8 unsigned long x, y;
9 int stat1, stat2; 9 int stat1, stat2;
10 dsa_key key, key2; 10 dsa_key key, key2;
11 11
12 /* make a random key */ 12 /* make a random key */
13 DO(dsa_make_key(&yarrow_prng, find_prng("yarrow"), 20, 128, &key)); 13 DO(dsa_make_key(&yarrow_prng, find_prng("yarrow"), 20, 128, &key));
14 14
15 /* verify it */ 15 /* verify it */
16 DO(dsa_verify_key(&key, &stat1)); 16 DO(dsa_verify_key(&key, &stat1));
17 if (stat1 == 0) { fprintf(stderr, "dsa_verify_key "); return 1; } 17 if (stat1 == 0) { fprintf(stderr, "dsa_verify_key "); return 1; }
18
19 /* encrypt a message */
20 for (x = 0; x < 16; x++) { msg[x] = x; }
21 x = sizeof(out);
22 DO(dsa_encrypt_key(msg, 16, out, &x, &yarrow_prng, find_prng("yarrow"), find_hash("sha1"), &key));
23
24 /* decrypt */
25 y = sizeof(out2);
26 DO(dsa_decrypt_key(out, x, out2, &y, &key));
27
28 if (y != 16 || memcmp(out2, msg, 16)) {
29 fprintf(stderr, "dsa_decrypt failed, y == %lu\n", y);
30 return 1;
31 }
18 32
19 /* sign the message */ 33 /* sign the message */
20 x = sizeof(out); 34 x = sizeof(out);
21 DO(dsa_sign_hash(msg, sizeof(msg), out, &x, &yarrow_prng, find_prng("yarrow"), &key)); 35 DO(dsa_sign_hash(msg, sizeof(msg), out, &x, &yarrow_prng, find_prng("yarrow"), &key));
22 36
62 } 76 }
63 77
64 #endif 78 #endif
65 79
66 /* $Source: /cvs/libtom/libtomcrypt/testprof/dsa_test.c,v $ */ 80 /* $Source: /cvs/libtom/libtomcrypt/testprof/dsa_test.c,v $ */
67 /* $Revision: 1.8 $ */ 81 /* $Revision: 1.9 $ */
68 /* $Date: 2005/06/03 19:24:32 $ */ 82 /* $Date: 2005/10/30 18:49:14 $ */