forked from wolfSSL/wolfssl
Use byte
for isAllocated
bit-field. Cleanup some of the "heap" hint logic.
This commit is contained in:
@@ -11448,16 +11448,18 @@ int wc_AesInit_Label(Aes* aes, const char* label, void* heap, int devId)
|
||||
/* Free Aes from use with async hardware */
|
||||
void wc_AesFree(Aes* aes)
|
||||
{
|
||||
unsigned int isAllocated;
|
||||
void* heap;
|
||||
byte isAllocated;
|
||||
|
||||
if (aes == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
heap = aes->heap;
|
||||
isAllocated = aes->isAllocated;
|
||||
|
||||
#ifdef WC_DEBUG_CIPHER_LIFECYCLE
|
||||
(void)wc_debug_CipherLifecycleFree(&aes->CipherLifecycleTag, aes->heap, 1);
|
||||
(void)wc_debug_CipherLifecycleFree(&aes->CipherLifecycleTag, heap, 1);
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)
|
||||
@@ -11495,7 +11497,7 @@ void wc_AesFree(Aes* aes)
|
||||
#endif
|
||||
#if defined(WOLFSSL_AESGCM_STREAM) && defined(WOLFSSL_SMALL_STACK) && \
|
||||
!defined(WOLFSSL_AESNI)
|
||||
XFREE(aes->streamData, aes->heap, DYNAMIC_TYPE_AES);
|
||||
XFREE(aes->streamData, heap, DYNAMIC_TYPE_AES);
|
||||
aes->streamData = NULL;
|
||||
#endif
|
||||
|
||||
@@ -11524,7 +11526,7 @@ void wc_AesFree(Aes* aes)
|
||||
#endif
|
||||
|
||||
if (isAllocated) {
|
||||
XFREE(aes, aes->heap, DYNAMIC_TYPE_AES);
|
||||
XFREE(aes, heap, DYNAMIC_TYPE_AES);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -707,14 +707,14 @@ int wc_curve25519_init(curve25519_key* key)
|
||||
/* Clean the memory of a key */
|
||||
void wc_curve25519_free(curve25519_key* key)
|
||||
{
|
||||
int isAllocated = 0;
|
||||
void* heap;
|
||||
byte isAllocated = 0;
|
||||
|
||||
if (key == NULL)
|
||||
return;
|
||||
|
||||
isAllocated = key->isAllocated;
|
||||
heap = key->heap;
|
||||
isAllocated = key->isAllocated;
|
||||
|
||||
#ifdef WOLFSSL_SE050
|
||||
se050_curve25519_free_key(key);
|
||||
|
@@ -1023,14 +1023,14 @@ int wc_ed25519_init(ed25519_key* key)
|
||||
/* clear memory of key */
|
||||
void wc_ed25519_free(ed25519_key* key)
|
||||
{
|
||||
int isAllocated = 0;
|
||||
void* heap;
|
||||
byte isAllocated = 0;
|
||||
|
||||
if (key == NULL)
|
||||
return;
|
||||
|
||||
isAllocated = key->isAllocated;
|
||||
heap = key->heap;
|
||||
isAllocated = key->isAllocated;
|
||||
|
||||
#ifdef WOLFSSL_ED25519_PERSISTENT_SHA
|
||||
ed25519_hash_free(key, &key->sha);
|
||||
|
@@ -1041,8 +1041,8 @@ int wc_HashFinal(wc_HashAlg* hash, enum wc_HashType type, byte* out)
|
||||
int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
|
||||
{
|
||||
int ret = WC_NO_ERR_TRACE(HASH_TYPE_E); /* Default to hash type error */
|
||||
int isAllocated = 0;
|
||||
void* heap = NULL;
|
||||
byte isAllocated = 0;
|
||||
|
||||
if (hash == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
@@ -1172,6 +1172,7 @@ int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
|
||||
|
||||
if (isAllocated) {
|
||||
XFREE(hash, heap, DYNAMIC_TYPE_HASHES);
|
||||
(void)heap;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@@ -542,15 +542,15 @@ int wc_RsaGetKeyId(RsaKey* key, word32* keyId)
|
||||
int wc_FreeRsaKey(RsaKey* key)
|
||||
{
|
||||
int ret = 0;
|
||||
int isAllocated = 0;
|
||||
void* heap;
|
||||
byte isAllocated = 0;
|
||||
|
||||
if (key == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
isAllocated = key->isAllocated;
|
||||
heap = key->heap;
|
||||
isAllocated = key->isAllocated;
|
||||
|
||||
wc_RsaCleanup(key);
|
||||
|
||||
@@ -587,7 +587,7 @@ int wc_FreeRsaKey(RsaKey* key)
|
||||
mp_clear(&key->n);
|
||||
|
||||
#ifdef WOLFSSL_XILINX_CRYPT
|
||||
XFREE(key->mod, key->heap, DYNAMIC_TYPE_KEY);
|
||||
XFREE(key->mod, heap, DYNAMIC_TYPE_KEY);
|
||||
key->mod = NULL;
|
||||
#endif
|
||||
|
||||
|
@@ -99,8 +99,7 @@ struct curve25519_key {
|
||||
/* bit fields */
|
||||
byte pubSet:1;
|
||||
byte privSet:1;
|
||||
|
||||
unsigned int isAllocated:1; /* flag indicates if structure was allocated */
|
||||
byte isAllocated:1; /* flag indicates if structure was allocated */
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@@ -106,10 +106,10 @@ struct ed25519_key {
|
||||
void *heap;
|
||||
#ifdef WOLFSSL_ED25519_PERSISTENT_SHA
|
||||
wc_Sha512 sha;
|
||||
unsigned int sha_clean_flag : 1;
|
||||
byte sha_clean_flag : 1;
|
||||
#endif
|
||||
/* flag indicates if structure was allocated */
|
||||
unsigned int isAllocated : 1;
|
||||
byte isAllocated : 1;
|
||||
};
|
||||
|
||||
#ifndef WC_ED25519KEY_TYPE_DEFINED
|
||||
|
@@ -125,7 +125,7 @@ typedef union {
|
||||
typedef struct {
|
||||
wc_Hashes alg;
|
||||
enum wc_HashType type; /* sanity check */
|
||||
unsigned int isAllocated:1; /* flag indicates if structure was allocated */
|
||||
byte isAllocated:1; /* flag indicates if structure was allocated */
|
||||
} wc_HashAlg;
|
||||
#endif /* !NO_HASH_WRAPPER */
|
||||
|
||||
|
@@ -269,7 +269,7 @@ struct RsaKey {
|
||||
#if defined(WOLFSSL_RENESAS_FSPSM)
|
||||
FSPSM_RSA_CTX ctx;
|
||||
#endif
|
||||
unsigned int isAllocated:1; /* flag indicates if structure was allocated */
|
||||
byte isAllocated:1; /* flag indicates if structure was allocated */
|
||||
};
|
||||
|
||||
#ifndef WC_RSAKEY_TYPE_DEFINED
|
||||
|
Reference in New Issue
Block a user