mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-04 00:02:01 -04:00
Fix alice_priv_free in implementations (#293)
* fix replaced free by OQS_MEM_secure_free where necessary * commit * commit * removed //free(alice_priv)
This commit is contained in:
parent
068c48ae37
commit
89d290a75f
4
.gitignore
vendored
4
.gitignore
vendored
@ -105,3 +105,7 @@ data/
|
|||||||
# Exceptions
|
# Exceptions
|
||||||
!/src/kex_sidh_msr/config.h
|
!/src/kex_sidh_msr/config.h
|
||||||
!src/sig_picnic/external/config.h.in
|
!src/sig_picnic/external/config.h.in
|
||||||
|
|
||||||
|
# Misc (master branch)
|
||||||
|
.objs_upstream
|
||||||
|
*_kem*
|
||||||
|
@ -66,7 +66,7 @@ int main(void) {
|
|||||||
printf("===============================================================\n");
|
printf("===============================================================\n");
|
||||||
|
|
||||||
/* Alice's initial message */
|
/* Alice's initial message */
|
||||||
int success = OQS_KEX_alice_0(kex, &alice_priv, &alice_msg, &alice_msg_len);
|
OQS_STATUS success = OQS_KEX_alice_0(kex, &alice_priv, &alice_msg, &alice_msg_len);
|
||||||
if (success != OQS_SUCCESS) {
|
if (success != OQS_SUCCESS) {
|
||||||
eprintf("ERROR: OQS_KEX_alice_0 failed!\n");
|
eprintf("ERROR: OQS_KEX_alice_0 failed!\n");
|
||||||
cleanup(alice_msg, alice_msg_len, alice_key, alice_key_len, bob_msg,
|
cleanup(alice_msg, alice_msg_len, alice_key, alice_key_len, bob_msg,
|
||||||
|
@ -145,7 +145,7 @@ cleanup:
|
|||||||
|
|
||||||
void OQS_KEX_code_mcbits_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
void OQS_KEX_code_mcbits_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
||||||
if (alice_priv) {
|
if (alice_priv) {
|
||||||
free(alice_priv);
|
OQS_MEM_secure_free(alice_priv, CRYPTO_SECRETKEYBYTES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,12 +20,13 @@
|
|||||||
#include "recommended.h"
|
#include "recommended.h"
|
||||||
#define MACRIFY(NAME) NAME##_recommended
|
#define MACRIFY(NAME) NAME##_recommended
|
||||||
#include "kex_lwe_frodo_macrify.c"
|
#include "kex_lwe_frodo_macrify.c"
|
||||||
|
static size_t alice_priv_key_len = PARAMS_N * PARAMS_NBAR * sizeof(uint16_t);
|
||||||
// undefine macros to avoid any confusion later
|
// undefine macros to avoid any confusion later
|
||||||
#include "recommended.h"
|
#include "recommended.h"
|
||||||
#undef MACRIFY
|
#undef MACRIFY
|
||||||
|
|
||||||
void OQS_KEX_lwe_frodo_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
void OQS_KEX_lwe_frodo_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
||||||
free(alice_priv);
|
OQS_MEM_secure_free(alice_priv, alice_priv_key_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OQS_KEX_lwe_frodo_free(OQS_KEX *k) {
|
void OQS_KEX_lwe_frodo_free(OQS_KEX *k) {
|
||||||
|
@ -222,7 +222,7 @@ cleanup:
|
|||||||
void OQS_KEX_ntru_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
void OQS_KEX_ntru_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
||||||
if (alice_priv) {
|
if (alice_priv) {
|
||||||
OQS_KEX_ntru_alice_priv *ntru_alice_priv = (OQS_KEX_ntru_alice_priv *) alice_priv;
|
OQS_KEX_ntru_alice_priv *ntru_alice_priv = (OQS_KEX_ntru_alice_priv *) alice_priv;
|
||||||
free(ntru_alice_priv->priv_key);
|
OQS_MEM_secure_free(ntru_alice_priv->priv_key, ntru_alice_priv->priv_key_len);
|
||||||
}
|
}
|
||||||
free(alice_priv);
|
free(alice_priv);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ cleanup:
|
|||||||
|
|
||||||
void OQS_KEX_rlwe_bcns15_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
void OQS_KEX_rlwe_bcns15_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
||||||
if (alice_priv) {
|
if (alice_priv) {
|
||||||
free(alice_priv);
|
OQS_MEM_secure_free(alice_priv, 1024 * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ cleanup:
|
|||||||
|
|
||||||
void OQS_KEX_rlwe_msrln16_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
void OQS_KEX_rlwe_msrln16_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
||||||
if (alice_priv) {
|
if (alice_priv) {
|
||||||
free(alice_priv);
|
OQS_MEM_secure_free(alice_priv, 1024 * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ cleanup:
|
|||||||
|
|
||||||
void OQS_KEX_rlwe_newhope_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
void OQS_KEX_rlwe_newhope_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
||||||
if (alice_priv) {
|
if (alice_priv) {
|
||||||
free(alice_priv);
|
OQS_MEM_secure_free(alice_priv, sizeof(poly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,9 @@ OQS_STATUS OQS_KEX_sidh_iqc_ref_alice_1(OQS_KEX *k, const void *alice_priv,
|
|||||||
|
|
||||||
void OQS_KEX_sidh_iqc_ref_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
void OQS_KEX_sidh_iqc_ref_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
||||||
if (alice_priv) {
|
if (alice_priv) {
|
||||||
free(alice_priv);
|
uint32_t prime_size = (mpz_sizeinbase(characteristic, 2) + 7) / 8;
|
||||||
|
uint32_t private_key_size = 2 * prime_size;
|
||||||
|
OQS_MEM_secure_free(alice_priv, private_key_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,9 +302,10 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OQS_KEX_sidh_msr_alice_priv_free(UNUSED OQS_KEX *k, void *alice_priv) {
|
void OQS_KEX_sidh_msr_alice_priv_free(OQS_KEX *k, void *alice_priv) {
|
||||||
if (alice_priv) {
|
if (alice_priv) {
|
||||||
free(alice_priv);
|
SIDH_CTX *sidh_ctx = (SIDH_CTX *) k->ctx;
|
||||||
|
OQS_MEM_secure_free(alice_priv, (sidh_ctx->priv_key_len) * sizeof(uint8_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Generates the signature key pair */
|
/* Generates the signature key pair */
|
||||||
int success = OQS_SIG_keygen(s, priv, pub);
|
OQS_STATUS success = OQS_SIG_keygen(s, priv, pub);
|
||||||
if (success != OQS_SUCCESS) {
|
if (success != OQS_SUCCESS) {
|
||||||
eprintf("ERROR: OQS_SIG_keygen failed!\n");
|
eprintf("ERROR: OQS_SIG_keygen failed!\n");
|
||||||
cleanup(msg, msg_len, sig, sig_len, pub, priv, s, rnd);
|
cleanup(msg, msg_len, sig, sig_len, pub, priv, s, rnd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user