free cleanup almost the finale
Add OPENSSL_clear_free which merges cleanse and free.
(Names was picked to be similar to BN_clear_free, etc.)
Removed OPENSSL_freeFunc macro.
Fixed the small simple ones that are left:
CRYPTO_free CRYPTO_free_locked OPENSSL_free_locked
Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
@@ -127,9 +127,7 @@ void EC_KEY_free(EC_KEY *r)
|
||||
|
||||
EC_EX_DATA_free_all_data(&r->method_data);
|
||||
|
||||
OPENSSL_cleanse((void *)r, sizeof(EC_KEY));
|
||||
|
||||
OPENSSL_free(r);
|
||||
OPENSSL_clear_free((void *)r, sizeof(EC_KEY));
|
||||
}
|
||||
|
||||
EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
|
||||
|
||||
@@ -166,14 +166,8 @@ void EC_GROUP_clear_free(EC_GROUP *group)
|
||||
EC_POINT_clear_free(group->generator);
|
||||
BN_clear_free(group->order);
|
||||
BN_clear_free(group->cofactor);
|
||||
|
||||
if (group->seed) {
|
||||
OPENSSL_cleanse(group->seed, group->seed_len);
|
||||
OPENSSL_free(group->seed);
|
||||
}
|
||||
|
||||
OPENSSL_cleanse(group, sizeof *group);
|
||||
OPENSSL_free(group);
|
||||
OPENSSL_clear_free(group->seed, group->seed_len);
|
||||
OPENSSL_clear_free(group, sizeof *group);
|
||||
}
|
||||
|
||||
int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src)
|
||||
@@ -751,8 +745,7 @@ void EC_POINT_clear_free(EC_POINT *point)
|
||||
point->meth->point_clear_finish(point);
|
||||
else if (point->meth->point_finish != 0)
|
||||
point->meth->point_finish(point);
|
||||
OPENSSL_cleanse(point, sizeof *point);
|
||||
OPENSSL_free(point);
|
||||
OPENSSL_clear_free(point, sizeof *point);
|
||||
}
|
||||
|
||||
int EC_POINT_copy(EC_POINT *dest, const EC_POINT *src)
|
||||
|
||||
@@ -169,8 +169,7 @@ static void ec_pre_comp_clear_free(void *pre_)
|
||||
}
|
||||
OPENSSL_free(pre->points);
|
||||
}
|
||||
OPENSSL_cleanse(pre, sizeof *pre);
|
||||
OPENSSL_free(pre);
|
||||
OPENSSL_clear_free(pre, sizeof *pre);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -268,10 +268,7 @@ static int pkey_ec_kdf_derive(EVP_PKEY_CTX *ctx,
|
||||
rv = 1;
|
||||
|
||||
err:
|
||||
if (ktmp) {
|
||||
OPENSSL_cleanse(ktmp, ktmplen);
|
||||
OPENSSL_free(ktmp);
|
||||
}
|
||||
OPENSSL_clear_free(ktmp, ktmplen);
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1247,8 +1247,7 @@ static void nistp224_pre_comp_clear_free(void *pre_)
|
||||
if (i > 0)
|
||||
return;
|
||||
|
||||
OPENSSL_cleanse(pre, sizeof *pre);
|
||||
OPENSSL_free(pre);
|
||||
OPENSSL_clear_free(pre, sizeof *pre);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -1862,8 +1862,7 @@ static void nistp256_pre_comp_clear_free(void *pre_)
|
||||
if (i > 0)
|
||||
return;
|
||||
|
||||
OPENSSL_cleanse(pre, sizeof *pre);
|
||||
OPENSSL_free(pre);
|
||||
OPENSSL_clear_free(pre, sizeof *pre);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -1691,8 +1691,7 @@ static void nistp521_pre_comp_clear_free(void *pre_)
|
||||
if (i > 0)
|
||||
return;
|
||||
|
||||
OPENSSL_cleanse(pre, sizeof(*pre));
|
||||
OPENSSL_free(pre);
|
||||
OPENSSL_clear_free(pre, sizeof(*pre));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -1471,13 +1471,9 @@ static void ecp_nistz256_pre_comp_clear_free(void *pre_)
|
||||
if (i > 0)
|
||||
return;
|
||||
|
||||
if (pre->precomp_storage) {
|
||||
OPENSSL_cleanse(pre->precomp,
|
||||
32 * sizeof(unsigned char) * (1 << pre->w) * 2 * 37);
|
||||
OPENSSL_free(pre->precomp_storage);
|
||||
}
|
||||
OPENSSL_cleanse(pre, sizeof *pre);
|
||||
OPENSSL_free(pre);
|
||||
OPENSSL_clear_free(pre->precomp,
|
||||
32 * sizeof(unsigned char) * (1 << pre->w) * 2 * 37);
|
||||
OPENSSL_clear_free(pre, sizeof *pre);
|
||||
}
|
||||
|
||||
static int ecp_nistz256_window_have_precompute_mult(const EC_GROUP *group)
|
||||
|
||||
Reference in New Issue
Block a user