summaryrefslogtreecommitdiffstats
path: root/crypto/ec
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-05-12 19:15:27 +0200
committerTomas Mraz <tomas@openssl.org>2021-05-13 19:26:06 +0200
commitafecd85db1359b5a62c037b8a507b928541c779c (patch)
tree26c1def792b0e9e80a8042ef87e9d5cfbc9093d1 /crypto/ec
parent2bdec3b037264540014120a02217fc67bf355f11 (diff)
Replace some of the ERR_clear_error() calls with mark calls
Fixes #15219 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/15253)
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/ec2_oct.c8
-rw-r--r--crypto/ec/ecp_oct.c10
2 files changed, 8 insertions, 10 deletions
diff --git a/crypto/ec/ec2_oct.c b/crypto/ec/ec2_oct.c
index 1970efd65c..10a4932591 100644
--- a/crypto/ec/ec2_oct.c
+++ b/crypto/ec/ec2_oct.c
@@ -46,9 +46,6 @@ int ossl_ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group,
#ifndef FIPS_MODULE
BN_CTX *new_ctx = NULL;
- /* clear error queue */
- ERR_clear_error();
-
if (ctx == NULL) {
ctx = new_ctx = BN_CTX_new();
if (ctx == NULL)
@@ -80,21 +77,24 @@ int ossl_ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group,
goto err;
if (!BN_GF2m_add(tmp, x, tmp))
goto err;
+ ERR_set_mark();
if (!BN_GF2m_mod_solve_quad_arr(z, tmp, group->poly, ctx)) {
#ifndef FIPS_MODULE
unsigned long err = ERR_peek_last_error();
if (ERR_GET_LIB(err) == ERR_LIB_BN
&& ERR_GET_REASON(err) == BN_R_NO_SOLUTION) {
- ERR_clear_error();
+ ERR_pop_to_mark();
ERR_raise(ERR_LIB_EC, EC_R_INVALID_COMPRESSED_POINT);
} else
#endif
{
+ ERR_clear_last_mark();
ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
}
goto err;
}
+ ERR_clear_last_mark();
z0 = (BN_is_odd(z)) ? 1 : 0;
if (!group->meth->field_mul(group, y, x, z, ctx))
goto err;
diff --git a/crypto/ec/ecp_oct.c b/crypto/ec/ecp_oct.c
index b10947d714..68943e521e 100644
--- a/crypto/ec/ecp_oct.c
+++ b/crypto/ec/ecp_oct.c
@@ -28,11 +28,6 @@ int ossl_ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,
BIGNUM *tmp1, *tmp2, *x, *y;
int ret = 0;
-#ifndef FIPS_MODULE
- /* clear error queue */
- ERR_clear_error();
-#endif
-
if (ctx == NULL) {
ctx = new_ctx = BN_CTX_new_ex(group->libctx);
if (ctx == NULL)
@@ -106,21 +101,24 @@ int ossl_ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,
goto err;
}
+ ERR_set_mark();
if (!BN_mod_sqrt(y, tmp1, group->field, ctx)) {
#ifndef FIPS_MODULE
unsigned long err = ERR_peek_last_error();
if (ERR_GET_LIB(err) == ERR_LIB_BN
&& ERR_GET_REASON(err) == BN_R_NOT_A_SQUARE) {
- ERR_clear_error();
+ ERR_pop_to_mark();
ERR_raise(ERR_LIB_EC, EC_R_INVALID_COMPRESSED_POINT);
} else
#endif
{
+ ERR_clear_last_mark();
ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
}
goto err;
}
+ ERR_clear_last_mark();
if (y_bit != BN_is_odd(y)) {
if (BN_is_zero(y)) {