Mercurial > dropbear
annotate whirl.c @ 211:f01f0400314d libtomcrypt
disapproval of revision 6a39eb8b36778460fca83b8149df2a8b6d3327fd
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 06 Jul 2005 13:23:45 +0000 |
parents | b939f2d4431e |
children | 7ed585a2c53b |
rev | line source |
---|---|
20
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
2 * |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
3 * LibTomCrypt is a library that provides various cryptographic |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
4 * algorithms in a highly modular and flexible manner. |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
5 * |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
6 * The library is free for all purposes without any express |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
7 * guarantee it works. |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
8 * |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
9 * Tom St Denis, [email protected], http://libtomcrypt.org |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
10 */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
11 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
12 /* WHIRLPOOL (using their new sbox) hash function by Tom St Denis */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
13 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
14 #include "mycrypt.h" |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
15 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
16 #ifdef WHIRLPOOL |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
17 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
18 const struct _hash_descriptor whirlpool_desc = |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
19 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
20 "whirlpool", |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
21 11, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
22 64, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
23 64, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
24 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
25 /* DER encoding (not yet supported) */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
26 { 0x00 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
27 0, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
28 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
29 &whirlpool_init, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
30 &whirlpool_process, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
31 &whirlpool_done, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
32 &whirlpool_test |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
33 }; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
34 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
35 /* the sboxes */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
36 #include "whirltab.c" |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
37 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
38 /* get a_{i,j} */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
39 #define GB(a,i,j) ((a[(i) & 7] >> (8 * (j))) & 255) |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
40 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
41 /* shortcut macro to perform three functions at once */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
42 #define theta_pi_gamma(a, i) \ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
43 SB0(GB(a, i-0, 7)) ^ \ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
44 SB1(GB(a, i-1, 6)) ^ \ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
45 SB2(GB(a, i-2, 5)) ^ \ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
46 SB3(GB(a, i-3, 4)) ^ \ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
47 SB4(GB(a, i-4, 3)) ^ \ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
48 SB5(GB(a, i-5, 2)) ^ \ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
49 SB6(GB(a, i-6, 1)) ^ \ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
50 SB7(GB(a, i-7, 0)) |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
51 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
52 #ifdef CLEAN_STACK |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
53 static void _whirlpool_compress(hash_state *md, unsigned char *buf) |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
54 #else |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
55 static void whirlpool_compress(hash_state *md, unsigned char *buf) |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
56 #endif |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
57 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
58 ulong64 K[2][8], T[3][8]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
59 int x, y; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
60 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
61 /* load the block/state */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
62 for (x = 0; x < 8; x++) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
63 K[0][x] = md->whirlpool.state[x]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
64 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
65 LOAD64H(T[0][x], buf + (8 * x)); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
66 T[2][x] = T[0][x]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
67 T[0][x] ^= K[0][x]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
68 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
69 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
70 /* do rounds 1..10 */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
71 for (x = 0; x < 10; x += 2) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
72 /* odd round */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
73 /* apply main transform to K[0] into K[1] */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
74 for (y = 0; y < 8; y++) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
75 K[1][y] = theta_pi_gamma(K[0], y); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
76 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
77 /* xor the constant */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
78 K[1][0] ^= cont[x]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
79 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
80 /* apply main transform to T[0] into T[1] */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
81 for (y = 0; y < 8; y++) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
82 T[1][y] = theta_pi_gamma(T[0], y) ^ K[1][y]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
83 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
84 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
85 /* even round */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
86 /* apply main transform to K[1] into K[0] */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
87 for (y = 0; y < 8; y++) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
88 K[0][y] = theta_pi_gamma(K[1], y); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
89 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
90 /* xor the constant */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
91 K[0][0] ^= cont[x+1]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
92 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
93 /* apply main transform to T[0] into T[1] */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
94 for (y = 0; y < 8; y++) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
95 T[0][y] = theta_pi_gamma(T[1], y) ^ K[0][y]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
96 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
97 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
98 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
99 /* store state */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
100 for (x = 0; x < 8; x++) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
101 md->whirlpool.state[x] ^= T[0][x] ^ T[2][x]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
102 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
103 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
104 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
105 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
106 #ifdef CLEAN_STACK |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
107 static void whirlpool_compress(hash_state *md, unsigned char *buf) |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
108 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
109 _whirlpool_compress(md, buf); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
110 burn_stack((5 * 8 * sizeof(ulong64)) + (2 * sizeof(int))); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
111 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
112 #endif |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
113 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
114 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
115 void whirlpool_init(hash_state * md) |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
116 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
117 _ARGCHK(md != NULL); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
118 zeromem(&md->whirlpool, sizeof(md->whirlpool)); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
119 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
120 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
121 HASH_PROCESS(whirlpool_process, whirlpool_compress, whirlpool, 64) |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
122 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
123 int whirlpool_done(hash_state * md, unsigned char *hash) |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
124 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
125 int i; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
126 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
127 _ARGCHK(md != NULL); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
128 _ARGCHK(hash != NULL); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
129 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
130 if (md->whirlpool.curlen >= sizeof(md->whirlpool.buf)) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
131 return CRYPT_INVALID_ARG; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
132 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
133 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
134 /* increase the length of the message */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
135 md->whirlpool.length += md->whirlpool.curlen * 8; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
136 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
137 /* append the '1' bit */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
138 md->whirlpool.buf[md->whirlpool.curlen++] = (unsigned char)0x80; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
139 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
140 /* if the length is currently above 32 bytes we append zeros |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
141 * then compress. Then we can fall back to padding zeros and length |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
142 * encoding like normal. |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
143 */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
144 if (md->whirlpool.curlen > 32) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
145 while (md->whirlpool.curlen < 64) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
146 md->whirlpool.buf[md->whirlpool.curlen++] = (unsigned char)0; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
147 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
148 whirlpool_compress(md, md->whirlpool.buf); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
149 md->whirlpool.curlen = 0; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
150 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
151 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
152 /* pad upto 56 bytes of zeroes (should be 32 but we only support 64-bit lengths) */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
153 while (md->whirlpool.curlen < 56) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
154 md->whirlpool.buf[md->whirlpool.curlen++] = (unsigned char)0; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
155 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
156 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
157 /* store length */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
158 STORE64H(md->whirlpool.length, md->whirlpool.buf+56); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
159 whirlpool_compress(md, md->whirlpool.buf); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
160 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
161 /* copy output */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
162 for (i = 0; i < 8; i++) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
163 STORE64H(md->whirlpool.state[i], hash+(8*i)); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
164 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
165 #ifdef CLEAN_STACK |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
166 zeromem(md, sizeof(*md)); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
167 #endif |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
168 return CRYPT_OK; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
169 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
170 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
171 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
172 int whirlpool_test(void) |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
173 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
174 #ifndef LTC_TEST |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
175 return CRYPT_NOP; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
176 #else |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
177 static const struct { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
178 int len; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
179 unsigned char msg[128], hash[64]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
180 } tests[] = { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
181 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
182 /* NULL Message */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
183 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
184 0, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
185 { 0x00 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
186 { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66, 0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
187 0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8, 0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
188 0x3E, 0x83, 0xBE, 0x69, 0x8B, 0x28, 0x8F, 0xEB, 0xCF, 0x88, 0xE3, 0xE0, 0x3C, 0x4F, 0x07, 0x57, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
189 0xEA, 0x89, 0x64, 0xE5, 0x9B, 0x63, 0xD9, 0x37, 0x08, 0xB1, 0x38, 0xCC, 0x42, 0xA6, 0x6E, 0xB3 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
190 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
191 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
192 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
193 /* 448-bits of 0 bits */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
194 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
195 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
196 56, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
197 { 0x00 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
198 { 0x0B, 0x3F, 0x53, 0x78, 0xEB, 0xED, 0x2B, 0xF4, 0xD7, 0xBE, 0x3C, 0xFD, 0x81, 0x8C, 0x1B, 0x03, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
199 0xB6, 0xBB, 0x03, 0xD3, 0x46, 0x94, 0x8B, 0x04, 0xF4, 0xF4, 0x0C, 0x72, 0x6F, 0x07, 0x58, 0x70, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
200 0x2A, 0x0F, 0x1E, 0x22, 0x58, 0x80, 0xE3, 0x8D, 0xD5, 0xF6, 0xED, 0x6D, 0xE9, 0xB1, 0xE9, 0x61, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
201 0xE4, 0x9F, 0xC1, 0x31, 0x8D, 0x7C, 0xB7, 0x48, 0x22, 0xF3, 0xD0, 0xE2, 0xE9, 0xA7, 0xE7, 0xB0 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
202 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
203 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
204 /* 520-bits of 0 bits */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
205 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
206 65, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
207 { 0x00 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
208 { 0x85, 0xE1, 0x24, 0xC4, 0x41, 0x5B, 0xCF, 0x43, 0x19, 0x54, 0x3E, 0x3A, 0x63, 0xFF, 0x57, 0x1D, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
209 0x09, 0x35, 0x4C, 0xEE, 0xBE, 0xE1, 0xE3, 0x25, 0x30, 0x8C, 0x90, 0x69, 0xF4, 0x3E, 0x2A, 0xE4, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
210 0xD0, 0xE5, 0x1D, 0x4E, 0xB1, 0xE8, 0x64, 0x28, 0x70, 0x19, 0x4E, 0x95, 0x30, 0xD8, 0xD8, 0xAF, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
211 0x65, 0x89, 0xD1, 0xBF, 0x69, 0x49, 0xDD, 0xF9, 0x0A, 0x7F, 0x12, 0x08, 0x62, 0x37, 0x95, 0xB9 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
212 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
213 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
214 /* 512-bits, leading set */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
215 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
216 64, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
217 { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
219 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
220 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
221 { 0x10, 0x3E, 0x00, 0x55, 0xA9, 0xB0, 0x90, 0xE1, 0x1C, 0x8F, 0xDD, 0xEB, 0xBA, 0x06, 0xC0, 0x5A, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
222 0xCE, 0x8B, 0x64, 0xB8, 0x96, 0x12, 0x8F, 0x6E, 0xED, 0x30, 0x71, 0xFC, 0xF3, 0xDC, 0x16, 0x94, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
223 0x67, 0x78, 0xE0, 0x72, 0x23, 0x23, 0x3F, 0xD1, 0x80, 0xFC, 0x40, 0xCC, 0xDB, 0x84, 0x30, 0xA6, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
224 0x40, 0xE3, 0x76, 0x34, 0x27, 0x1E, 0x65, 0x5C, 0xA1, 0x67, 0x4E, 0xBF, 0xF5, 0x07, 0xF8, 0xCB } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
225 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
226 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
227 /* 512-bits, leading set of second byte */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
228 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
229 64, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
230 { 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
234 { 0x35, 0x7B, 0x42, 0xEA, 0x79, 0xBC, 0x97, 0x86, 0x97, 0x5A, 0x3C, 0x44, 0x70, 0xAA, 0xB2, 0x3E, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
235 0x62, 0x29, 0x79, 0x7B, 0xAD, 0xBD, 0x54, 0x36, 0x5B, 0x54, 0x96, 0xE5, 0x5D, 0x9D, 0xD7, 0x9F, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
236 0xE9, 0x62, 0x4F, 0xB4, 0x22, 0x66, 0x93, 0x0A, 0x62, 0x8E, 0xD4, 0xDB, 0x08, 0xF9, 0xDD, 0x35, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
237 0xEF, 0x1B, 0xE1, 0x04, 0x53, 0xFC, 0x18, 0xF4, 0x2C, 0x7F, 0x5E, 0x1F, 0x9B, 0xAE, 0x55, 0xE0 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
238 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
239 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
240 /* 512-bits, leading set of last byte */ |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
241 { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
242 64, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
243 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
244 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
245 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
247 { 0x8B, 0x39, 0x04, 0xDD, 0x19, 0x81, 0x41, 0x26, 0xFD, 0x02, 0x74, 0xAB, 0x49, 0xC5, 0x97, 0xF6, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
248 0xD7, 0x75, 0x33, 0x52, 0xA2, 0xDD, 0x91, 0xFD, 0x8F, 0x9F, 0x54, 0x05, 0x4C, 0x54, 0xBF, 0x0F, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
249 0x06, 0xDB, 0x4F, 0xF7, 0x08, 0xA3, 0xA2, 0x8B, 0xC3, 0x7A, 0x92, 0x1E, 0xEE, 0x11, 0xED, 0x7B, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
250 0x6A, 0x53, 0x79, 0x32, 0xCC, 0x5E, 0x94, 0xEE, 0x1E, 0xA6, 0x57, 0x60, 0x7E, 0x36, 0xC9, 0xF7 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
251 }, |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
252 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
253 }; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
254 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
255 int i; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
256 unsigned char tmp[64]; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
257 hash_state md; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
258 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
259 for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
260 whirlpool_init(&md); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
261 whirlpool_process(&md, (unsigned char *)tests[i].msg, tests[i].len); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
262 whirlpool_done(&md, tmp); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
263 if (memcmp(tmp, tests[i].hash, 64) != 0) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
264 #if 0 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
265 printf("\nFailed test %d\n", i); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
266 for (i = 0; i < 64; ) { |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
267 printf("%02x ", tmp[i]); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
268 if (!(++i & 15)) printf("\n"); |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
269 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
270 #endif |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
271 return CRYPT_FAIL_TESTVECTOR; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
272 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
273 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
274 return CRYPT_OK; |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
275 #endif |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
276 } |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
277 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
278 |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
279 #endif |
b939f2d4431e
Include files accidentally zeroed when merging 0.96 release
Matt Johnston <matt@ucc.asn.au>
parents:
16
diff
changeset
|
280 |