diff --git a/wolfcrypt/src/md5.c b/wolfcrypt/src/md5.c index a3f903dc4..ce3b03318 100644 --- a/wolfcrypt/src/md5.c +++ b/wolfcrypt/src/md5.c @@ -37,6 +37,7 @@ #include #include #include +#include #ifdef NO_INLINE #include @@ -50,7 +51,7 @@ #if defined(STM32_HASH) /* Supports CubeMX HAL or Standard Peripheral Library */ - #define HAVE_MD5_CUST_API + #define HAVE_MD5_CUST_API int wc_InitMd5_ex(wc_Md5* md5, void* heap, int devId) { @@ -436,6 +437,9 @@ int wc_Md5Copy(wc_Md5* src, wc_Md5* dst) #ifdef WOLFSSL_PIC32MZ_HASH ret = wc_Pic32HashCopy(&src->cache, &dst->cache); #endif +#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) + dst->flags |= WC_HASH_FLAG_ISCOPY; +#endif return ret; } diff --git a/wolfcrypt/src/sha.c b/wolfcrypt/src/sha.c index 22f7ff8e3..6e8929417 100644 --- a/wolfcrypt/src/sha.c +++ b/wolfcrypt/src/sha.c @@ -42,6 +42,7 @@ #include #include +#include #ifdef WOLF_CRYPTO_CB #include @@ -713,6 +714,10 @@ int wc_ShaCopy(wc_Sha* src, wc_Sha* dst) dst->ctx.isfirstblock = src->ctx.isfirstblock; dst->ctx.sha_type = src->ctx.sha_type; #endif +#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) + dst->flags |= WC_HASH_FLAG_ISCOPY; +#endif + return ret; } #endif /* !WOLFSSL_TI_HASH */ diff --git a/wolfcrypt/src/sha256.c b/wolfcrypt/src/sha256.c index aa063e062..f44e9a4c1 100644 --- a/wolfcrypt/src/sha256.c +++ b/wolfcrypt/src/sha256.c @@ -44,6 +44,7 @@ #include #include #include +#include #ifdef WOLF_CRYPTO_CB #include @@ -1297,6 +1298,9 @@ void wc_Sha256Free(wc_Sha256* sha256) #ifdef WOLFSSL_ASYNC_CRYPT ret = wolfAsync_DevCopy(&src->asyncDev, &dst->asyncDev); #endif + #if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) + dst->flags |= WC_HASH_FLAG_ISCOPY; + #endif return ret; } @@ -1381,6 +1385,9 @@ int wc_Sha256Copy(wc_Sha256* src, wc_Sha256* dst) dst->ctx.isfirstblock = src->ctx.isfirstblock; dst->ctx.sha_type = src->ctx.sha_type; #endif +#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) + dst->flags |= WC_HASH_FLAG_ISCOPY; +#endif return ret; } diff --git a/wolfcrypt/src/sha3.c b/wolfcrypt/src/sha3.c index bb6e1ed11..9761a4fa0 100644 --- a/wolfcrypt/src/sha3.c +++ b/wolfcrypt/src/sha3.c @@ -43,6 +43,7 @@ #include #include +#include #ifdef NO_INLINE #include @@ -793,6 +794,9 @@ static int wc_Sha3Copy(wc_Sha3* src, wc_Sha3* dst) #ifdef WOLFSSL_ASYNC_CRYPT ret = wolfAsync_DevCopy(&src->asyncDev, &dst->asyncDev); #endif +#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) + dst->flags |= WC_HASH_FLAG_ISCOPY; +#endif return ret; } diff --git a/wolfcrypt/src/sha512.c b/wolfcrypt/src/sha512.c index 30e4e0a48..202d4de83 100644 --- a/wolfcrypt/src/sha512.c +++ b/wolfcrypt/src/sha512.c @@ -43,6 +43,7 @@ #include #include #include +#include /* deprecated USE_SLOW_SHA2 (replaced with USE_SLOW_SHA512) */ #if defined(USE_SLOW_SHA2) && !defined(USE_SLOW_SHA512) @@ -1110,6 +1111,10 @@ int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst) dst->ctx.isfirstblock = src->ctx.isfirstblock; dst->ctx.sha_type = src->ctx.sha_type; #endif +#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) + dst->flags |= WC_HASH_FLAG_ISCOPY; +#endif + return ret; } @@ -1182,6 +1187,10 @@ int wc_Sha384Copy(wc_Sha384* src, wc_Sha384* dst) dst->ctx.isfirstblock = src->ctx.isfirstblock; dst->ctx.sha_type = src->ctx.sha_type; #endif +#if defined(WOLFSSL_HASH_FLAGS) || defined(WOLF_CRYPTO_CB) + dst->flags |= WC_HASH_FLAG_ISCOPY; +#endif + return ret; } diff --git a/wolfssl/wolfcrypt/hash.h b/wolfssl/wolfcrypt/hash.h index 920333efc..4690f1797 100644 --- a/wolfssl/wolfcrypt/hash.h +++ b/wolfssl/wolfcrypt/hash.h @@ -79,6 +79,7 @@ enum wc_MACAlgorithm { enum wc_HashFlags { WC_HASH_FLAG_NONE = 0x00000000, WC_HASH_FLAG_WILLCOPY = 0x00000001, /* flag to indicate hash will be copied */ + WC_HASH_FLAG_ISCOPY = 0x00000002, /* hash is copy */ };