7
unsigned char buf[3][4096];
14
/* make up two keys */
15
DO(dh_make_key (&test_yarrow, find_prng ("yarrow"), 512, &usera));
16
DO(dh_make_key (&test_yarrow, find_prng ("yarrow"), 512, &userb));
18
/* make the shared secret */
20
DO(dh_shared_secret (&usera, &userb, buf[0], &x));
23
DO(dh_shared_secret (&userb, &usera, buf[1], &y));
25
printf ("DH Shared keys are not same size.\n");
28
if (memcmp (buf[0], buf[1], x)) {
29
printf ("DH Shared keys not same contents.\n");
33
/* now export userb */
35
DO(dh_export (buf[1], &y, PK_PUBLIC, &userb));
38
/* import and make the shared secret again */
39
DO(dh_import (buf[1], y, &userb));
41
DO(dh_shared_secret (&usera, &userb, buf[2], &z));
44
printf ("failed. Size don't match?\n");
47
if (memcmp (buf[0], buf[2], x)) {
48
printf ("Failed. Content didn't match.\n");
54
/* test encrypt_key */
55
dh_make_key (&test_yarrow, find_prng ("yarrow"), 512, &usera);
56
for (x = 0; x < 16; x++) {
60
DO(dh_encrypt_key (buf[0], 16, buf[1], &y, &test_yarrow, find_prng ("yarrow"), find_hash ("md5"), &usera));
61
zeromem (buf[0], sizeof (buf[0]));
63
DO(dh_decrypt_key (buf[1], y, buf[0], &x, &usera));
65
printf ("Failed (length)\n");
68
for (x = 0; x < 16; x++)
70
printf ("Failed (contents)\n");
75
for (x = 0; x < 16; x++) {
79
DO(dh_sign_hash (buf[0], 16, buf[1], &x, &test_yarrow , find_prng ("yarrow"), &usera));
80
DO(dh_verify_hash (buf[1], x, buf[0], 16, &stat, &usera));
82
DO(dh_verify_hash (buf[1], x, buf[0], 16, &stat2, &usera));
83
if (!(stat == 1 && stat2 == 0)) {
84
printf("dh_sign/verify_hash %d %d", stat, stat2);