Mercurial > dropbear
comparison whirl.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 | 7ed585a2c53b |
comparison
equal
deleted
inserted
replaced
15:6362d3854bb4 | 143:5d99163f7e32 |
---|---|
48 SB5(GB(a, i-5, 2)) ^ \ | 48 SB5(GB(a, i-5, 2)) ^ \ |
49 SB6(GB(a, i-6, 1)) ^ \ | 49 SB6(GB(a, i-6, 1)) ^ \ |
50 SB7(GB(a, i-7, 0)) | 50 SB7(GB(a, i-7, 0)) |
51 | 51 |
52 #ifdef CLEAN_STACK | 52 #ifdef CLEAN_STACK |
53 static void _whirlpool_compress(hash_state *md, unsigned char *buf) | 53 static int _whirlpool_compress(hash_state *md, unsigned char *buf) |
54 #else | 54 #else |
55 static void whirlpool_compress(hash_state *md, unsigned char *buf) | 55 static int whirlpool_compress(hash_state *md, unsigned char *buf) |
56 #endif | 56 #endif |
57 { | 57 { |
58 ulong64 K[2][8], T[3][8]; | 58 ulong64 K[2][8], T[3][8]; |
59 int x, y; | 59 int x, y; |
60 | 60 |
88 K[0][y] = theta_pi_gamma(K[1], y); | 88 K[0][y] = theta_pi_gamma(K[1], y); |
89 } | 89 } |
90 /* xor the constant */ | 90 /* xor the constant */ |
91 K[0][0] ^= cont[x+1]; | 91 K[0][0] ^= cont[x+1]; |
92 | 92 |
93 /* apply main transform to T[0] into T[1] */ | 93 /* apply main transform to T[1] into T[0] */ |
94 for (y = 0; y < 8; y++) { | 94 for (y = 0; y < 8; y++) { |
95 T[0][y] = theta_pi_gamma(T[1], y) ^ K[0][y]; | 95 T[0][y] = theta_pi_gamma(T[1], y) ^ K[0][y]; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 /* store state */ | 99 /* store state */ |
100 for (x = 0; x < 8; x++) { | 100 for (x = 0; x < 8; x++) { |
101 md->whirlpool.state[x] ^= T[0][x] ^ T[2][x]; | 101 md->whirlpool.state[x] ^= T[0][x] ^ T[2][x]; |
102 } | 102 } |
103 | |
104 return CRYPT_OK; | |
103 } | 105 } |
104 | 106 |
105 | 107 |
106 #ifdef CLEAN_STACK | 108 #ifdef CLEAN_STACK |
107 static void whirlpool_compress(hash_state *md, unsigned char *buf) | 109 static int whirlpool_compress(hash_state *md, unsigned char *buf) |
108 { | 110 { |
109 _whirlpool_compress(md, buf); | 111 int err; |
112 err = _whirlpool_compress(md, buf); | |
110 burn_stack((5 * 8 * sizeof(ulong64)) + (2 * sizeof(int))); | 113 burn_stack((5 * 8 * sizeof(ulong64)) + (2 * sizeof(int))); |
111 } | 114 return err; |
112 #endif | 115 } |
113 | 116 #endif |
114 | 117 |
115 void whirlpool_init(hash_state * md) | 118 |
119 int whirlpool_init(hash_state * md) | |
116 { | 120 { |
117 _ARGCHK(md != NULL); | 121 _ARGCHK(md != NULL); |
118 zeromem(&md->whirlpool, sizeof(md->whirlpool)); | 122 zeromem(&md->whirlpool, sizeof(md->whirlpool)); |
123 return CRYPT_OK; | |
119 } | 124 } |
120 | 125 |
121 HASH_PROCESS(whirlpool_process, whirlpool_compress, whirlpool, 64) | 126 HASH_PROCESS(whirlpool_process, whirlpool_compress, whirlpool, 64) |
122 | 127 |
123 int whirlpool_done(hash_state * md, unsigned char *hash) | 128 int whirlpool_done(hash_state * md, unsigned char *hash) |