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