OLD | NEW |
| (Empty) |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
4 /* $Id: hasht.h,v 1.11 2013/02/05 18:10:46 wtc%google.com Exp $ */ | |
5 | |
6 #ifndef _HASHT_H_ | |
7 #define _HASHT_H_ | |
8 | |
9 /* Opaque objects */ | |
10 typedef struct SECHashObjectStr SECHashObject; | |
11 typedef struct HASHContextStr HASHContext; | |
12 | |
13 /* | |
14 * The hash functions the security library supports | |
15 * NOTE the order must match the definition of SECHashObjects[]! | |
16 */ | |
17 typedef enum { | |
18 HASH_AlgNULL = 0, | |
19 HASH_AlgMD2 = 1, | |
20 HASH_AlgMD5 = 2, | |
21 HASH_AlgSHA1 = 3, | |
22 HASH_AlgSHA256 = 4, | |
23 HASH_AlgSHA384 = 5, | |
24 HASH_AlgSHA512 = 6, | |
25 HASH_AlgSHA224 = 7, | |
26 HASH_AlgTOTAL | |
27 } HASH_HashType; | |
28 | |
29 /* | |
30 * Number of bytes each hash algorithm produces | |
31 */ | |
32 #define MD2_LENGTH 16 | |
33 #define MD5_LENGTH 16 | |
34 #define SHA1_LENGTH 20 | |
35 #define SHA224_LENGTH 28 | |
36 #define SHA256_LENGTH 32 | |
37 #define SHA384_LENGTH 48 | |
38 #define SHA512_LENGTH 64 | |
39 #define HASH_LENGTH_MAX SHA512_LENGTH | |
40 | |
41 /* | |
42 * Structure to hold hash computation info and routines | |
43 */ | |
44 struct SECHashObjectStr { | |
45 unsigned int length; /* hash output length (in bytes) */ | |
46 void * (*create)(void); | |
47 void * (*clone)(void *); | |
48 void (*destroy)(void *, PRBool); | |
49 void (*begin)(void *); | |
50 void (*update)(void *, const unsigned char *, unsigned int); | |
51 void (*end)(void *, unsigned char *, unsigned int *, unsigned int); | |
52 unsigned int blocklength; /* hash input block size (in bytes) */ | |
53 HASH_HashType type; | |
54 void (*end_raw)(void *, unsigned char *, unsigned int *, unsigned int); | |
55 }; | |
56 | |
57 struct HASHContextStr { | |
58 const struct SECHashObjectStr *hashobj; | |
59 void *hash_context; | |
60 }; | |
61 | |
62 #endif /* _HASHT_H_ */ | |
OLD | NEW |