- Timestamp:
- Feb 7, 2019, 8:36:33 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_rx/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/hash.h
r337 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/hash.h 24 */ 22 25 23 26 #ifndef WOLF_CRYPT_HASH_H … … 38 41 #include <wolfssl/wolfcrypt/sha512.h> 39 42 #endif 43 #ifdef HAVE_BLAKE2 44 #include <wolfssl/wolfcrypt/blake2.h> 45 #endif 46 #ifdef WOLFSSL_SHA3 47 #include <wolfssl/wolfcrypt/sha3.h> 48 #endif 49 #ifndef NO_MD4 50 #include <wolfssl/wolfcrypt/md4.h> 51 #endif 52 #ifdef WOLFSSL_MD2 53 #include <wolfssl/wolfcrypt/md2.h> 54 #endif 55 40 56 41 57 #ifdef __cplusplus … … 43 59 #endif 44 60 45 /* Hash types */ 46 enum wc_HashType { 47 WC_HASH_TYPE_NONE = 0, 48 WC_HASH_TYPE_MD2 = 1, 49 WC_HASH_TYPE_MD4 = 2, 50 WC_HASH_TYPE_MD5 = 3, 51 WC_HASH_TYPE_SHA = 4, /* SHA-1 (not old SHA-0) */ 52 WC_HASH_TYPE_SHA224 = 9, 53 WC_HASH_TYPE_SHA256 = 5, 54 WC_HASH_TYPE_SHA384 = 6, 55 WC_HASH_TYPE_SHA512 = 7, 56 WC_HASH_TYPE_MD5_SHA = 8, 57 }; 61 #if !defined(HAVE_FIPS) && !defined(NO_OLD_WC_NAMES) 62 #define MAX_DIGEST_SIZE WC_MAX_DIGEST_SIZE 63 #endif 64 58 65 59 66 typedef union { … … 80 87 /* Find largest possible digest size 81 88 Note if this gets up to the size of 80 or over check smallstack build */ 82 #if defined(WOLFSSL_SHA512) 89 #if defined(WOLFSSL_SHA3) 90 #define WC_MAX_DIGEST_SIZE WC_SHA3_512_DIGEST_SIZE 91 #define WC_MAX_BLOCK_SIZE WC_SHA3_224_BLOCK_SIZE /* 224 is the largest block size */ 92 #elif defined(WOLFSSL_SHA512) 83 93 #define WC_MAX_DIGEST_SIZE WC_SHA512_DIGEST_SIZE 94 #define WC_MAX_BLOCK_SIZE WC_SHA512_BLOCK_SIZE 95 #elif defined(HAVE_BLAKE2) 96 #define WC_MAX_DIGEST_SIZE BLAKE2B_OUTBYTES 97 #define WC_MAX_BLOCK_SIZE BLAKE2B_BLOCKBYTES 84 98 #elif defined(WOLFSSL_SHA384) 85 99 #define WC_MAX_DIGEST_SIZE WC_SHA384_DIGEST_SIZE 100 #define WC_MAX_BLOCK_SIZE WC_SHA384_BLOCK_SIZE 86 101 #elif !defined(NO_SHA256) 87 102 #define WC_MAX_DIGEST_SIZE WC_SHA256_DIGEST_SIZE 103 #define WC_MAX_BLOCK_SIZE WC_SHA256_BLOCK_SIZE 88 104 #elif defined(WOLFSSL_SHA224) 89 105 #define WC_MAX_DIGEST_SIZE WC_SHA224_DIGEST_SIZE 106 #define WC_MAX_BLOCK_SIZE WC_SHA224_BLOCK_SIZE 90 107 #elif !defined(NO_SHA) 91 108 #define WC_MAX_DIGEST_SIZE WC_SHA_DIGEST_SIZE 109 #define WC_MAX_BLOCK_SIZE WC_SHA_BLOCK_SIZE 92 110 #elif !defined(NO_MD5) 93 111 #define WC_MAX_DIGEST_SIZE WC_MD5_DIGEST_SIZE 112 #define WC_MAX_BLOCK_SIZE WC_MD5_BLOCK_SIZE 94 113 #else 95 114 #define WC_MAX_DIGEST_SIZE 64 /* default to max size of 64 */ 115 #define WC_MAX_BLOCK_SIZE 128 96 116 #endif 97 117 98 118 #if !defined(NO_ASN) || !defined(NO_DH) || defined(HAVE_ECC) 99 119 WOLFSSL_API int wc_HashGetOID(enum wc_HashType hash_type); 120 WOLFSSL_API enum wc_HashType wc_OidGetHash(int oid); 100 121 #endif 101 122 123 WOLFSSL_API enum wc_HashType wc_HashTypeConvert(int hashType); 124 102 125 WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type); 126 WOLFSSL_API int wc_HashGetBlockSize(enum wc_HashType hash_type); 103 127 WOLFSSL_API int wc_Hash(enum wc_HashType hash_type, 104 128 const byte* data, word32 data_len, … … 111 135 WOLFSSL_API int wc_HashFinal(wc_HashAlg* hash, enum wc_HashType type, 112 136 byte* out); 113 137 WOLFSSL_API int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type); 114 138 115 139 #ifndef NO_MD5 … … 123 147 #endif 124 148 149 #ifdef WOLFSSL_SHA224 150 #include <wolfssl/wolfcrypt/sha256.h> 151 WOLFSSL_API int wc_Sha224Hash(const byte*, word32, byte*); 152 #endif /* defined(WOLFSSL_SHA224) */ 153 125 154 #ifndef NO_SHA256 126 155 #include <wolfssl/wolfcrypt/sha256.h> 127 156 WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*); 157 #endif 128 158 129 #if defined(WOLFSSL_SHA224) 130 WOLFSSL_API int wc_Sha224Hash(const byte*, word32, byte*); 131 #endif /* defined(WOLFSSL_SHA224) */132 #endif 159 #ifdef WOLFSSL_SHA384 160 #include <wolfssl/wolfcrypt/sha512.h> 161 WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*); 162 #endif /* defined(WOLFSSL_SHA384) */ 133 163 134 164 #ifdef WOLFSSL_SHA512 135 165 #include <wolfssl/wolfcrypt/sha512.h> 136 166 WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*); 137 138 #if defined(WOLFSSL_SHA384)139 WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*);140 #endif /* defined(WOLFSSL_SHA384) */141 167 #endif /* WOLFSSL_SHA512 */ 142 168
Note:
See TracChangeset
for help on using the changeset viewer.