Mercurial > dropbear
annotate src/headers/tomcrypt_hash.h @ 191:1c15b283127b libtomcrypt-orig
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 06 May 2005 13:23:02 +0000 |
parents | |
children | 39d5d58461d6 |
rev | line source |
---|---|
191
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1 /* ---- HASH FUNCTIONS ---- */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2 #ifdef SHA512 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
3 struct sha512_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
4 ulong64 length, state[8]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
5 unsigned long curlen; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
6 unsigned char buf[128]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
7 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
8 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
9 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
10 #ifdef SHA256 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
11 struct sha256_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
12 ulong64 length; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
13 ulong32 state[8], curlen; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
14 unsigned char buf[64]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
15 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
16 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
17 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
18 #ifdef SHA1 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
19 struct sha1_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
20 ulong64 length; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
21 ulong32 state[5], curlen; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
22 unsigned char buf[64]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
23 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
24 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
25 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
26 #ifdef MD5 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
27 struct md5_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
28 ulong64 length; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
29 ulong32 state[4], curlen; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
30 unsigned char buf[64]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
31 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
32 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
33 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
34 #ifdef MD4 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
35 struct md4_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
36 ulong64 length; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
37 ulong32 state[4], curlen; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
38 unsigned char buf[64]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
39 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
40 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
41 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
42 #ifdef TIGER |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
43 struct tiger_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
44 ulong64 state[3], length; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
45 unsigned long curlen; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
46 unsigned char buf[64]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
47 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
48 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
49 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
50 #ifdef MD2 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
51 struct md2_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
52 unsigned char chksum[16], X[48], buf[16]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
53 unsigned long curlen; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
54 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
55 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
56 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
57 #ifdef RIPEMD128 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
58 struct rmd128_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
59 ulong64 length; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
60 unsigned char buf[64]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
61 ulong32 curlen, state[4]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
62 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
63 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
64 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
65 #ifdef RIPEMD160 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
66 struct rmd160_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
67 ulong64 length; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
68 unsigned char buf[64]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
69 ulong32 curlen, state[5]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
70 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
71 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
72 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
73 #ifdef WHIRLPOOL |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
74 struct whirlpool_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
75 ulong64 length, state[8]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
76 unsigned char buf[64]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
77 ulong32 curlen; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
78 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
79 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
80 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
81 #ifdef CHC_HASH |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
82 struct chc_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
83 ulong64 length; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
84 unsigned char state[MAXBLOCKSIZE], buf[MAXBLOCKSIZE]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
85 ulong32 curlen; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
86 }; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
87 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
88 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
89 typedef union Hash_state { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
90 #ifdef CHC_HASH |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
91 struct chc_state chc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
92 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
93 #ifdef WHIRLPOOL |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
94 struct whirlpool_state whirlpool; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
95 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
96 #ifdef SHA512 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
97 struct sha512_state sha512; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
98 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
99 #ifdef SHA256 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
100 struct sha256_state sha256; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
101 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
102 #ifdef SHA1 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
103 struct sha1_state sha1; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
104 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
105 #ifdef MD5 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
106 struct md5_state md5; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
107 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
108 #ifdef MD4 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
109 struct md4_state md4; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
110 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
111 #ifdef MD2 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
112 struct md2_state md2; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
113 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
114 #ifdef TIGER |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
115 struct tiger_state tiger; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
116 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
117 #ifdef RIPEMD128 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
118 struct rmd128_state rmd128; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
119 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
120 #ifdef RIPEMD160 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
121 struct rmd160_state rmd160; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
122 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
123 void *data; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
124 } hash_state; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
125 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
126 extern struct ltc_hash_descriptor { |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
127 /** name of hash */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
128 char *name; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
129 /** internal ID */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
130 unsigned char ID; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
131 /** Size of digest in octets */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
132 unsigned long hashsize; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
133 /** Input block size in octets */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
134 unsigned long blocksize; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
135 /** ASN.1 DER identifier */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
136 unsigned char DER[64]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
137 /** Length of DER encoding */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
138 unsigned long DERlen; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
139 /** Init a hash state |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
140 @param hash The hash to initialize |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
141 @return CRYPT_OK if successful |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
142 */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
143 int (*init)(hash_state *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
144 /** Process a block of data |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
145 @param hash The hash state |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
146 @param in The data to hash |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
147 @param inlen The length of the data (octets) |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
148 @return CRYPT_OK if successful |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
149 */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
150 int (*process)(hash_state *hash, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
151 /** Produce the digest and store it |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
152 @param hash The hash state |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
153 @param out [out] The destination of the digest |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
154 @return CRYPT_OK if successful |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
155 */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
156 int (*done)(hash_state *hash, unsigned char *out); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
157 /** Self-test |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
158 @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
159 */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
160 int (*test)(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
161 } hash_descriptor[]; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
162 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
163 #ifdef CHC_HASH |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
164 int chc_register(int cipher); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
165 int chc_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
166 int chc_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
167 int chc_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
168 int chc_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
169 extern const struct ltc_hash_descriptor chc_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
170 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
171 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
172 #ifdef WHIRLPOOL |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
173 int whirlpool_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
174 int whirlpool_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
175 int whirlpool_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
176 int whirlpool_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
177 extern const struct ltc_hash_descriptor whirlpool_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
178 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
179 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
180 #ifdef SHA512 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
181 int sha512_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
182 int sha512_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
183 int sha512_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
184 int sha512_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
185 extern const struct ltc_hash_descriptor sha512_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
186 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
187 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
188 #ifdef SHA384 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
189 #ifndef SHA512 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
190 #error SHA512 is required for SHA384 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
191 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
192 int sha384_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
193 #define sha384_process sha512_process |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
194 int sha384_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
195 int sha384_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
196 extern const struct ltc_hash_descriptor sha384_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
197 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
198 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
199 #ifdef SHA256 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
200 int sha256_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
201 int sha256_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
202 int sha256_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
203 int sha256_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
204 extern const struct ltc_hash_descriptor sha256_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
205 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
206 #ifdef SHA224 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
207 #ifndef SHA256 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
208 #error SHA256 is required for SHA224 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
209 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
210 int sha224_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
211 #define sha224_process sha256_process |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
212 int sha224_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
213 int sha224_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
214 extern const struct ltc_hash_descriptor sha224_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
215 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
216 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
217 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
218 #ifdef SHA1 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
219 int sha1_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
220 int sha1_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
221 int sha1_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
222 int sha1_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
223 extern const struct ltc_hash_descriptor sha1_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
224 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
225 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
226 #ifdef MD5 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
227 int md5_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
228 int md5_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
229 int md5_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
230 int md5_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
231 extern const struct ltc_hash_descriptor md5_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
232 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
233 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
234 #ifdef MD4 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
235 int md4_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
236 int md4_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
237 int md4_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
238 int md4_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
239 extern const struct ltc_hash_descriptor md4_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
240 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
241 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
242 #ifdef MD2 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
243 int md2_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
244 int md2_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
245 int md2_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
246 int md2_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
247 extern const struct ltc_hash_descriptor md2_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
248 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
249 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
250 #ifdef TIGER |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
251 int tiger_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
252 int tiger_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
253 int tiger_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
254 int tiger_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
255 extern const struct ltc_hash_descriptor tiger_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
256 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
257 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
258 #ifdef RIPEMD128 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
259 int rmd128_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
260 int rmd128_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
261 int rmd128_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
262 int rmd128_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
263 extern const struct ltc_hash_descriptor rmd128_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
264 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
265 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
266 #ifdef RIPEMD160 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
267 int rmd160_init(hash_state * md); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
268 int rmd160_process(hash_state * md, const unsigned char *in, unsigned long inlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
269 int rmd160_done(hash_state * md, unsigned char *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
270 int rmd160_test(void); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
271 extern const struct ltc_hash_descriptor rmd160_desc; |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
272 #endif |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
273 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
274 int find_hash(const char *name); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
275 int find_hash_id(unsigned char ID); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
276 int find_hash_any(const char *name, int digestlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
277 int register_hash(const struct ltc_hash_descriptor *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
278 int unregister_hash(const struct ltc_hash_descriptor *hash); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
279 int hash_is_valid(int idx); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
280 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
281 int hash_memory(int hash, |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
282 const unsigned char *in, unsigned long inlen, |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
283 unsigned char *out, unsigned long *outlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
284 int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen, |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
285 const unsigned char *in, unsigned long inlen, ...); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
286 int hash_filehandle(int hash, FILE *in, unsigned char *out, unsigned long *outlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
287 int hash_file(int hash, const char *fname, unsigned char *out, unsigned long *outlen); |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
288 |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
289 /* a simple macro for making hash "process" functions */ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
290 #define HASH_PROCESS(func_name, compress_name, state_var, block_size) \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
291 int func_name (hash_state * md, const unsigned char *in, unsigned long inlen) \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
292 { \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
293 unsigned long n; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
294 int err; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
295 LTC_ARGCHK(md != NULL); \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
296 LTC_ARGCHK(in != NULL); \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
297 if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
298 return CRYPT_INVALID_ARG; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
299 } \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
300 while (inlen > 0) { \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
301 if (md-> state_var .curlen == 0 && inlen >= block_size) { \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
302 if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) { \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
303 return err; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
304 } \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
305 md-> state_var .length += block_size * 8; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
306 in += block_size; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
307 inlen -= block_size; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
308 } else { \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
309 n = MIN(inlen, (block_size - md-> state_var .curlen)); \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
310 memcpy(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
311 md-> state_var .curlen += n; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
312 in += n; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
313 inlen -= n; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
314 if (md-> state_var .curlen == block_size) { \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
315 if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) {\ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
316 return err; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
317 } \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
318 md-> state_var .length += 8*block_size; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
319 md-> state_var .curlen = 0; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
320 } \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
321 } \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
322 } \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
323 return CRYPT_OK; \ |
1c15b283127b
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
324 } |