Mercurial > dropbear
comparison demos/test/ecc_test.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 MECC | |
2 | 4 |
3 int ecc_tests (void) | 5 int ecc_tests (void) |
4 { | 6 { |
5 unsigned char buf[4][4096]; | 7 unsigned char buf[4][4096]; |
6 unsigned long x, y, z; | 8 unsigned long x, y, z; |
8 ecc_key usera, userb; | 10 ecc_key usera, userb; |
9 | 11 |
10 DO(ecc_test ()); | 12 DO(ecc_test ()); |
11 | 13 |
12 /* make up two keys */ | 14 /* make up two keys */ |
13 DO(ecc_make_key (&test_yarrow, find_prng ("yarrow"), 24, &usera)); | 15 DO(ecc_make_key (&test_yarrow, find_prng ("yarrow"), 65, &usera)); |
14 DO(ecc_make_key (&test_yarrow, find_prng ("yarrow"), 24, &userb)); | 16 DO(ecc_make_key (&test_yarrow, find_prng ("yarrow"), 65, &userb)); |
15 | 17 |
16 /* make the shared secret */ | 18 /* make the shared secret */ |
17 x = 4096; | 19 x = 4096; |
18 DO(ecc_shared_secret (&usera, &userb, buf[0], &x)); | 20 DO(ecc_shared_secret (&usera, &userb, buf[0], &x)); |
19 | 21 |
51 } | 53 } |
52 ecc_free (&usera); | 54 ecc_free (&usera); |
53 ecc_free (&userb); | 55 ecc_free (&userb); |
54 | 56 |
55 /* test encrypt_key */ | 57 /* test encrypt_key */ |
56 ecc_make_key (&test_yarrow, find_prng ("yarrow"), 20, &usera); | 58 ecc_make_key (&test_yarrow, find_prng ("yarrow"), 65, &usera); |
57 for (x = 0; x < 32; x++) { | 59 for (x = 0; x < 32; x++) { |
58 buf[0][x] = x; | 60 buf[0][x] = x; |
59 } | 61 } |
60 y = sizeof (buf[1]); | 62 y = sizeof (buf[1]); |
61 DO(ecc_encrypt_key (buf[0], 32, buf[1], &y, &test_yarrow, find_prng ("yarrow"), find_hash ("sha256"), &usera)); | 63 DO(ecc_encrypt_key (buf[0], 32, buf[1], &y, &test_yarrow, find_prng ("yarrow"), find_hash ("sha256"), &usera)); |
85 return 1; | 87 return 1; |
86 } | 88 } |
87 ecc_free (&usera); | 89 ecc_free (&usera); |
88 return 0; | 90 return 0; |
89 } | 91 } |
92 | |
93 #else | |
94 | |
95 int ecc_tests(void) | |
96 { | |
97 printf("NOP"); | |
98 return 0; | |
99 } | |
100 | |
101 #endif |