@@ -1073,11 +1073,16 @@ static int InitSha256(wc_Sha256* sha256)
10731073 (defined(HAVE_INTEL_AVX1 ) || defined(HAVE_INTEL_AVX2 ))
10741074 if (!IS_INTEL_AVX1 (intel_flags ) && !IS_INTEL_AVX2 (intel_flags ))
10751075 #endif
1076- #if (defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1077- defined(CONFIG_IDF_TARGET_ESP32C6 )) && \
1078- defined(WOLFSSL_ESP32_CRYPT ) && \
1076+ #if ( defined(CONFIG_IDF_TARGET_ESP32C2 ) || \
1077+ defined(CONFIG_IDF_TARGET_ESP8684 ) || \
1078+ defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1079+ defined(CONFIG_IDF_TARGET_ESP32C6 ) \
1080+ ) && \
1081+ defined(WOLFSSL_ESP32_CRYPT ) && \
10791082 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH ) && \
10801083 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 )
1084+ /* For Espressif RISC-V Targets, we *may* need to reverse bytes
1085+ * depending on if HW is active or not. */
10811086 if (esp_sha_need_byte_reversal (& sha256 -> ctx ))
10821087 #endif
10831088 {
@@ -1179,11 +1184,16 @@ static int InitSha256(wc_Sha256* sha256)
11791184 #endif
11801185
11811186 #if defined(LITTLE_ENDIAN_ORDER ) && !defined(FREESCALE_MMCAU_SHA )
1182- #if (defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1183- defined(CONFIG_IDF_TARGET_ESP32C6 )) && \
1184- defined(WOLFSSL_ESP32_CRYPT ) && \
1187+ #if ( defined(CONFIG_IDF_TARGET_ESP32C2 ) || \
1188+ defined(CONFIG_IDF_TARGET_ESP8684 ) || \
1189+ defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1190+ defined(CONFIG_IDF_TARGET_ESP32C6 ) \
1191+ ) && \
1192+ defined(WOLFSSL_ESP32_CRYPT ) && \
11851193 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH ) && \
11861194 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 )
1195+ /* For Espressif RISC-V Targets, we *may* need to reverse bytes
1196+ * depending on if HW is active or not. */
11871197 if (esp_sha_need_byte_reversal (& sha256 -> ctx ))
11881198 #endif
11891199 #if defined(WOLFSSL_X86_64_BUILD ) && \
@@ -1297,11 +1307,16 @@ static int InitSha256(wc_Sha256* sha256)
12971307 #endif
12981308
12991309 #if defined(LITTLE_ENDIAN_ORDER ) && !defined(FREESCALE_MMCAU_SHA )
1300- #if (defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1301- defined(CONFIG_IDF_TARGET_ESP32C6 )) && \
1302- defined(WOLFSSL_ESP32_CRYPT ) && \
1310+ #if ( defined(CONFIG_IDF_TARGET_ESP32C2 ) || \
1311+ defined(CONFIG_IDF_TARGET_ESP8684 ) || \
1312+ defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1313+ defined(CONFIG_IDF_TARGET_ESP32C6 ) \
1314+ ) && \
1315+ defined(WOLFSSL_ESP32_CRYPT ) && \
13031316 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH ) && \
13041317 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 )
1318+ /* For Espressif RISC-V Targets, we *may* need to reverse bytes
1319+ * depending on if HW is active or not. */
13051320 if (esp_sha_need_byte_reversal (& sha256 -> ctx ))
13061321 #endif
13071322 #if defined(WOLFSSL_X86_64_BUILD ) && defined(USE_INTEL_SPEEDUP ) && \
@@ -1350,11 +1365,16 @@ static int InitSha256(wc_Sha256* sha256)
13501365
13511366 /* store lengths */
13521367 #if defined(LITTLE_ENDIAN_ORDER ) && !defined(FREESCALE_MMCAU_SHA )
1353- #if (defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1354- defined(CONFIG_IDF_TARGET_ESP32C6 )) && \
1355- defined(WOLFSSL_ESP32_CRYPT ) && \
1368+ #if ( defined(CONFIG_IDF_TARGET_ESP32C2 ) || \
1369+ defined(CONFIG_IDF_TARGET_ESP8684 ) || \
1370+ defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1371+ defined(CONFIG_IDF_TARGET_ESP32C6 ) \
1372+ ) && \
1373+ defined(WOLFSSL_ESP32_CRYPT ) && \
13561374 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH ) && \
13571375 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 )
1376+ /* For Espressif RISC-V Targets, we *may* need to reverse bytes
1377+ * depending on if HW is active or not. */
13581378 if (esp_sha_need_byte_reversal (& sha256 -> ctx ))
13591379 #endif
13601380 #if defined(WOLFSSL_X86_64_BUILD ) && defined(USE_INTEL_SPEEDUP ) && \
@@ -1373,11 +1393,16 @@ static int InitSha256(wc_Sha256* sha256)
13731393
13741394 /* Only the ESP32-C3 with HW enabled may need pad size byte order reversal
13751395 * depending on HW or SW mode */
1376- #if (defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1377- defined(CONFIG_IDF_TARGET_ESP32C6 )) && \
1378- defined(WOLFSSL_ESP32_CRYPT ) && \
1396+ #if ( defined(CONFIG_IDF_TARGET_ESP32C2 ) || \
1397+ defined(CONFIG_IDF_TARGET_ESP8684 ) || \
1398+ defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1399+ defined(CONFIG_IDF_TARGET_ESP32C6 ) \
1400+ ) && \
1401+ defined(WOLFSSL_ESP32_CRYPT ) && \
13791402 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH ) && \
13801403 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 )
1404+ /* For Espressif RISC-V Targets, we *may* need to reverse bytes
1405+ * depending on if HW is active or not. */
13811406 if (sha256 -> ctx .mode == ESP32_SHA_HW ) {
13821407 #if defined(WOLFSSL_SUPER_VERBOSE_DEBUG )
13831408 ESP_LOGV (TAG , "Start: Reverse PAD SIZE Endianness." );
@@ -1442,11 +1467,16 @@ static int InitSha256(wc_Sha256* sha256)
14421467 }
14431468
14441469 #ifdef LITTLE_ENDIAN_ORDER
1445- #if (defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1446- defined(CONFIG_IDF_TARGET_ESP32C6 )) && \
1447- defined(WOLFSSL_ESP32_CRYPT ) && \
1470+ #if ( defined(CONFIG_IDF_TARGET_ESP32C2 ) || \
1471+ defined(CONFIG_IDF_TARGET_ESP8684 ) || \
1472+ defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1473+ defined(CONFIG_IDF_TARGET_ESP32C6 ) \
1474+ ) && \
1475+ defined(WOLFSSL_ESP32_CRYPT ) && \
14481476 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH ) && \
14491477 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 )
1478+ /* For Espressif RISC-V Targets, we *may* need to reverse bytes
1479+ * depending on if HW is active or not. */
14501480 if (esp_sha_need_byte_reversal (& sha256 -> ctx ))
14511481 #endif
14521482 {
@@ -1497,10 +1527,16 @@ static int InitSha256(wc_Sha256* sha256)
14971527 }
14981528
14991529 #if defined(LITTLE_ENDIAN_ORDER )
1500- #if (defined(CONFIG_IDF_TARGET_ESP32C3 ) || defined(CONFIG_IDF_TARGET_ESP32C6 )) && \
1501- defined(WOLFSSL_ESP32_CRYPT ) && \
1530+ #if ( defined(CONFIG_IDF_TARGET_ESP32C2 ) || \
1531+ defined(CONFIG_IDF_TARGET_ESP8684 ) || \
1532+ defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1533+ defined(CONFIG_IDF_TARGET_ESP32C6 ) \
1534+ ) && \
1535+ defined(WOLFSSL_ESP32_CRYPT ) && \
15021536 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH ) && \
15031537 !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 )
1538+ /* For Espressif RISC-V Targets, we *may* need to reverse bytes
1539+ * depending on if HW is active or not. */
15041540 if (esp_sha_need_byte_reversal (& sha256 -> ctx ))
15051541 #endif
15061542 {
@@ -1792,23 +1828,27 @@ static int InitSha256(wc_Sha256* sha256)
17921828 }
17931829 #endif /* WOLFSSL_ASYNC_CRYPT */
17941830
1795- #if defined(WOLFSSL_USE_ESP32_CRYPT_HASH_HW ) && \
1796- (!defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 ) || \
1797- !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA224 ))
1831+ #if defined(WOLFSSL_USE_ESP32_CRYPT_HASH_HW ) && \
1832+ ( !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 ) || \
1833+ !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA224 ) )
17981834
1799- /* nothing enabled here for C3 success */
1835+ /* nothing enabled here for RISC-V C2/C3/C6 success */
18001836 #endif
18011837
18021838 ret = Sha256Final ((wc_Sha256 * )sha224 );
18031839 if (ret != 0 )
18041840 return ret ;
18051841
18061842 #if defined(LITTLE_ENDIAN_ORDER )
1807- #if (defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1808- defined(CONFIG_IDF_TARGET_ESP32C6 )) && \
1843+ #if ( defined(CONFIG_IDF_TARGET_ESP32C2 ) || \
1844+ defined(CONFIG_IDF_TARGET_ESP8684 ) || \
1845+ defined(CONFIG_IDF_TARGET_ESP32C3 ) || \
1846+ defined(CONFIG_IDF_TARGET_ESP32C6 ) \
1847+ ) && \
18091848 defined(WOLFSSL_ESP32_CRYPT ) && \
1810- (!defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 ) || \
1811- !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA224 ))
1849+ (!defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 ) || \
1850+ !defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA224 ) \
1851+ )
18121852 if (esp_sha_need_byte_reversal (& sha224 -> ctx ))
18131853 #endif
18141854 {
0 commit comments