Added flag to indicate if hash is copied.

This commit is contained in:
David Garske
2019-02-05 18:28:54 -08:00
parent e7b23646a5
commit dcdb1d7094
6 changed files with 31 additions and 1 deletions

View File

@ -37,6 +37,7 @@
#include <wolfssl/wolfcrypt/md5.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h>
#include <wolfssl/wolfcrypt/hash.h>
#ifdef NO_INLINE
#include <wolfssl/wolfcrypt/misc.h>
@ -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;
}

View File

@ -42,6 +42,7 @@
#include <wolfssl/wolfcrypt/sha.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/hash.h>
#ifdef WOLF_CRYPTO_CB
#include <wolfssl/wolfcrypt/cryptocb.h>
@ -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 */

View File

@ -44,6 +44,7 @@
#include <wolfssl/wolfcrypt/sha256.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/cpuid.h>
#include <wolfssl/wolfcrypt/hash.h>
#ifdef WOLF_CRYPTO_CB
#include <wolfssl/wolfcrypt/cryptocb.h>
@ -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;
}

View File

@ -43,6 +43,7 @@
#include <wolfssl/wolfcrypt/sha3.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/hash.h>
#ifdef NO_INLINE
#include <wolfssl/wolfcrypt/misc.h>
@ -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;
}

View File

@ -43,6 +43,7 @@
#include <wolfssl/wolfcrypt/sha512.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/cpuid.h>
#include <wolfssl/wolfcrypt/hash.h>
/* 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;
}

View File

@ -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 */
};