michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _HASHT_H_ michael@0: #define _HASHT_H_ michael@0: michael@0: #include "prtypes.h" michael@0: michael@0: /* Opaque objects */ michael@0: typedef struct SECHashObjectStr SECHashObject; michael@0: typedef struct HASHContextStr HASHContext; michael@0: michael@0: /* michael@0: * The hash functions the security library supports michael@0: * NOTE the order must match the definition of SECHashObjects[]! michael@0: */ michael@0: typedef enum { michael@0: HASH_AlgNULL = 0, michael@0: HASH_AlgMD2 = 1, michael@0: HASH_AlgMD5 = 2, michael@0: HASH_AlgSHA1 = 3, michael@0: HASH_AlgSHA256 = 4, michael@0: HASH_AlgSHA384 = 5, michael@0: HASH_AlgSHA512 = 6, michael@0: HASH_AlgSHA224 = 7, michael@0: HASH_AlgTOTAL michael@0: } HASH_HashType; michael@0: michael@0: /* michael@0: * Number of bytes each hash algorithm produces michael@0: */ michael@0: #define MD2_LENGTH 16 michael@0: #define MD5_LENGTH 16 michael@0: #define SHA1_LENGTH 20 michael@0: #define SHA224_LENGTH 28 michael@0: #define SHA256_LENGTH 32 michael@0: #define SHA384_LENGTH 48 michael@0: #define SHA512_LENGTH 64 michael@0: #define HASH_LENGTH_MAX SHA512_LENGTH michael@0: michael@0: /* michael@0: * Structure to hold hash computation info and routines michael@0: */ michael@0: struct SECHashObjectStr { michael@0: unsigned int length; /* hash output length (in bytes) */ michael@0: void * (*create)(void); michael@0: void * (*clone)(void *); michael@0: void (*destroy)(void *, PRBool); michael@0: void (*begin)(void *); michael@0: void (*update)(void *, const unsigned char *, unsigned int); michael@0: void (*end)(void *, unsigned char *, unsigned int *, unsigned int); michael@0: unsigned int blocklength; /* hash input block size (in bytes) */ michael@0: HASH_HashType type; michael@0: void (*end_raw)(void *, unsigned char *, unsigned int *, unsigned int); michael@0: }; michael@0: michael@0: struct HASHContextStr { michael@0: const struct SECHashObjectStr *hashobj; michael@0: void *hash_context; michael@0: }; michael@0: michael@0: #endif /* _HASHT_H_ */