hasht.h (1907B)
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 5 #ifndef _HASHT_H_ 6 #define _HASHT_H_ 7 8 #include "prtypes.h" 9 10 /* Opaque objects */ 11 typedef struct SECHashObjectStr SECHashObject; 12 typedef struct HASHContextStr HASHContext; 13 14 /* 15 * The hash functions the security library supports 16 * NOTE the order must match the definition of SECHashObjects[]! 17 */ 18 typedef enum { 19 HASH_AlgNULL = 0, 20 HASH_AlgMD2 = 1, 21 HASH_AlgMD5 = 2, 22 HASH_AlgSHA1 = 3, 23 HASH_AlgSHA256 = 4, 24 HASH_AlgSHA384 = 5, 25 HASH_AlgSHA512 = 6, 26 HASH_AlgSHA224 = 7, 27 HASH_AlgSHA3_224 = 8, 28 HASH_AlgSHA3_256 = 9, 29 HASH_AlgSHA3_384 = 10, 30 HASH_AlgSHA3_512 = 11, 31 HASH_AlgTOTAL 32 } HASH_HashType; 33 34 /* 35 * Number of bytes each hash algorithm produces 36 */ 37 #define MD2_LENGTH 16 38 #define MD5_LENGTH 16 39 #define SHA1_LENGTH 20 40 #define SHA224_LENGTH 28 41 #define SHA256_LENGTH 32 42 #define SHA384_LENGTH 48 43 #define SHA512_LENGTH 64 44 #define SHA3_224_LENGTH 28 45 #define SHA3_256_LENGTH 32 46 #define SHA3_384_LENGTH 48 47 #define SHA3_512_LENGTH 64 48 #define HASH_LENGTH_MAX SHA512_LENGTH 49 50 /* 51 * Structure to hold hash computation info and routines 52 */ 53 struct SECHashObjectStr { 54 unsigned int length; /* hash output length (in bytes) */ 55 void *(*create)(void); 56 void *(*clone)(void *); 57 void (*destroy)(void *, PRBool); 58 void (*begin)(void *); 59 void (*update)(void *, const unsigned char *, unsigned int); 60 void (*end)(void *, unsigned char *, unsigned int *, unsigned int); 61 unsigned int blocklength; /* hash input block size (in bytes) */ 62 HASH_HashType type; 63 void (*end_raw)(void *, unsigned char *, unsigned int *, unsigned int); 64 }; 65 66 struct HASHContextStr { 67 const struct SECHashObjectStr *hashobj; 68 void *hash_context; 69 }; 70 71 #endif /* _HASHT_H_ */