Skip to content

Commit

Permalink
Merge pull request #7389 from dgarske/nxp_mmcau_sha256
Browse files Browse the repository at this point in the history
Fix the NXP MMCAU HW acceleration for SHA2-256
  • Loading branch information
JacobBarthelmeh authored Apr 3, 2024
2 parents c768f76 + d7c6d7a commit f6a24ef
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions wolfcrypt/src/sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ on the specific device platform.
#define HAVE_INTEL_RORX
#endif


#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
#if defined(LITTLE_ENDIAN_ORDER)
#if ( defined(CONFIG_IDF_TARGET_ESP32C2) || \
defined(CONFIG_IDF_TARGET_ESP8684) || \
defined(CONFIG_IDF_TARGET_ESP32C3) || \
Expand All @@ -182,20 +181,24 @@ on the specific device platform.
* depending on if HW is active or not. */
#define SHA256_REV_BYTES(ctx) \
(esp_sha_need_byte_reversal(ctx))
#elif defined(FREESCALE_MMCAU_SHA)
#define SHA256_REV_BYTES(ctx) 1 /* reverse needed on final */
#endif
#endif
#ifndef SHA256_REV_BYTES
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
#if defined(LITTLE_ENDIAN_ORDER)
#define SHA256_REV_BYTES(ctx) 1
#else
#define SHA256_REV_BYTES(ctx) 0
#endif
#endif
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA) && \
#if defined(LITTLE_ENDIAN_ORDER) && \
defined(WOLFSSL_X86_64_BUILD) && defined(USE_INTEL_SPEEDUP) && \
(defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2))
#define SHA256_UPDATE_REV_BYTES(ctx) \
(!IS_INTEL_AVX1(intel_flags) && !IS_INTEL_AVX2(intel_flags))
#elif defined(FREESCALE_MMCAU_SHA)
#define SHA256_UPDATE_REV_BYTES(ctx) 0 /* reverse not needed on update */
#else
#define SHA256_UPDATE_REV_BYTES(ctx) SHA256_REV_BYTES(ctx)
#endif
Expand Down

0 comments on commit f6a24ef

Please sign in to comment.