26#ifndef WOLF_CRYPT_HASH_H
27#define WOLF_CRYPT_HASH_H
37#if defined(WOLFSSL_SHA224) || !defined(NO_SHA256)
40#if defined(WOLFSSL_SHA384) || defined(WOLFSSL_SHA512)
47 #include <wolfssl/wolfcrypt/sha3.h>
55#if defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S)
64#if !defined(HAVE_FIPS) && !defined(NO_OLD_WC_NAMES)
65 #define MAX_DIGEST_SIZE WC_MAX_DIGEST_SIZE
83 WC_HASH_FLAG_NONE = 0x00000000,
84 WC_HASH_FLAG_WILLCOPY = 0x00000001,
85 WC_HASH_FLAG_ISCOPY = 0x00000002,
87 WC_HASH_SHA3_KECCAK256 =0x00010000,
105 #ifdef WOLFSSL_SHA384
108 #ifdef WOLFSSL_SHA512
118#if defined(WOLFSSL_SHA3)
119 #define WC_MAX_DIGEST_SIZE WC_SHA3_512_DIGEST_SIZE
120 #define WC_MAX_BLOCK_SIZE WC_SHA3_224_BLOCK_SIZE
121#elif defined(WOLFSSL_SHA512)
122 #define WC_MAX_DIGEST_SIZE WC_SHA512_DIGEST_SIZE
123 #define WC_MAX_BLOCK_SIZE WC_SHA512_BLOCK_SIZE
124#elif defined(HAVE_BLAKE2)
125 #define WC_MAX_DIGEST_SIZE BLAKE2B_OUTBYTES
126 #define WC_MAX_BLOCK_SIZE BLAKE2B_BLOCKBYTES
127#elif defined(WOLFSSL_SHA384)
128 #define WC_MAX_DIGEST_SIZE WC_SHA384_DIGEST_SIZE
129 #define WC_MAX_BLOCK_SIZE WC_SHA384_BLOCK_SIZE
130#elif !defined(NO_SHA256)
131 #define WC_MAX_DIGEST_SIZE WC_SHA256_DIGEST_SIZE
132 #define WC_MAX_BLOCK_SIZE WC_SHA256_BLOCK_SIZE
133#elif defined(WOLFSSL_SHA224)
134 #define WC_MAX_DIGEST_SIZE WC_SHA224_DIGEST_SIZE
135 #define WC_MAX_BLOCK_SIZE WC_SHA224_BLOCK_SIZE
136#elif !defined(NO_SHA)
137 #define WC_MAX_DIGEST_SIZE WC_SHA_DIGEST_SIZE
138 #define WC_MAX_BLOCK_SIZE WC_SHA_BLOCK_SIZE
139#elif !defined(NO_MD5)
140 #define WC_MAX_DIGEST_SIZE WC_MD5_DIGEST_SIZE
141 #define WC_MAX_BLOCK_SIZE WC_MD5_BLOCK_SIZE
143 #define WC_MAX_DIGEST_SIZE 64
144 #define WC_MAX_BLOCK_SIZE 128
147#if !defined(NO_ASN) || !defined(NO_DH) || defined(HAVE_ECC)
149WOLFSSL_API
enum wc_HashType wc_OidGetHash(
int oid);
152WOLFSSL_API
enum wc_HashType wc_HashTypeConvert(
int hashType);
155WOLFSSL_API
int wc_HashGetBlockSize(
enum wc_HashType hash_type);
156WOLFSSL_API
int wc_Hash(
enum wc_HashType hash_type,
157 const byte* data, word32 data_len,
158 byte* hash, word32 hash_len);
161WOLFSSL_API
int wc_HashInit_ex(
wc_HashAlg* hash,
enum wc_HashType type,
162 void* heap,
int devId);
163WOLFSSL_API
int wc_HashInit(
wc_HashAlg* hash,
enum wc_HashType type);
164WOLFSSL_API
int wc_HashUpdate(
wc_HashAlg* hash,
enum wc_HashType type,
165 const byte* data, word32 dataSz);
166WOLFSSL_API
int wc_HashFinal(
wc_HashAlg* hash,
enum wc_HashType type,
168WOLFSSL_API
int wc_HashFree(
wc_HashAlg* hash,
enum wc_HashType type);
170#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)
171 WOLFSSL_API
int wc_HashSetFlags(
wc_HashAlg* hash,
enum wc_HashType type,
173 WOLFSSL_API
int wc_HashGetFlags(
wc_HashAlg* hash,
enum wc_HashType type,
179WOLFSSL_API
int wc_Md5Hash(
const byte* data, word32 len,
byte* hash);
184WOLFSSL_API
int wc_ShaHash(
const byte*, word32,
byte*);
208#include <wolfssl/wolfcrypt/sha3.h>
209WOLFSSL_API
int wc_Sha3_224Hash(
const byte*, word32,
byte*);
210WOLFSSL_API
int wc_Sha3_256Hash(
const byte*, word32,
byte*);
211WOLFSSL_API
int wc_Sha3_384Hash(
const byte*, word32,
byte*);
212WOLFSSL_API
int wc_Sha3_512Hash(
const byte*, word32,
byte*);
213#ifdef WOLFSSL_SHAKE256
214WOLFSSL_API
int wc_Shake256Hash(
const byte*, word32,
byte*, word32);
219#ifdef HAVE_FFDHE_8192
221#elif defined(HAVE_FFDHE_6144)
226 MAX_PRF_LABSEED = 128,
230#ifdef WOLFSSL_HAVE_PRF
231WOLFSSL_API
int wc_PRF(
byte* result, word32 resLen,
const byte* secret,
232 word32 secLen,
const byte* seed, word32 seedLen,
int hash,
233 void* heap,
int devId);
234WOLFSSL_API
int wc_PRF_TLSv1(
byte* digest, word32 digLen,
const byte* secret,
235 word32 secLen,
const byte* label, word32 labLen,
236 const byte* seed, word32 seedLen,
void* heap,
int devId);
237WOLFSSL_API
int wc_PRF_TLS(
byte* digest, word32 digLen,
const byte* secret,
238 word32 secLen,
const byte* label, word32 labLen,
239 const byte* seed, word32 seedLen,
int useAtLeastSha256,
240 int hash_type,
void* heap,
int devId);
WOLFSSL_API int wc_Md5Hash(const byte *data, word32 len, byte *hash)
Convenience function, handles all the hashing and places the result into hash.
Definition hash.c:984
WOLFSSL_API int wc_ShaHash(const byte *, word32, byte *)
Convenience function, handles all the hashing and places the result into hash.
Definition hash.c:1021
WOLFSSL_API int wc_Sha224Hash(const byte *, word32, byte *)
Convenience function, handles all the hashing and places the result into hash.
Definition hash.c:1058
WOLFSSL_API int wc_Sha384Hash(const byte *, word32, byte *)
Convenience function, handles all the hashing and places the result into hash.
Definition hash.c:1176
WOLFSSL_API int wc_Sha256Hash(const byte *, word32, byte *)
Convenience function, handles all the hashing and places the result into hash.
Definition hash.c:1096
WOLFSSL_API int wc_Sha512Hash(const byte *, word32, byte *)
Convenience function, handles all the hashing and places the result into hash.
Definition hash.c:1138
WOLFSSL_API int wc_HashGetOID(enum wc_HashType hash_type)
This function will return the OID for the wc_HashType provided.
Definition hash.c:134
WOLFSSL_API int wc_Hash(enum wc_HashType hash_type, const byte *data, word32 data_len, byte *hash, word32 hash_len)
This function performs a hash on the provided data buffer and returns it in the hash buffer provided.
Definition hash.c:449
WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type)
This function returns the size of the digest (output) for a hash_type. The returns size is used to ma...
Definition hash.c:272
Definition wolfcaam_sha.h:68
Definition afalg_hash.h:31