Mercurial > dropbear
comparison sha384.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 |
---|---|
28 &sha512_process, | 28 &sha512_process, |
29 &sha384_done, | 29 &sha384_done, |
30 &sha384_test | 30 &sha384_test |
31 }; | 31 }; |
32 | 32 |
33 void sha384_init(hash_state * md) | 33 int sha384_init(hash_state * md) |
34 { | 34 { |
35 _ARGCHK(md != NULL); | 35 _ARGCHK(md != NULL); |
36 | 36 |
37 md->sha512.curlen = 0; | 37 md->sha512.curlen = 0; |
38 md->sha512.length = 0; | 38 md->sha512.length = 0; |
42 md->sha512.state[3] = CONST64(0x152fecd8f70e5939); | 42 md->sha512.state[3] = CONST64(0x152fecd8f70e5939); |
43 md->sha512.state[4] = CONST64(0x67332667ffc00b31); | 43 md->sha512.state[4] = CONST64(0x67332667ffc00b31); |
44 md->sha512.state[5] = CONST64(0x8eb44a8768581511); | 44 md->sha512.state[5] = CONST64(0x8eb44a8768581511); |
45 md->sha512.state[6] = CONST64(0xdb0c2e0d64f98fa7); | 45 md->sha512.state[6] = CONST64(0xdb0c2e0d64f98fa7); |
46 md->sha512.state[7] = CONST64(0x47b5481dbefa4fa4); | 46 md->sha512.state[7] = CONST64(0x47b5481dbefa4fa4); |
47 return CRYPT_OK; | |
47 } | 48 } |
48 | 49 |
49 int sha384_done(hash_state * md, unsigned char *hash) | 50 int sha384_done(hash_state * md, unsigned char *hash) |
50 { | 51 { |
51 unsigned char buf[64]; | 52 unsigned char buf[64]; |
56 if (md->sha512.curlen >= sizeof(md->sha512.buf)) { | 57 if (md->sha512.curlen >= sizeof(md->sha512.buf)) { |
57 return CRYPT_INVALID_ARG; | 58 return CRYPT_INVALID_ARG; |
58 } | 59 } |
59 | 60 |
60 sha512_done(md, buf); | 61 sha512_done(md, buf); |
61 memcpy(hash, buf, 48); | 62 XMEMCPY(hash, buf, 48); |
62 #ifdef CLEAN_STACK | 63 #ifdef CLEAN_STACK |
63 zeromem(buf, sizeof(buf)); | 64 zeromem(buf, sizeof(buf)); |
64 #endif | 65 #endif |
65 return CRYPT_OK; | 66 return CRYPT_OK; |
66 } | 67 } |