d9898ee8 |
1 | /* |
2 | ** Copyright 2001-2005 Double Precision, Inc. |
3 | ** See COPYING for distribution information. |
4 | */ |
5 | #define SHA1_INTERNAL |
6 | #include "sha1.h" |
7 | #include "../libhmac/hmac.h" |
8 | |
d9898ee8 |
9 | |
10 | static void alloc_context_sha1( void (*func)(void *, void *), void *arg) |
11 | { |
12 | struct SHA1_CONTEXT c; |
13 | |
14 | (*func)((void *)&c, arg); |
15 | } |
16 | |
17 | static void alloc_hash_sha1( void (*func)(unsigned char *, void *), void *arg) |
18 | { |
19 | unsigned char c[SHA1_DIGEST_SIZE]; |
20 | |
21 | (*func)(c, arg); |
22 | } |
23 | |
24 | struct hmac_hashinfo hmac_sha1 = { |
25 | "sha1", |
26 | SHA1_BLOCK_SIZE, |
27 | SHA1_DIGEST_SIZE, |
28 | sizeof(struct SHA1_CONTEXT), |
29 | (void (*)(void *))sha1_context_init, |
30 | (void (*)(void *, const void *, unsigned))sha1_context_hashstream, |
31 | (void (*)(void *, unsigned long))sha1_context_endstream, |
32 | (void (*)(void *, unsigned char *))sha1_context_digest, |
33 | (void (*)(void *, const unsigned char *))sha1_context_restore, |
34 | alloc_context_sha1, |
35 | alloc_hash_sha1}; |
36 | |
37 | static void alloc_context_sha256( void (*func)(void *, void *), void *arg) |
38 | { |
39 | struct SHA256_CONTEXT c; |
40 | |
41 | (*func)((void *)&c, arg); |
42 | } |
43 | |
44 | static void alloc_hash_sha256( void (*func)(unsigned char *, void *), void *arg) |
45 | { |
46 | unsigned char c[SHA256_DIGEST_SIZE]; |
47 | |
48 | (*func)(c, arg); |
49 | } |
50 | |
51 | struct hmac_hashinfo hmac_sha256 = { |
52 | "sha256", |
53 | SHA256_BLOCK_SIZE, |
54 | SHA256_DIGEST_SIZE, |
55 | sizeof(struct SHA256_CONTEXT), |
56 | (void (*)(void *))sha256_context_init, |
57 | (void (*)(void *, const void *, unsigned))sha256_context_hashstream, |
58 | (void (*)(void *, unsigned long))sha256_context_endstream, |
59 | (void (*)(void *, unsigned char *))sha256_context_digest, |
60 | (void (*)(void *, const unsigned char *))sha256_context_restore, |
61 | alloc_context_sha256, |
62 | alloc_hash_sha256}; |