summaryrefslogtreecommitdiff
path: root/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha.h
diff options
context:
space:
mode:
Diffstat (limited to 'FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha.h')
-rw-r--r--FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha.h157
1 files changed, 124 insertions, 33 deletions
diff --git a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha.h b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha.h
index 80a2c9832..0b7f65404 100644
--- a/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha.h
+++ b/FreeRTOS-Plus/Source/WolfSSL/wolfssl/wolfcrypt/sha.h
@@ -1,8 +1,8 @@
/* sha.h
*
- * Copyright (C) 2006-2015 wolfSSL Inc.
+ * Copyright (C) 2006-2020 wolfSSL Inc.
*
- * This file is part of wolfSSL. (formerly known as CyaSSL)
+ * This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,9 +16,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
+/*!
+ \file wolfssl/wolfcrypt/sha.h
+*/
+
+
#ifndef WOLF_CRYPT_SHA_H
#define WOLF_CRYPT_SHA_H
@@ -26,57 +31,143 @@
#ifndef NO_SHA
-#ifdef HAVE_FIPS
+#if defined(HAVE_FIPS) && \
+ defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
+ #include <wolfssl/wolfcrypt/fips.h>
+#endif /* HAVE_FIPS_VERSION >= 2 */
+
+#if defined(HAVE_FIPS) && \
+ (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
+#define wc_Sha Sha
+#define WC_SHA SHA
+#define WC_SHA_BLOCK_SIZE SHA_BLOCK_SIZE
+#define WC_SHA_DIGEST_SIZE SHA_DIGEST_SIZE
+#define WC_SHA_PAD_SIZE SHA_PAD_SIZE
+
/* for fips @wc_fips */
#include <cyassl/ctaocrypt/sha.h>
#endif
+#ifdef FREESCALE_LTC_SHA
+ #include "fsl_ltc.h"
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef HAVE_FIPS /* avoid redefining structs */
+/* avoid redefinition of structs */
+#if !defined(HAVE_FIPS) || \
+ (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
+
+#ifdef WOLFSSL_MICROCHIP_PIC32MZ
+ #include <wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h>
+#endif
+#ifdef STM32_HASH
+ #include <wolfssl/wolfcrypt/port/st/stm32.h>
+#endif
+#ifdef WOLFSSL_ASYNC_CRYPT
+ #include <wolfssl/wolfcrypt/async.h>
+#endif
+#ifdef WOLFSSL_ESP32WROOM32_CRYPT
+ #include <wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h>
+#endif
+
+#if !defined(NO_OLD_SHA_NAMES)
+ #define SHA WC_SHA
+#endif
+
+#ifndef NO_OLD_WC_NAMES
+ #define Sha wc_Sha
+ #define SHA_BLOCK_SIZE WC_SHA_BLOCK_SIZE
+ #define SHA_DIGEST_SIZE WC_SHA_DIGEST_SIZE
+ #define SHA_PAD_SIZE WC_SHA_PAD_SIZE
+#endif
+
/* in bytes */
enum {
-#ifdef STM32F2_HASH
- SHA_REG_SIZE = 4, /* STM32 register size, bytes */
-#endif
- SHA = 1, /* hash type unique */
- SHA_BLOCK_SIZE = 64,
- SHA_DIGEST_SIZE = 20,
- SHA_PAD_SIZE = 56
+ WC_SHA = WC_HASH_TYPE_SHA,
+ WC_SHA_BLOCK_SIZE = 64,
+ WC_SHA_DIGEST_SIZE = 20,
+ WC_SHA_PAD_SIZE = 56
};
-#ifdef WOLFSSL_PIC32MZ_HASH
-#include "port/pic32/pic32mz-crypt.h"
-#endif
-#ifndef WOLFSSL_TI_HASH
-
+#if defined(WOLFSSL_TI_HASH)
+ #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
+
+#elif defined(WOLFSSL_IMX6_CAAM)
+ #include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h"
+#elif defined(WOLFSSL_RENESAS_TSIP_CRYPT) && \
+ !defined(NO_WOLFSSL_RENESAS_TSIP_CRYPT_HASH)
+ #include "wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h"
+#else
+
/* Sha digest */
-typedef struct Sha {
- word32 buffLen; /* in bytes */
- word32 loLen; /* length in bytes */
- word32 hiLen; /* length in bytes */
- word32 buffer[SHA_BLOCK_SIZE / sizeof(word32)];
- #ifndef WOLFSSL_PIC32MZ_HASH
- word32 digest[SHA_DIGEST_SIZE / sizeof(word32)];
+struct wc_Sha {
+#ifdef FREESCALE_LTC_SHA
+ ltc_hash_ctx_t ctx;
+#elif defined(STM32_HASH)
+ STM32_HASH_Context stmCtx;
+#else
+ word32 buffLen; /* in bytes */
+ word32 loLen; /* length in bytes */
+ word32 hiLen; /* length in bytes */
+ word32 buffer[WC_SHA_BLOCK_SIZE / sizeof(word32)];
+ #ifdef WOLFSSL_PIC32MZ_HASH
+ word32 digest[PIC32_DIGEST_SIZE / sizeof(word32)];
#else
- word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
- pic32mz_desc desc; /* Crypt Engine descripter */
+ word32 digest[WC_SHA_DIGEST_SIZE / sizeof(word32)];
+ #endif
+ void* heap;
+ #ifdef WOLFSSL_PIC32MZ_HASH
+ hashUpdCache cache; /* cache for updates */
+ #endif
+ #ifdef WOLFSSL_ASYNC_CRYPT
+ WC_ASYNC_DEV asyncDev;
+ #endif /* WOLFSSL_ASYNC_CRYPT */
+ #ifdef WOLF_CRYPTO_CB
+ int devId;
+ void* devCtx; /* generic crypto callback context */
#endif
-} Sha;
+#endif
+#if defined(WOLFSSL_ESP32WROOM32_CRYPT) && \
+ !defined(NO_WOLFSSL_ESP32WROOM32_CRYPT_HASH)
+ WC_ESP32SHA ctx;
+#endif
+#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)
+ word32 flags; /* enum wc_HashFlags in hash.h */
+#endif
+};
-#else /* WOLFSSL_TI_HASH */
- #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
+#ifndef WC_SHA_TYPE_DEFINED
+ typedef struct wc_Sha wc_Sha;
+ #define WC_SHA_TYPE_DEFINED
#endif
+#endif /* WOLFSSL_TI_HASH */
+
+
#endif /* HAVE_FIPS */
-WOLFSSL_API int wc_InitSha(Sha*);
-WOLFSSL_API int wc_ShaUpdate(Sha*, const byte*, word32);
-WOLFSSL_API int wc_ShaFinal(Sha*, byte*);
-WOLFSSL_API int wc_ShaHash(const byte*, word32, byte*);
+WOLFSSL_API int wc_InitSha(wc_Sha*);
+WOLFSSL_API int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId);
+WOLFSSL_API int wc_ShaUpdate(wc_Sha*, const byte*, word32);
+WOLFSSL_API int wc_ShaFinalRaw(wc_Sha*, byte*);
+WOLFSSL_API int wc_ShaFinal(wc_Sha*, byte*);
+WOLFSSL_API void wc_ShaFree(wc_Sha*);
+
+WOLFSSL_API int wc_ShaGetHash(wc_Sha*, byte*);
+WOLFSSL_API int wc_ShaCopy(wc_Sha*, wc_Sha*);
+
+#ifdef WOLFSSL_PIC32MZ_HASH
+WOLFSSL_API void wc_ShaSizeSet(wc_Sha* sha, word32 len);
+#endif
+
+#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB)
+ WOLFSSL_API int wc_ShaSetFlags(wc_Sha* sha, word32 flags);
+ WOLFSSL_API int wc_ShaGetFlags(wc_Sha* sha, word32* flags);
+#endif
#ifdef __cplusplus
} /* extern "C" */