comparison sha224.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
26 &sha224_done, 26 &sha224_done,
27 &sha224_test 27 &sha224_test
28 }; 28 };
29 29
30 /* init the sha256 er... sha224 state ;-) */ 30 /* init the sha256 er... sha224 state ;-) */
31 void sha224_init(hash_state * md) 31 int sha224_init(hash_state * md)
32 { 32 {
33 _ARGCHK(md != NULL); 33 _ARGCHK(md != NULL);
34 34
35 md->sha256.curlen = 0; 35 md->sha256.curlen = 0;
36 md->sha256.length = 0; 36 md->sha256.length = 0;
40 md->sha256.state[3] = 0xf70e5939UL; 40 md->sha256.state[3] = 0xf70e5939UL;
41 md->sha256.state[4] = 0xffc00b31UL; 41 md->sha256.state[4] = 0xffc00b31UL;
42 md->sha256.state[5] = 0x68581511UL; 42 md->sha256.state[5] = 0x68581511UL;
43 md->sha256.state[6] = 0x64f98fa7UL; 43 md->sha256.state[6] = 0x64f98fa7UL;
44 md->sha256.state[7] = 0xbefa4fa4UL; 44 md->sha256.state[7] = 0xbefa4fa4UL;
45 return CRYPT_OK;
45 } 46 }
46 47
47 int sha224_done(hash_state * md, unsigned char *hash) 48 int sha224_done(hash_state * md, unsigned char *hash)
48 { 49 {
49 unsigned char buf[32]; 50 unsigned char buf[32];
50 int err; 51 int err;
51 52
52 err = sha256_done(md, buf); 53 err = sha256_done(md, buf);
53 memcpy(hash, buf, 28); 54 XMEMCPY(hash, buf, 28);
54 #ifdef CLEAN_STACK 55 #ifdef CLEAN_STACK
55 zeromem(buf, sizeof(buf)); 56 zeromem(buf, sizeof(buf));
56 #endif 57 #endif
57 return err; 58 return err;
58 } 59 }