1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/util/hasht.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef _HASHT_H_ 1.9 +#define _HASHT_H_ 1.10 + 1.11 +#include "prtypes.h" 1.12 + 1.13 +/* Opaque objects */ 1.14 +typedef struct SECHashObjectStr SECHashObject; 1.15 +typedef struct HASHContextStr HASHContext; 1.16 + 1.17 +/* 1.18 + * The hash functions the security library supports 1.19 + * NOTE the order must match the definition of SECHashObjects[]! 1.20 + */ 1.21 +typedef enum { 1.22 + HASH_AlgNULL = 0, 1.23 + HASH_AlgMD2 = 1, 1.24 + HASH_AlgMD5 = 2, 1.25 + HASH_AlgSHA1 = 3, 1.26 + HASH_AlgSHA256 = 4, 1.27 + HASH_AlgSHA384 = 5, 1.28 + HASH_AlgSHA512 = 6, 1.29 + HASH_AlgSHA224 = 7, 1.30 + HASH_AlgTOTAL 1.31 +} HASH_HashType; 1.32 + 1.33 +/* 1.34 + * Number of bytes each hash algorithm produces 1.35 + */ 1.36 +#define MD2_LENGTH 16 1.37 +#define MD5_LENGTH 16 1.38 +#define SHA1_LENGTH 20 1.39 +#define SHA224_LENGTH 28 1.40 +#define SHA256_LENGTH 32 1.41 +#define SHA384_LENGTH 48 1.42 +#define SHA512_LENGTH 64 1.43 +#define HASH_LENGTH_MAX SHA512_LENGTH 1.44 + 1.45 +/* 1.46 + * Structure to hold hash computation info and routines 1.47 + */ 1.48 +struct SECHashObjectStr { 1.49 + unsigned int length; /* hash output length (in bytes) */ 1.50 + void * (*create)(void); 1.51 + void * (*clone)(void *); 1.52 + void (*destroy)(void *, PRBool); 1.53 + void (*begin)(void *); 1.54 + void (*update)(void *, const unsigned char *, unsigned int); 1.55 + void (*end)(void *, unsigned char *, unsigned int *, unsigned int); 1.56 + unsigned int blocklength; /* hash input block size (in bytes) */ 1.57 + HASH_HashType type; 1.58 + void (*end_raw)(void *, unsigned char *, unsigned int *, unsigned int); 1.59 +}; 1.60 + 1.61 +struct HASHContextStr { 1.62 + const struct SECHashObjectStr *hashobj; 1.63 + void *hash_context; 1.64 +}; 1.65 + 1.66 +#endif /* _HASHT_H_ */