Skip to content

Commit

Permalink
[#1823] update memory allocator for copy_from_upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Songling Han <[email protected]>
  • Loading branch information
songlingatpan committed Sep 17, 2024
1 parent b61754c commit 3dc1284
Show file tree
Hide file tree
Showing 66 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions scripts/copy_from_upstream/src/kem/family/kem_scheme.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% endif %}
OQS_KEM *OQS_KEM_{{ family }}_{{ scheme['scheme'] }}_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down Expand Up @@ -42,7 +42,7 @@ OQS_KEM *OQS_KEM_{{ family }}_{{ scheme['scheme'] }}_new(void) {
/** Alias */
OQS_KEM *OQS_KEM_{{ family }}_{{ scheme['alias_scheme'] }}_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/copy_from_upstream/src/sig/family/sig_scheme.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% endif %}
OQS_SIG *OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down Expand Up @@ -41,7 +41,7 @@ OQS_SIG *OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_new(void) {
/** Alias */
OQS_SIG *OQS_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{%- if scheme['signed_msg_order'] == 'sig_then_msg' %}
// signed_msg = signature || msg
*signed_msg_len = signature_len + msg_len;
*signed_msg = malloc(*signed_msg_len);
*signed_msg = OQS_MEM_malloc(*signed_msg_len);
if (*signed_msg == NULL) {
return OQS_ERROR;
}
Expand All @@ -13,7 +13,7 @@
{%- elif scheme['signed_msg_order'] == 'msg_then_sig' %}
// signed_msg = msg || signature
*signed_msg_len = msg_len + signature_len;
*signed_msg = malloc(*signed_msg_len);
*signed_msg = OQS_MEM_malloc(*signed_msg_len);
if (*signed_msg == NULL) {
return OQS_ERROR;
}
Expand All @@ -24,7 +24,7 @@
// signed_msg = sig_len (2 bytes, big endian) || nonce (40 bytes) || msg || 0x29 || sig
const uint16_t signature_len_uint16 = (uint16_t)signature_len;
*signed_msg_len = 2 + signature_len_uint16 + msg_len;
*signed_msg = malloc(*signed_msg_len);
*signed_msg = OQS_MEM_malloc(*signed_msg_len);
if (*signed_msg == NULL) {
return OQS_ERROR;
}
Expand All @@ -44,7 +44,7 @@
// signed_msg = sig_len (2 bytes, big endian) || nonce (40 bytes) || msg || 0x2A || sig
const uint16_t signature_len_uint16 = (uint16_t)signature_len;
*signed_msg_len = 2 + signature_len + msg_len;
*signed_msg = malloc(*signed_msg_len);
*signed_msg = OQS_MEM_malloc(*signed_msg_len);
if (*signed_msg == NULL) {
return OQS_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/classic_mceliece/kem_classic_mceliece_348864.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_classic_mceliece_348864_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/classic_mceliece/kem_classic_mceliece_348864f.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_classic_mceliece_348864f_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/classic_mceliece/kem_classic_mceliece_460896.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_classic_mceliece_460896_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/classic_mceliece/kem_classic_mceliece_460896f.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_classic_mceliece_460896f_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/classic_mceliece/kem_classic_mceliece_6688128.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_classic_mceliece_6688128_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/classic_mceliece/kem_classic_mceliece_6688128f.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_classic_mceliece_6688128f_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/classic_mceliece/kem_classic_mceliece_6960119.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_classic_mceliece_6960119_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/classic_mceliece/kem_classic_mceliece_6960119f.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_classic_mceliece_6960119f_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/classic_mceliece/kem_classic_mceliece_8192128.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_classic_mceliece_8192128_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/classic_mceliece/kem_classic_mceliece_8192128f.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_classic_mceliece_8192128f_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/hqc/kem_hqc_128.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_hqc_128_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/hqc/kem_hqc_192.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_hqc_192_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/hqc/kem_hqc_256.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_hqc_256_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/kyber/kem_kyber_1024.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_kyber_1024_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/kyber/kem_kyber_512.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_kyber_512_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/kyber/kem_kyber_768.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_kyber_768_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/ml_kem/kem_ml_kem_1024.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_ml_kem_1024_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/ml_kem/kem_ml_kem_512.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_ml_kem_512_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kem/ml_kem/kem_ml_kem_768.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_KEM *OQS_KEM_ml_kem_768_new(void) {

OQS_KEM *kem = malloc(sizeof(OQS_KEM));
OQS_KEM *kem = OQS_MEM_malloc(sizeof(OQS_KEM));
if (kem == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdp_128_balanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdp_128_balanced_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdp_128_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdp_128_fast_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdp_128_small.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdp_128_small_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdp_192_balanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdp_192_balanced_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdp_192_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdp_192_fast_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdp_192_small.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdp_192_small_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdp_256_balanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdp_256_balanced_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdp_256_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdp_256_fast_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdp_256_small.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdp_256_small_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdpg_128_balanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdpg_128_balanced_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdpg_128_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdpg_128_fast_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdpg_128_small.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdpg_128_small_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdpg_192_balanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdpg_192_balanced_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdpg_192_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdpg_192_fast_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdpg_192_small.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdpg_192_small_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdpg_256_balanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdpg_256_balanced_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sig/cross/sig_cross_rsdpg_256_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

OQS_SIG *OQS_SIG_cross_rsdpg_256_fast_new(void) {

OQS_SIG *sig = malloc(sizeof(OQS_SIG));
OQS_SIG *sig = OQS_MEM_malloc(sizeof(OQS_SIG));
if (sig == NULL) {
return NULL;
}
Expand Down
Loading

0 comments on commit 3dc1284

Please sign in to comment.