diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2022-11-24 01:30:02 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2022-11-24 01:30:02 +0000 |
commit | a17d9a15280536a190ca160e9343c08f16a068cd (patch) | |
tree | 2cd6fbe4886639f989f2ca063a36126d90bd1bf1 /lib/libcrypto/ec | |
parent | 9e99c6a2c66b10a6040db1d11288088c59910c58 (diff) |
Change bn_expand()/bn_wexpand() to indicate failure/success via 0/1.
Currently bn_expand()/bn_wexpand() return a BIGNUM *, however none of the
callers use this (and many already treat it as a true/false value).
Change these functions to return 0 on failure and 1 on success, revising
callers that test against NULL in the process.
ok tb@
Diffstat (limited to 'lib/libcrypto/ec')
-rw-r--r-- | lib/libcrypto/ec/ec2_smpl.c | 10 | ||||
-rw-r--r-- | lib/libcrypto/ec/ecp_nistz256.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/ec/ecp_smpl.c | 18 |
3 files changed, 16 insertions, 16 deletions
diff --git a/lib/libcrypto/ec/ec2_smpl.c b/lib/libcrypto/ec/ec2_smpl.c index b6c06a45a20..b4d7f5db2e8 100644 --- a/lib/libcrypto/ec/ec2_smpl.c +++ b/lib/libcrypto/ec/ec2_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_smpl.c,v 1.26 2022/11/24 01:24:37 jsing Exp $ */ +/* $OpenBSD: ec2_smpl.c,v 1.27 2022/11/24 01:30:01 jsing Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -186,9 +186,9 @@ ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) dest->poly[3] = src->poly[3]; dest->poly[4] = src->poly[4]; dest->poly[5] = src->poly[5]; - if (bn_expand(&dest->a, dest->poly[0]) == NULL) + if (!bn_expand(&dest->a, dest->poly[0])) return 0; - if (bn_expand(&dest->b, dest->poly[0]) == NULL) + if (!bn_expand(&dest->b, dest->poly[0])) return 0; for (i = dest->a.top; i < dest->a.dmax; i++) dest->a.d[i] = 0; @@ -216,7 +216,7 @@ ec_GF2m_simple_group_set_curve(EC_GROUP *group, /* group->a */ if (!BN_GF2m_mod_arr(&group->a, a, group->poly)) goto err; - if (bn_expand(&group->a, group->poly[0]) == NULL) + if (!bn_expand(&group->a, group->poly[0])) goto err; for (i = group->a.top; i < group->a.dmax; i++) group->a.d[i] = 0; @@ -224,7 +224,7 @@ ec_GF2m_simple_group_set_curve(EC_GROUP *group, /* group->b */ if (!BN_GF2m_mod_arr(&group->b, b, group->poly)) goto err; - if (bn_expand(&group->b, group->poly[0]) == NULL) + if (!bn_expand(&group->b, group->poly[0])) goto err; for (i = group->b.top; i < group->b.dmax; i++) group->b.d[i] = 0; diff --git a/lib/libcrypto/ec/ecp_nistz256.c b/lib/libcrypto/ec/ecp_nistz256.c index e4929b92bbb..e3a6cc855a7 100644 --- a/lib/libcrypto/ec/ecp_nistz256.c +++ b/lib/libcrypto/ec/ecp_nistz256.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistz256.c,v 1.12 2022/11/19 07:00:57 tb Exp $ */ +/* $OpenBSD: ecp_nistz256.c,v 1.13 2022/11/24 01:30:01 jsing Exp $ */ /* Copyright (c) 2014, Intel Corporation. * * Permission to use, copy, modify, and/or distribute this software for any @@ -310,7 +310,7 @@ is_one(const BIGNUM *z) static int ecp_nistz256_set_words(BIGNUM *a, BN_ULONG words[P256_LIMBS]) { - if (bn_wexpand(a, P256_LIMBS) == NULL) { + if (!bn_wexpand(a, P256_LIMBS)) { ECerror(ERR_R_MALLOC_FAILURE); return 0; } diff --git a/lib/libcrypto/ec/ecp_smpl.c b/lib/libcrypto/ec/ecp_smpl.c index 55fb46869db..71d403b8548 100644 --- a/lib/libcrypto/ec/ecp_smpl.c +++ b/lib/libcrypto/ec/ecp_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_smpl.c,v 1.36 2022/11/19 07:29:29 tb Exp $ */ +/* $OpenBSD: ecp_smpl.c,v 1.37 2022/11/24 01:30:01 jsing Exp $ */ /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -1556,8 +1556,8 @@ ec_GFp_simple_mul_ct(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, */ cardinality_bits = BN_num_bits(cardinality); group_top = cardinality->top; - if ((bn_wexpand(k, group_top + 2) == NULL) || - (bn_wexpand(lambda, group_top + 2) == NULL)) + if (!bn_wexpand(k, group_top + 2) || + !bn_wexpand(lambda, group_top + 2)) goto err; if (!BN_copy(k, scalar)) @@ -1588,12 +1588,12 @@ ec_GFp_simple_mul_ct(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, goto err; group_top = group->field.top; - if ((bn_wexpand(&s->X, group_top) == NULL) || - (bn_wexpand(&s->Y, group_top) == NULL) || - (bn_wexpand(&s->Z, group_top) == NULL) || - (bn_wexpand(&r->X, group_top) == NULL) || - (bn_wexpand(&r->Y, group_top) == NULL) || - (bn_wexpand(&r->Z, group_top) == NULL)) + if (!bn_wexpand(&s->X, group_top) || + !bn_wexpand(&s->Y, group_top) || + !bn_wexpand(&s->Z, group_top) || + !bn_wexpand(&r->X, group_top) || + !bn_wexpand(&r->Y, group_top) || + !bn_wexpand(&r->Z, group_top)) goto err; /* |