28 #ifndef WOLF_CRYPT_SHA256_H 29 #define WOLF_CRYPT_SHA256_H 35 #if defined(HAVE_FIPS) && \ 36 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 37 #include <wolfssl/wolfcrypt/fips.h> 40 #if defined(HAVE_FIPS) && \ 41 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 42 #define wc_Sha256 Sha256 43 #define WC_SHA256 SHA256 44 #define WC_SHA256_BLOCK_SIZE SHA256_BLOCK_SIZE 45 #define WC_SHA256_DIGEST_SIZE SHA256_DIGEST_SIZE 46 #define WC_SHA256_PAD_SIZE SHA256_PAD_SIZE 49 #define wc_Sha224 Sha224 50 #define WC_SHA224 SHA224 51 #define WC_SHA224_BLOCK_SIZE SHA224_BLOCK_SIZE 52 #define WC_SHA224_DIGEST_SIZE SHA224_DIGEST_SIZE 53 #define WC_SHA224_PAD_SIZE SHA224_PAD_SIZE 57 #include <cyassl/ctaocrypt/sha256.h> 60 #ifdef FREESCALE_LTC_SHA 70 #if !defined(HAVE_FIPS) || \ 71 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 73 #ifdef WOLFSSL_MICROCHIP_PIC32MZ 74 #include <wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h> 77 #include <wolfssl/wolfcrypt/port/st/stm32.h> 79 #ifdef WOLFSSL_ASYNC_CRYPT 80 #include <wolfssl/wolfcrypt/async.h> 82 #if defined(WOLFSSL_DEVCRYPTO) && defined(WOLFSSL_DEVCRYPTO_HASH) 83 #include <wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h> 85 #if defined(WOLFSSL_ESP32WROOM32_CRYPT) 86 #include "wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h" 88 #if defined(WOLFSSL_CRYPTOCELL) 89 #include <wolfssl/wolfcrypt/port/arm/cryptoCell.h> 93 #define SHA256_NOINLINE __declspec(noinline) 94 #elif defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) 95 #define SHA256_NOINLINE __attribute__((noinline)) 97 #define SHA256_NOINLINE 100 #if !defined(NO_OLD_SHA_NAMES) 101 #define SHA256 WC_SHA256 104 #ifndef NO_OLD_WC_NAMES 105 #define Sha256 wc_Sha256 106 #define SHA256_BLOCK_SIZE WC_SHA256_BLOCK_SIZE 107 #define SHA256_DIGEST_SIZE WC_SHA256_DIGEST_SIZE 108 #define SHA256_PAD_SIZE WC_SHA256_PAD_SIZE 113 WC_SHA256 = WC_HASH_TYPE_SHA256,
114 WC_SHA256_BLOCK_SIZE = 64,
115 WC_SHA256_DIGEST_SIZE = 32,
116 WC_SHA256_PAD_SIZE = 56
120 #ifdef WOLFSSL_TI_HASH 121 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h" 122 #elif defined(WOLFSSL_IMX6_CAAM) 123 #include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h" 124 #elif defined(WOLFSSL_AFALG_HASH) 125 #include "wolfssl/wolfcrypt/port/af_alg/afalg_hash.h" 126 #elif defined(WOLFSSL_RENESAS_TSIP_CRYPT) && \ 127 !defined(NO_WOLFSSL_RENESAS_TSIP_CRYPT_HASH) 128 #include "wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h" 133 #ifdef FREESCALE_LTC_SHA 135 #elif defined(STM32_HASH_SHA2) 139 ALIGN16 word32 digest[WC_SHA256_DIGEST_SIZE /
sizeof(word32)];
140 ALIGN16 word32 buffer[WC_SHA256_BLOCK_SIZE /
sizeof(word32)];
145 #ifdef WOLFSSL_PIC32MZ_HASH 148 #ifdef WOLFSSL_ASYNC_CRYPT 149 WC_ASYNC_DEV asyncDev;
151 #ifdef WOLFSSL_SMALL_STACK_CACHE 154 #ifdef WOLFSSL_DEVCRYPTO_HASH 160 #if defined(WOLFSSL_ESP32WROOM32_CRYPT) && \ 161 !defined(NO_WOLFSSL_ESP32WROOM32_CRYPT_HASH) 164 #ifdef WOLFSSL_CRYPTOCELL 165 CRYS_HASHUserContext_t ctx;
167 #ifdef WOLF_CRYPTO_CB 172 #if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) 177 #ifndef WC_SHA256_TYPE_DEFINED 179 #define WC_SHA256_TYPE_DEFINED 187 WOLFSSL_API
int wc_InitSha256_ex(
wc_Sha256*,
void*,
int);
189 WOLFSSL_API
int wc_Sha256FinalRaw(
wc_Sha256*, byte*);
196 #ifdef WOLFSSL_PIC32MZ_HASH 197 WOLFSSL_API
void wc_Sha256SizeSet(
wc_Sha256*, word32);
200 #if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) 201 WOLFSSL_API
int wc_Sha256SetFlags(
wc_Sha256* sha256, word32 flags);
202 WOLFSSL_API
int wc_Sha256GetFlags(
wc_Sha256* sha256, word32* flags);
205 #ifdef WOLFSSL_SHA224 207 #if !defined(HAVE_FIPS) || \ 208 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 210 #ifndef NO_OLD_WC_NAMES 211 #define Sha224 wc_Sha224 212 #define SHA224 WC_SHA224 213 #define SHA224_BLOCK_SIZE WC_SHA224_BLOCK_SIZE 214 #define SHA224_DIGEST_SIZE WC_SHA224_DIGEST_SIZE 215 #define SHA224_PAD_SIZE WC_SHA224_PAD_SIZE 220 WC_SHA224 = WC_HASH_TYPE_SHA224,
221 WC_SHA224_BLOCK_SIZE = WC_SHA256_BLOCK_SIZE,
222 WC_SHA224_DIGEST_SIZE = 28,
223 WC_SHA224_PAD_SIZE = WC_SHA256_PAD_SIZE
227 #ifndef WC_SHA224_TYPE_DEFINED 229 #define WC_SHA224_TYPE_DEFINED 234 WOLFSSL_API
int wc_InitSha224_ex(
wc_Sha224*,
void*,
int);
237 WOLFSSL_API
void wc_Sha224Free(
wc_Sha224*);
239 WOLFSSL_API
int wc_Sha224GetHash(
wc_Sha224*, byte*);
242 #if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) 243 WOLFSSL_API
int wc_Sha224SetFlags(
wc_Sha224* sha224, word32 flags);
244 WOLFSSL_API
int wc_Sha224GetFlags(
wc_Sha224* sha224, word32* flags);
Definition: wc_devcrypto.h:35
WOLFSSL_API void wc_Sha256Free(wc_Sha256 *)
Resets the Sha256 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined...
Definition: sha256.c:1448
WOLFSSL_API int wc_InitSha256(wc_Sha256 *)
This function initializes SHA256. This is automatically called by wc_Sha256Hash.
Definition: sha256.c:1443
WOLFSSL_API int wc_Sha256Update(wc_Sha256 *, const byte *, word32)
Can be called to continually hash the provided byte array of length len.
Definition: sha256.c:501
Definition: pic32mz-crypt.h:115
WOLFSSL_API int wc_InitSha224(wc_Sha224 *)
Used to initialize a Sha224 struct.
Definition: armv8-sha256.c:1419
Definition: esp32-crypt.h:104
WOLFSSL_API int wc_Sha256GetHash(wc_Sha256 *, byte *)
Gets hash data. Result is placed into hash. Does not reset state of sha256 struct.
Definition: afalg_hash.c:255
WOLFSSL_API int wc_Sha224Final(wc_Sha224 *, byte *)
Finalizes hashing of data. Result is placed into hash. Resets state of sha224 struct.
Definition: sha256.c:1385
WOLFSSL_API int wc_Sha256Final(wc_Sha256 *, byte *)
Finalizes hashing of data. Result is placed into hash. Resets state of sha256 struct.
Definition: sha256.c:518
WOLFSSL_API int wc_Sha224Update(wc_Sha224 *, const byte *, word32)
Can be called to continually hash the provided byte array of length len.
Definition: sha256.c:1364