Skip to content

Commit d7c6d7a

Browse files
committed
Fix the NXP MMCAU HW acceleration for SHA2-256. Broken with LMS SHA2 refactor.
1 parent d930825 commit d7c6d7a

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

wolfcrypt/src/sha256.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ on the specific device platform.
168168
#define HAVE_INTEL_RORX
169169
#endif
170170

171-
172-
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
171+
#if defined(LITTLE_ENDIAN_ORDER)
173172
#if ( defined(CONFIG_IDF_TARGET_ESP32C2) || \
174173
defined(CONFIG_IDF_TARGET_ESP8684) || \
175174
defined(CONFIG_IDF_TARGET_ESP32C3) || \
@@ -182,20 +181,24 @@ on the specific device platform.
182181
* depending on if HW is active or not. */
183182
#define SHA256_REV_BYTES(ctx) \
184183
(esp_sha_need_byte_reversal(ctx))
184+
#elif defined(FREESCALE_MMCAU_SHA)
185+
#define SHA256_REV_BYTES(ctx) 1 /* reverse needed on final */
185186
#endif
186187
#endif
187188
#ifndef SHA256_REV_BYTES
188-
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
189+
#if defined(LITTLE_ENDIAN_ORDER)
189190
#define SHA256_REV_BYTES(ctx) 1
190191
#else
191192
#define SHA256_REV_BYTES(ctx) 0
192193
#endif
193194
#endif
194-
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA) && \
195+
#if defined(LITTLE_ENDIAN_ORDER) && \
195196
defined(WOLFSSL_X86_64_BUILD) && defined(USE_INTEL_SPEEDUP) && \
196197
(defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2))
197198
#define SHA256_UPDATE_REV_BYTES(ctx) \
198199
(!IS_INTEL_AVX1(intel_flags) && !IS_INTEL_AVX2(intel_flags))
200+
#elif defined(FREESCALE_MMCAU_SHA)
201+
#define SHA256_UPDATE_REV_BYTES(ctx) 0 /* reverse not needed on update */
199202
#else
200203
#define SHA256_UPDATE_REV_BYTES(ctx) SHA256_REV_BYTES(ctx)
201204
#endif

0 commit comments

Comments
 (0)