comparison md5.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 c2b93763dac9
comparison
equal deleted inserted replaced
15:6362d3854bb4 143:5d99163f7e32
79 }; 79 };
80 80
81 #endif 81 #endif
82 82
83 #ifdef CLEAN_STACK 83 #ifdef CLEAN_STACK
84 static void _md5_compress(hash_state *md, unsigned char *buf) 84 static int _md5_compress(hash_state *md, unsigned char *buf)
85 #else 85 #else
86 static void md5_compress(hash_state *md, unsigned char *buf) 86 static int md5_compress(hash_state *md, unsigned char *buf)
87 #endif 87 #endif
88 { 88 {
89 ulong32 i, W[16], a, b, c, d; 89 ulong32 i, W[16], a, b, c, d;
90 #ifdef SMALL_CODE 90 #ifdef SMALL_CODE
91 ulong32 t; 91 ulong32 t;
192 192
193 md->md5.state[0] = md->md5.state[0] + a; 193 md->md5.state[0] = md->md5.state[0] + a;
194 md->md5.state[1] = md->md5.state[1] + b; 194 md->md5.state[1] = md->md5.state[1] + b;
195 md->md5.state[2] = md->md5.state[2] + c; 195 md->md5.state[2] = md->md5.state[2] + c;
196 md->md5.state[3] = md->md5.state[3] + d; 196 md->md5.state[3] = md->md5.state[3] + d;
197
198 return CRYPT_OK;
197 } 199 }
198 200
199 #ifdef CLEAN_STACK 201 #ifdef CLEAN_STACK
200 static void md5_compress(hash_state *md, unsigned char *buf) 202 static int md5_compress(hash_state *md, unsigned char *buf)
201 { 203 {
202 _md5_compress(md, buf); 204 int err;
205 err = _md5_compress(md, buf);
203 burn_stack(sizeof(ulong32) * 21); 206 burn_stack(sizeof(ulong32) * 21);
204 } 207 return err;
205 #endif 208 }
206 209 #endif
207 void md5_init(hash_state * md) 210
211 int md5_init(hash_state * md)
208 { 212 {
209 _ARGCHK(md != NULL); 213 _ARGCHK(md != NULL);
210 md->md5.state[0] = 0x67452301UL; 214 md->md5.state[0] = 0x67452301UL;
211 md->md5.state[1] = 0xefcdab89UL; 215 md->md5.state[1] = 0xefcdab89UL;
212 md->md5.state[2] = 0x98badcfeUL; 216 md->md5.state[2] = 0x98badcfeUL;
213 md->md5.state[3] = 0x10325476UL; 217 md->md5.state[3] = 0x10325476UL;
214 md->md5.curlen = 0; 218 md->md5.curlen = 0;
215 md->md5.length = 0; 219 md->md5.length = 0;
220 return CRYPT_OK;
216 } 221 }
217 222
218 HASH_PROCESS(md5_process, md5_compress, md5, 64) 223 HASH_PROCESS(md5_process, md5_compress, md5, 64)
219 224
220 int md5_done(hash_state * md, unsigned char *hash) 225 int md5_done(hash_state * md, unsigned char *hash)