Mercurial > dropbear
comparison rmd128.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 |
---|---|
73 #define III(a, b, c, d, x, s) \ | 73 #define III(a, b, c, d, x, s) \ |
74 (a) += I((b), (c), (d)) + (x) + 0x50a28be6UL;\ | 74 (a) += I((b), (c), (d)) + (x) + 0x50a28be6UL;\ |
75 (a) = ROL((a), (s)); | 75 (a) = ROL((a), (s)); |
76 | 76 |
77 #ifdef CLEAN_STACK | 77 #ifdef CLEAN_STACK |
78 static void _rmd128_compress(hash_state *md, unsigned char *buf) | 78 static int _rmd128_compress(hash_state *md, unsigned char *buf) |
79 #else | 79 #else |
80 static void rmd128_compress(hash_state *md, unsigned char *buf) | 80 static int rmd128_compress(hash_state *md, unsigned char *buf) |
81 #endif | 81 #endif |
82 { | 82 { |
83 ulong32 aa,bb,cc,dd,aaa,bbb,ccc,ddd,X[16]; | 83 ulong32 aa,bb,cc,dd,aaa,bbb,ccc,ddd,X[16]; |
84 int i; | 84 int i; |
85 | 85 |
242 ddd += cc + md->rmd128.state[1]; /* final result for MDbuf[0] */ | 242 ddd += cc + md->rmd128.state[1]; /* final result for MDbuf[0] */ |
243 md->rmd128.state[1] = md->rmd128.state[2] + dd + aaa; | 243 md->rmd128.state[1] = md->rmd128.state[2] + dd + aaa; |
244 md->rmd128.state[2] = md->rmd128.state[3] + aa + bbb; | 244 md->rmd128.state[2] = md->rmd128.state[3] + aa + bbb; |
245 md->rmd128.state[3] = md->rmd128.state[0] + bb + ccc; | 245 md->rmd128.state[3] = md->rmd128.state[0] + bb + ccc; |
246 md->rmd128.state[0] = ddd; | 246 md->rmd128.state[0] = ddd; |
247 | |
248 return CRYPT_OK; | |
247 } | 249 } |
248 | 250 |
249 #ifdef CLEAN_STACK | 251 #ifdef CLEAN_STACK |
250 static void rmd128_compress(hash_state *md, unsigned char *buf) | 252 static int rmd128_compress(hash_state *md, unsigned char *buf) |
251 { | 253 { |
252 _rmd128_compress(md, buf); | 254 int err; |
255 err = _rmd128_compress(md, buf); | |
253 burn_stack(sizeof(ulong32) * 24 + sizeof(int)); | 256 burn_stack(sizeof(ulong32) * 24 + sizeof(int)); |
254 } | 257 return err; |
255 #endif | 258 } |
256 | 259 #endif |
257 void rmd128_init(hash_state * md) | 260 |
261 int rmd128_init(hash_state * md) | |
258 { | 262 { |
259 _ARGCHK(md != NULL); | 263 _ARGCHK(md != NULL); |
260 md->rmd128.state[0] = 0x67452301UL; | 264 md->rmd128.state[0] = 0x67452301UL; |
261 md->rmd128.state[1] = 0xefcdab89UL; | 265 md->rmd128.state[1] = 0xefcdab89UL; |
262 md->rmd128.state[2] = 0x98badcfeUL; | 266 md->rmd128.state[2] = 0x98badcfeUL; |
263 md->rmd128.state[3] = 0x10325476UL; | 267 md->rmd128.state[3] = 0x10325476UL; |
264 md->rmd128.curlen = 0; | 268 md->rmd128.curlen = 0; |
265 md->rmd128.length = 0; | 269 md->rmd128.length = 0; |
270 return CRYPT_OK; | |
266 } | 271 } |
267 | 272 |
268 HASH_PROCESS(rmd128_process, rmd128_compress, rmd128, 64) | 273 HASH_PROCESS(rmd128_process, rmd128_compress, rmd128, 64) |
269 | 274 |
270 int rmd128_done(hash_state * md, unsigned char *hash) | 275 int rmd128_done(hash_state * md, unsigned char *hash) |