security/nss/lib/util/hasht.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     5 #ifndef _HASHT_H_
     6 #define _HASHT_H_
     8 #include "prtypes.h"
    10 /* Opaque objects */
    11 typedef struct SECHashObjectStr SECHashObject;
    12 typedef struct HASHContextStr HASHContext;
    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_AlgTOTAL
    28 } HASH_HashType;
    30 /*
    31  * Number of bytes each hash algorithm produces
    32  */
    33 #define MD2_LENGTH	16
    34 #define MD5_LENGTH	16
    35 #define SHA1_LENGTH	20
    36 #define SHA224_LENGTH 	28
    37 #define SHA256_LENGTH 	32
    38 #define SHA384_LENGTH 	48
    39 #define SHA512_LENGTH 	64
    40 #define HASH_LENGTH_MAX SHA512_LENGTH
    42 /*
    43  * Structure to hold hash computation info and routines
    44  */
    45 struct SECHashObjectStr {
    46     unsigned int length;  /* hash output length (in bytes) */
    47     void * (*create)(void);
    48     void * (*clone)(void *);
    49     void (*destroy)(void *, PRBool);
    50     void (*begin)(void *);
    51     void (*update)(void *, const unsigned char *, unsigned int);
    52     void (*end)(void *, unsigned char *, unsigned int *, unsigned int);
    53     unsigned int blocklength;  /* hash input block size (in bytes) */
    54     HASH_HashType type;
    55     void (*end_raw)(void *, unsigned char *, unsigned int *, unsigned int);
    56 };
    58 struct HASHContextStr {
    59     const struct SECHashObjectStr *hashobj;
    60     void *hash_context;
    61 };
    63 #endif /* _HASHT_H_ */

mercurial