projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Swap to using _longjmp/_setjmp instead of longjmp/setjmp
[oweals/openssl.git]
/
crypto
/
ec
/
ecp_nistp521.c
diff --git
a/crypto/ec/ecp_nistp521.c
b/crypto/ec/ecp_nistp521.c
index b2fe653f1e52660a501d1c1bebbdcf8d84efebdf..dd5b19b5813af1ac4944959be25762b9d50ee924 100644
(file)
--- a/
crypto/ec/ecp_nistp521.c
+++ b/
crypto/ec/ecp_nistp521.c
@@
-185,7
+185,7
@@
static int BN_to_felem(felem out, const BIGNUM *bn)
unsigned num_bytes;
/* BN_bn2bin eats leading zeroes */
unsigned num_bytes;
/* BN_bn2bin eats leading zeroes */
- memset(b_out, 0, sizeof
b_out
);
+ memset(b_out, 0, sizeof
(b_out)
);
num_bytes = BN_num_bytes(bn);
if (num_bytes > sizeof b_out) {
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
num_bytes = BN_num_bytes(bn);
if (num_bytes > sizeof b_out) {
ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE);
@@
-1470,7
+1470,8
@@
static void select_point(const limb idx, unsigned int size,
{
unsigned i, j;
limb *outlimbs = &out[0][0];
{
unsigned i, j;
limb *outlimbs = &out[0][0];
- memset(outlimbs, 0, 3 * sizeof(felem));
+
+ memset(out, 0, sizeof(*out) * 3);
for (i = 0; i < size; i++) {
const limb *inlimbs = &pre_comp[i][0][0];
for (i = 0; i < size; i++) {
const limb *inlimbs = &pre_comp[i][0][0];
@@
-1513,7
+1514,7
@@
static void batch_mul(felem x_out, felem y_out, felem z_out,
u8 sign, digit;
/* set nq to the point at infinity */
u8 sign, digit;
/* set nq to the point at infinity */
- memset(nq, 0,
3 * sizeof(felem
));
+ memset(nq, 0,
sizeof(nq
));
/*
* Loop over all scalars msb-to-lsb, interleaving additions of multiples
/*
* Loop over all scalars msb-to-lsb, interleaving additions of multiples
@@
-1643,13
+1644,12
@@
const EC_METHOD *EC_GFp_nistp521_method(void)
static NISTP521_PRE_COMP *nistp521_pre_comp_new()
{
static NISTP521_PRE_COMP *nistp521_pre_comp_new()
{
- NISTP521_PRE_COMP *ret =
NULL
;
- ret = OPENSSL_malloc(sizeof(NISTP521_PRE_COMP));
- if (
!ret
) {
+ NISTP521_PRE_COMP *ret =
OPENSSL_zalloc(sizeof(*ret))
;
+
+ if (
ret == NULL
) {
ECerr(EC_F_NISTP521_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
return ret;
}
ECerr(EC_F_NISTP521_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
return ret;
}
- memset(ret->g_pre_comp, 0, sizeof(ret->g_pre_comp));
ret->references = 1;
return ret;
}
ret->references = 1;
return ret;
}
@@
-1691,8
+1691,7
@@
static void nistp521_pre_comp_clear_free(void *pre_)
if (i > 0)
return;
if (i > 0)
return;
- OPENSSL_cleanse(pre, sizeof(*pre));
- OPENSSL_free(pre);
+ OPENSSL_clear_free(pre, sizeof(*pre));
}
/******************************************************************************/
}
/******************************************************************************/
@@
-1736,8
+1735,7
@@
int ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p,
ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx);
err:
BN_CTX_end(ctx);
ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx);
err:
BN_CTX_end(ctx);
- if (new_ctx != NULL)
- BN_CTX_free(new_ctx);
+ BN_CTX_free(new_ctx);
return ret;
}
return ret;
}
@@
-1836,7
+1834,7
@@
int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
BIGNUM *x, *y, *z, *tmp_scalar;
felem_bytearray g_secret;
felem_bytearray *secrets = NULL;
BIGNUM *x, *y, *z, *tmp_scalar;
felem_bytearray g_secret;
felem_bytearray *secrets = NULL;
- felem(*pre_comp)[17][3] = NULL;
+ felem
(*pre_comp)[17][3] = NULL;
felem *tmp_felems = NULL;
felem_bytearray tmp;
unsigned i, num_bytes;
felem *tmp_felems = NULL;
felem_bytearray tmp;
unsigned i, num_bytes;
@@
-1903,11
+1901,11
@@
int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
*/
mixed = 1;
}
*/
mixed = 1;
}
- secrets = OPENSSL_
malloc(num_points * sizeof(felem_bytearray)
);
- pre_comp = OPENSSL_
malloc(num_points * 17 * 3 * sizeof(felem)
);
+ secrets = OPENSSL_
zalloc(sizeof(*secrets) * num_points
);
+ pre_comp = OPENSSL_
zalloc(sizeof(*pre_comp) * num_points
);
if (mixed)
tmp_felems =
if (mixed)
tmp_felems =
- OPENSSL_malloc(
(num_points * 17 + 1) * sizeof(felem
));
+ OPENSSL_malloc(
sizeof(*tmp_felems) * (num_points * 17 + 1
));
if ((secrets == NULL) || (pre_comp == NULL)
|| (mixed && (tmp_felems == NULL))) {
ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_MALLOC_FAILURE);
if ((secrets == NULL) || (pre_comp == NULL)
|| (mixed && (tmp_felems == NULL))) {
ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_MALLOC_FAILURE);
@@
-1918,8
+1916,6
@@
int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
* we treat NULL scalars as 0, and NULL points as points at infinity,
* i.e., they contribute nothing to the linear combination
*/
* we treat NULL scalars as 0, and NULL points as points at infinity,
* i.e., they contribute nothing to the linear combination
*/
- memset(secrets, 0, num_points * sizeof(felem_bytearray));
- memset(pre_comp, 0, num_points * 17 * 3 * sizeof(felem));
for (i = 0; i < num_points; ++i) {
if (i == num)
/*
for (i = 0; i < num_points; ++i) {
if (i == num)
/*
@@
-2022,14
+2018,10
@@
int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
err:
BN_CTX_end(ctx);
EC_POINT_free(generator);
err:
BN_CTX_end(ctx);
EC_POINT_free(generator);
- if (new_ctx != NULL)
- BN_CTX_free(new_ctx);
- if (secrets != NULL)
- OPENSSL_free(secrets);
- if (pre_comp != NULL)
- OPENSSL_free(pre_comp);
- if (tmp_felems != NULL)
- OPENSSL_free(tmp_felems);
+ BN_CTX_free(new_ctx);
+ OPENSSL_free(secrets);
+ OPENSSL_free(pre_comp);
+ OPENSSL_free(tmp_felems);
return ret;
}
return ret;
}
@@
-2138,8
+2130,7
@@
int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
err:
BN_CTX_end(ctx);
EC_POINT_free(generator);
err:
BN_CTX_end(ctx);
EC_POINT_free(generator);
- if (new_ctx != NULL)
- BN_CTX_free(new_ctx);
+ BN_CTX_free(new_ctx);
nistp521_pre_comp_free(pre);
return ret;
}
nistp521_pre_comp_free(pre);
return ret;
}