comparison demos/test/dh_tests.c @ 143:5d99163f7e32 libtomcrypt-orig

import of libtomcrypt 0.99
author Matt Johnston <matt@ucc.asn.au>
date Sun, 19 Dec 2004 11:34:45 +0000
parents 6362d3854bb4
children
comparison
equal deleted inserted replaced
15:6362d3854bb4 143:5d99163f7e32
1 #include "test.h" 1 #include "test.h"
2
3 #ifdef MDH
2 4
3 int dh_tests (void) 5 int dh_tests (void)
4 { 6 {
5 unsigned char buf[3][4096]; 7 unsigned char buf[3][4096];
6 unsigned long x, y, z; 8 unsigned long x, y, z;
8 dh_key usera, userb; 10 dh_key usera, userb;
9 11
10 DO(dh_test()); 12 DO(dh_test());
11 13
12 /* make up two keys */ 14 /* make up two keys */
13 DO(dh_make_key (&test_yarrow, find_prng ("yarrow"), 96, &usera)); 15 DO(dh_make_key (&test_yarrow, find_prng ("yarrow"), 512, &usera));
14 DO(dh_make_key (&test_yarrow, find_prng ("yarrow"), 96, &userb)); 16 DO(dh_make_key (&test_yarrow, find_prng ("yarrow"), 512, &userb));
15 17
16 /* make the shared secret */ 18 /* make the shared secret */
17 x = 4096; 19 x = 4096;
18 DO(dh_shared_secret (&usera, &userb, buf[0], &x)); 20 DO(dh_shared_secret (&usera, &userb, buf[0], &x));
19 21
48 } 50 }
49 dh_free (&usera); 51 dh_free (&usera);
50 dh_free (&userb); 52 dh_free (&userb);
51 53
52 /* test encrypt_key */ 54 /* test encrypt_key */
53 dh_make_key (&test_yarrow, find_prng ("yarrow"), 128, &usera); 55 dh_make_key (&test_yarrow, find_prng ("yarrow"), 512, &usera);
54 for (x = 0; x < 16; x++) { 56 for (x = 0; x < 16; x++) {
55 buf[0][x] = x; 57 buf[0][x] = x;
56 } 58 }
57 y = sizeof (buf[1]); 59 y = sizeof (buf[1]);
58 DO(dh_encrypt_key (buf[0], 16, buf[1], &y, &test_yarrow, find_prng ("yarrow"), find_hash ("md5"), &usera)); 60 DO(dh_encrypt_key (buf[0], 16, buf[1], &y, &test_yarrow, find_prng ("yarrow"), find_hash ("md5"), &usera));
83 return 1; 85 return 1;
84 } 86 }
85 dh_free (&usera); 87 dh_free (&usera);
86 return 0; 88 return 0;
87 } 89 }
90
91 #else
92
93 int dh_tests(void)
94 {
95 printf("NOP");
96 return 0;
97 }
98
99 #endif