mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-04 21:24:43 +02:00
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 */
|
/* Free Aes from use with async hardware */
|
||||||
void wc_AesFree(Aes* aes)
|
void wc_AesFree(Aes* aes)
|
||||||
{
|
{
|
||||||
unsigned int isAllocated;
|
void* heap;
|
||||||
|
byte isAllocated;
|
||||||
|
|
||||||
if (aes == NULL) {
|
if (aes == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
heap = aes->heap;
|
||||||
isAllocated = aes->isAllocated;
|
isAllocated = aes->isAllocated;
|
||||||
|
|
||||||
#ifdef WC_DEBUG_CIPHER_LIFECYCLE
|
#ifdef WC_DEBUG_CIPHER_LIFECYCLE
|
||||||
(void)wc_debug_CipherLifecycleFree(&aes->CipherLifecycleTag, aes->heap, 1);
|
(void)wc_debug_CipherLifecycleFree(&aes->CipherLifecycleTag, heap, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_AES)
|
||||||
@@ -11495,7 +11497,7 @@ void wc_AesFree(Aes* aes)
|
|||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_AESGCM_STREAM) && defined(WOLFSSL_SMALL_STACK) && \
|
#if defined(WOLFSSL_AESGCM_STREAM) && defined(WOLFSSL_SMALL_STACK) && \
|
||||||
!defined(WOLFSSL_AESNI)
|
!defined(WOLFSSL_AESNI)
|
||||||
XFREE(aes->streamData, aes->heap, DYNAMIC_TYPE_AES);
|
XFREE(aes->streamData, heap, DYNAMIC_TYPE_AES);
|
||||||
aes->streamData = NULL;
|
aes->streamData = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -11524,7 +11526,7 @@ void wc_AesFree(Aes* aes)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (isAllocated) {
|
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 */
|
/* Clean the memory of a key */
|
||||||
void wc_curve25519_free(curve25519_key* key)
|
void wc_curve25519_free(curve25519_key* key)
|
||||||
{
|
{
|
||||||
int isAllocated = 0;
|
|
||||||
void* heap;
|
void* heap;
|
||||||
|
byte isAllocated = 0;
|
||||||
|
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
isAllocated = key->isAllocated;
|
|
||||||
heap = key->heap;
|
heap = key->heap;
|
||||||
|
isAllocated = key->isAllocated;
|
||||||
|
|
||||||
#ifdef WOLFSSL_SE050
|
#ifdef WOLFSSL_SE050
|
||||||
se050_curve25519_free_key(key);
|
se050_curve25519_free_key(key);
|
||||||
|
@@ -1023,14 +1023,14 @@ int wc_ed25519_init(ed25519_key* key)
|
|||||||
/* clear memory of key */
|
/* clear memory of key */
|
||||||
void wc_ed25519_free(ed25519_key* key)
|
void wc_ed25519_free(ed25519_key* key)
|
||||||
{
|
{
|
||||||
int isAllocated = 0;
|
|
||||||
void* heap;
|
void* heap;
|
||||||
|
byte isAllocated = 0;
|
||||||
|
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
isAllocated = key->isAllocated;
|
|
||||||
heap = key->heap;
|
heap = key->heap;
|
||||||
|
isAllocated = key->isAllocated;
|
||||||
|
|
||||||
#ifdef WOLFSSL_ED25519_PERSISTENT_SHA
|
#ifdef WOLFSSL_ED25519_PERSISTENT_SHA
|
||||||
ed25519_hash_free(key, &key->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 wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
|
||||||
{
|
{
|
||||||
int ret = WC_NO_ERR_TRACE(HASH_TYPE_E); /* Default to hash type error */
|
int ret = WC_NO_ERR_TRACE(HASH_TYPE_E); /* Default to hash type error */
|
||||||
int isAllocated = 0;
|
|
||||||
void* heap = NULL;
|
void* heap = NULL;
|
||||||
|
byte isAllocated = 0;
|
||||||
|
|
||||||
if (hash == NULL)
|
if (hash == NULL)
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
@@ -1172,6 +1172,7 @@ int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
|
|||||||
|
|
||||||
if (isAllocated) {
|
if (isAllocated) {
|
||||||
XFREE(hash, heap, DYNAMIC_TYPE_HASHES);
|
XFREE(hash, heap, DYNAMIC_TYPE_HASHES);
|
||||||
|
(void)heap;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -542,15 +542,15 @@ int wc_RsaGetKeyId(RsaKey* key, word32* keyId)
|
|||||||
int wc_FreeRsaKey(RsaKey* key)
|
int wc_FreeRsaKey(RsaKey* key)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int isAllocated = 0;
|
|
||||||
void* heap;
|
void* heap;
|
||||||
|
byte isAllocated = 0;
|
||||||
|
|
||||||
if (key == NULL) {
|
if (key == NULL) {
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
isAllocated = key->isAllocated;
|
|
||||||
heap = key->heap;
|
heap = key->heap;
|
||||||
|
isAllocated = key->isAllocated;
|
||||||
|
|
||||||
wc_RsaCleanup(key);
|
wc_RsaCleanup(key);
|
||||||
|
|
||||||
@@ -587,7 +587,7 @@ int wc_FreeRsaKey(RsaKey* key)
|
|||||||
mp_clear(&key->n);
|
mp_clear(&key->n);
|
||||||
|
|
||||||
#ifdef WOLFSSL_XILINX_CRYPT
|
#ifdef WOLFSSL_XILINX_CRYPT
|
||||||
XFREE(key->mod, key->heap, DYNAMIC_TYPE_KEY);
|
XFREE(key->mod, heap, DYNAMIC_TYPE_KEY);
|
||||||
key->mod = NULL;
|
key->mod = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -99,8 +99,7 @@ struct curve25519_key {
|
|||||||
/* bit fields */
|
/* bit fields */
|
||||||
byte pubSet:1;
|
byte pubSet:1;
|
||||||
byte privSet:1;
|
byte privSet:1;
|
||||||
|
byte isAllocated:1; /* flag indicates if structure was allocated */
|
||||||
unsigned int isAllocated:1; /* flag indicates if structure was allocated */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@@ -106,10 +106,10 @@ struct ed25519_key {
|
|||||||
void *heap;
|
void *heap;
|
||||||
#ifdef WOLFSSL_ED25519_PERSISTENT_SHA
|
#ifdef WOLFSSL_ED25519_PERSISTENT_SHA
|
||||||
wc_Sha512 sha;
|
wc_Sha512 sha;
|
||||||
unsigned int sha_clean_flag : 1;
|
byte sha_clean_flag : 1;
|
||||||
#endif
|
#endif
|
||||||
/* flag indicates if structure was allocated */
|
/* flag indicates if structure was allocated */
|
||||||
unsigned int isAllocated : 1;
|
byte isAllocated : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef WC_ED25519KEY_TYPE_DEFINED
|
#ifndef WC_ED25519KEY_TYPE_DEFINED
|
||||||
|
@@ -125,7 +125,7 @@ typedef union {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
wc_Hashes alg;
|
wc_Hashes alg;
|
||||||
enum wc_HashType type; /* sanity check */
|
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;
|
} wc_HashAlg;
|
||||||
#endif /* !NO_HASH_WRAPPER */
|
#endif /* !NO_HASH_WRAPPER */
|
||||||
|
|
||||||
|
@@ -269,7 +269,7 @@ struct RsaKey {
|
|||||||
#if defined(WOLFSSL_RENESAS_FSPSM)
|
#if defined(WOLFSSL_RENESAS_FSPSM)
|
||||||
FSPSM_RSA_CTX ctx;
|
FSPSM_RSA_CTX ctx;
|
||||||
#endif
|
#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
|
#ifndef WC_RSAKEY_TYPE_DEFINED
|
||||||
|
Reference in New Issue
Block a user