@@ -60,6 +60,10 @@ on the specific device platform.
6060
6161#if !defined(NO_SHA256 ) && !defined(WOLFSSL_RISCV_ASM )
6262
63+ #if defined(WOLF_CRYPTO_CB_ONLY_SHA256 ) && defined(WOLFSSL_SHA224 )
64+ #error "WOLF_CRYPTO_CB_ONLY_SHA256 is incompatible with WOLFSSL_SHA224"
65+ #endif
66+
6367#if defined(HAVE_FIPS ) && defined(HAVE_FIPS_VERSION ) && (HAVE_FIPS_VERSION >= 2 )
6468 /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
6569 #define FIPS_NO_WRAPPERS
@@ -1205,6 +1209,7 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
12051209
12061210#ifdef NEED_SOFT_SHA256
12071211
1212+ #ifndef WOLF_CRYPTO_CB_ONLY_SHA256
12081213 static const FLASH_QUALIFIER ALIGN32 word32 K [64 ] = {
12091214 0x428A2F98L , 0x71374491L , 0xB5C0FBCFL , 0xE9B5DBA5L , 0x3956C25BL ,
12101215 0x59F111F1L , 0x923F82A4L , 0xAB1C5ED5L , 0xD807AA98L , 0x12835B01L ,
@@ -1580,6 +1585,7 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
15801585
15811586 return ret ;
15821587 }
1588+ #endif /* !WOLF_CRYPTO_CB_ONLY_SHA256 */
15831589
15841590#if defined(WOLFSSL_KCAPI_HASH )
15851591 /* implemented in wolfcrypt/src/port/kcapi/kcapi_hash.c */
@@ -1609,6 +1615,9 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
16091615 /* fall-through when unavailable */
16101616 }
16111617 #endif
1618+ #ifdef WOLF_CRYPTO_CB_ONLY_SHA256
1619+ return NO_VALID_DEVID ;
1620+ #else
16121621 #if defined(WOLFSSL_ASYNC_CRYPT ) && defined(WC_ASYNC_ENABLE_SHA256 )
16131622 if (sha256 -> asyncDev .marker == WOLFSSL_ASYNC_MARKER_SHA256 ) {
16141623 #if defined(HAVE_INTEL_QA )
@@ -1618,9 +1627,11 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
16181627 #endif /* WOLFSSL_ASYNC_CRYPT */
16191628
16201629 return Sha256Update (sha256 , data , len );
1630+ #endif /* !WOLF_CRYPTO_CB_ONLY_SHA256 */
16211631 }
16221632#endif
16231633
1634+ #ifndef WOLF_CRYPTO_CB_ONLY_SHA256
16241635 static WC_INLINE int Sha256Final (wc_Sha256 * sha256 )
16251636 {
16261637 int ret ;
@@ -1771,9 +1782,11 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
17711782
17721783 return ret ;
17731784 }
1785+ #endif /* !WOLF_CRYPTO_CB_ONLY_SHA256 */
17741786
17751787#if !defined(WOLFSSL_KCAPI_HASH )
17761788
1789+ #ifndef WOLFSSL_NO_HASH_RAW
17771790 int wc_Sha256FinalRaw (wc_Sha256 * sha256 , byte * hash )
17781791 {
17791792 #ifdef LITTLE_ENDIAN_ORDER
@@ -1797,6 +1810,7 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
17971810
17981811 return 0 ;
17991812 }
1813+ #endif /* !WOLFSSL_NO_HASH_RAW */
18001814
18011815 int wc_Sha256Final (wc_Sha256 * sha256 , byte * hash )
18021816 {
@@ -1818,6 +1832,9 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
18181832 }
18191833 #endif
18201834
1835+ #ifdef WOLF_CRYPTO_CB_ONLY_SHA256
1836+ return NO_VALID_DEVID ;
1837+ #else
18211838 #if defined(WOLFSSL_ASYNC_CRYPT ) && defined(WC_ASYNC_ENABLE_SHA256 )
18221839 if (sha256 -> asyncDev .marker == WOLFSSL_ASYNC_MARKER_SHA256 ) {
18231840 #if defined(HAVE_INTEL_QA )
@@ -1841,9 +1858,11 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
18411858 XMEMCPY (hash , sha256 -> digest , WC_SHA256_DIGEST_SIZE );
18421859
18431860 return InitSha256 (sha256 ); /* reset state */
1861+ #endif /* !WOLF_CRYPTO_CB_ONLY_SHA256 */
18441862 }
18451863
1846- #if defined(OPENSSL_EXTRA ) || defined(HAVE_CURL )
1864+ #if (defined(OPENSSL_EXTRA ) || defined(HAVE_CURL )) && \
1865+ !defined(WOLF_CRYPTO_CB_ONLY_SHA256 )
18471866/* Apply SHA256 transformation to the data */
18481867/* @param sha a pointer to wc_Sha256 structure */
18491868/* @param data data to be applied SHA256 transformation */
@@ -1867,7 +1886,8 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
18671886 }
18681887#endif /* OPENSSL_EXTRA || HAVE_CURL */
18691888
1870- #if defined(WOLFSSL_HAVE_LMS ) && !defined(WOLFSSL_LMS_FULL_HASH )
1889+ #if defined(WOLFSSL_HAVE_LMS ) && !defined(WOLFSSL_LMS_FULL_HASH ) && \
1890+ !defined(WOLF_CRYPTO_CB_ONLY_SHA256 )
18711891 /* One block will be used from data.
18721892 * hash must be big enough to hold all of digest output.
18731893 */
0 commit comments