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 | |
9 | static const char rcsid[]="$Id: hmac.c,v 1.2 2005/02/21 03:18:30 mrsam Exp $"; |
10 | |
11 | static void alloc_context_sha1( void (*func)(void *, void *), void *arg) |
12 | { |
13 | struct SHA1_CONTEXT c; |
14 | |
15 | (*func)((void *)&c, arg); |
16 | } |
17 | |
18 | static void alloc_hash_sha1( void (*func)(unsigned char *, void *), void *arg) |
19 | { |
20 | unsigned char c[SHA1_DIGEST_SIZE]; |
21 | |
22 | (*func)(c, arg); |
23 | } |
24 | |
25 | struct hmac_hashinfo hmac_sha1 = { |
26 | "sha1", |
27 | SHA1_BLOCK_SIZE, |
28 | SHA1_DIGEST_SIZE, |
29 | sizeof(struct SHA1_CONTEXT), |
30 | (void (*)(void *))sha1_context_init, |
31 | (void (*)(void *, const void *, unsigned))sha1_context_hashstream, |
32 | (void (*)(void *, unsigned long))sha1_context_endstream, |
33 | (void (*)(void *, unsigned char *))sha1_context_digest, |
34 | (void (*)(void *, const unsigned char *))sha1_context_restore, |
35 | alloc_context_sha1, |
36 | alloc_hash_sha1}; |
37 | |
38 | static void alloc_context_sha256( void (*func)(void *, void *), void *arg) |
39 | { |
40 | struct SHA256_CONTEXT c; |
41 | |
42 | (*func)((void *)&c, arg); |
43 | } |
44 | |
45 | static void alloc_hash_sha256( void (*func)(unsigned char *, void *), void *arg) |
46 | { |
47 | unsigned char c[SHA256_DIGEST_SIZE]; |
48 | |
49 | (*func)(c, arg); |
50 | } |
51 | |
52 | struct hmac_hashinfo hmac_sha256 = { |
53 | "sha256", |
54 | SHA256_BLOCK_SIZE, |
55 | SHA256_DIGEST_SIZE, |
56 | sizeof(struct SHA256_CONTEXT), |
57 | (void (*)(void *))sha256_context_init, |
58 | (void (*)(void *, const void *, unsigned))sha256_context_hashstream, |
59 | (void (*)(void *, unsigned long))sha256_context_endstream, |
60 | (void (*)(void *, unsigned char *))sha256_context_digest, |
61 | (void (*)(void *, const unsigned char *))sha256_context_restore, |
62 | alloc_context_sha256, |
63 | alloc_hash_sha256}; |