Merge pull request #4025 from danielinux/hdrbg_double_include_sha256

Fix double include of sha256.h causing a build error
This commit is contained in:
David Garske
2021-05-13 09:15:51 -07:00
committed by GitHub
5 changed files with 26 additions and 53 deletions

View File

@@ -19,24 +19,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#ifdef NO_INLINE
#include <wolfssl/wolfcrypt/misc.h>
#else
#define WOLFSSL_MISC_INCLUDED
#include <wolfcrypt/src/misc.c>
#endif
#ifdef WOLFSSL_IMXRT_DCP
#include <wolfssl/wolfcrypt/aes.h>
#include <wolfssl/wolfcrypt/sha.h>
#include <wolfssl/wolfcrypt/sha256.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#ifdef WOLFSSL_IMXRT_DCP
#if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) && defined(DCP_USE_DCACHE) && (DCP_USE_DCACHE == 1U)
#error "DCACHE not supported by this driver. Please undefine DCP_USE_DCACHE."
#endif
@@ -45,8 +40,6 @@
#define DCP_USE_OTP_KEY 0 /* Set to 1 to select OTP key for AES encryption/decryption. */
#endif
#include "fsl_device_registers.h"
#include "fsl_debug_console.h"
#include "fsl_dcp.h"
#ifndef SINGLE_THREADED
@@ -448,11 +441,6 @@ int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId)
return ret;
}
int wc_InitSha(wc_Sha* sha)
{
return wc_InitSha_ex(sha, NULL, INVALID_DEVID);
}
void DCPShaFree(wc_Sha* sha)
{
if (sha)

View File

@@ -330,6 +330,7 @@
/* implemented in wolfcrypt/src/port/Renesas/renesas_tsip_sha.c */
#elif defined(WOLFSSL_IMXRT_DCP)
#include <wolfssl/wolfcrypt/port/nxp/dcp_port.h>
/* implemented in wolfcrypt/src/port/nxp/dcp_port.c */
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
@@ -793,13 +794,10 @@ int wc_ShaTransform(wc_Sha* sha, const unsigned char* data)
#endif /* USE_SHA_SOFTWARE_IMPL */
#if !defined(WOLFSSL_IMXRT_DCP)
int wc_InitSha(wc_Sha* sha)
{
return wc_InitSha_ex(sha, NULL, INVALID_DEVID);
}
#endif /* !defined(WOLFSSL_IMXRT_DCP) */
void wc_ShaFree(wc_Sha* sha)
{

View File

@@ -22,23 +22,22 @@
#define _DCP_PORT_H_
#include <wolfssl/wolfcrypt/settings.h>
#ifdef USE_FAST_MATH
#include <wolfssl/wolfcrypt/tfm.h>
#elif defined WOLFSSL_SP_MATH
#include <wolfssl/wolfcrypt/sp_int.h>
#else
#include <wolfssl/wolfcrypt/integer.h>
#include "fsl_dcp.h"
#ifndef NO_SHA256
#include <wolfssl/wolfcrypt/sha256.h>
void DCPSha256Free(wc_Sha256 *sha256);
#endif
#include <wolfssl/wolfcrypt/aes.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include "fsl_device_registers.h"
#include "fsl_debug_console.h"
#include "fsl_dcp.h"
#ifndef NO_SHA
#include <wolfssl/wolfcrypt/sha.h>
void DCPShaFree(wc_Sha *sha);
#endif
int wc_dcp_init(void);
#ifndef NO_AES
#include <wolfssl/wolfcrypt/aes.h>
int DCPAesInit(Aes* aes);
void DCPAesFree(Aes *aes);
@@ -53,25 +52,5 @@ int DCPAesEcbEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
int DCPAesEcbDecrypt(Aes* aes, byte* out, const byte* in, word32 sz);
#endif
#ifndef NO_SHA256
typedef struct wc_Sha256_DCP {
dcp_handle_t handle;
dcp_hash_ctx_t ctx;
} wc_Sha256;
#define WC_SHA256_TYPE_DEFINED
void DCPSha256Free(wc_Sha256 *sha256);
#endif
#ifndef NO_SHA
typedef struct wc_Sha_DCP {
dcp_handle_t handle;
dcp_hash_ctx_t ctx;
} wc_Sha;
#define WC_SHA_TYPE_DEFINED
void DCPShaFree(wc_Sha *sha);
#endif
#endif

View File

@@ -52,6 +52,10 @@
#include "fsl_ltc.h"
#endif
#ifdef WOLFSSL_IMXRT_DCP
#include "fsl_dcp.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
@@ -72,9 +76,6 @@
#ifdef WOLFSSL_ESP32WROOM32_CRYPT
#include <wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h>
#endif
#ifdef WOLFSSL_IMXRT_DCP
#include <wolfssl/wolfcrypt/port/nxp/dcp_port.h>
#endif
#if defined(WOLFSSL_SILABS_SE_ACCEL)
#include <wolfssl/wolfcrypt/port/silabs/silabs_hash.h>
#endif
@@ -119,6 +120,9 @@ struct wc_Sha {
STM32_HASH_Context stmCtx;
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
wc_silabs_sha_t silabsCtx;
#elif defined(WOLFSSL_IMXRT_DCP)
dcp_handle_t handle;
dcp_hash_ctx_t ctx;
#else
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */

View File

@@ -61,6 +61,9 @@
#include "fsl_ltc.h"
#endif
#ifdef WOLFSSL_IMXRT_DCP
#include "fsl_dcp.h"
#endif
#ifdef __cplusplus
extern "C" {
@@ -131,8 +134,6 @@ enum {
#include "wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h"
#elif defined(WOLFSSL_PSOC6_CRYPTO)
#include "wolfssl/wolfcrypt/port/cypress/psoc6_crypto.h"
#elif defined(WOLFSSL_IMXRT_DCP)
#include <wolfssl/wolfcrypt/port/nxp/dcp_port.h>
#else
/* wc_Sha256 digest */
@@ -143,6 +144,9 @@ struct wc_Sha256 {
STM32_HASH_Context stmCtx;
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
wc_silabs_sha_t silabsCtx;
#elif defined(WOLFSSL_IMXRT_DCP)
dcp_handle_t handle;
dcp_hash_ctx_t ctx;
#else
/* alignment on digest and buffer speeds up ARMv8 crypto operations */
ALIGN16 word32 digest[WC_SHA256_DIGEST_SIZE / sizeof(word32)];