summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/ecdsa/ecs_ossl.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c
index 3fd15f5f62..d7bd75b878 100644
--- a/src/lib/libcrypto/ecdsa/ecs_ossl.c
+++ b/src/lib/libcrypto/ecdsa/ecs_ossl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecs_ossl.c,v 1.40 2023/07/02 12:25:33 tb Exp $ */ 1/* $OpenBSD: ecs_ossl.c,v 1.41 2023/07/02 12:48:59 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project 3 * Written by Nils Larsch for the OpenSSL project
4 */ 4 */
@@ -124,7 +124,7 @@ int
124ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) 124ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
125{ 125{
126 BN_CTX *ctx = ctx_in; 126 BN_CTX *ctx = ctx_in;
127 BIGNUM *k = NULL, *r = NULL, *order = NULL, *X = NULL; 127 BIGNUM *k = NULL, *r = NULL, *order = NULL, *x = NULL;
128 EC_POINT *point = NULL; 128 EC_POINT *point = NULL;
129 const EC_GROUP *group; 129 const EC_GROUP *group;
130 int order_bits, ret = 0; 130 int order_bits, ret = 0;
@@ -142,7 +142,7 @@ ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp
142 } 142 }
143 143
144 if ((k = BN_new()) == NULL || (r = BN_new()) == NULL || 144 if ((k = BN_new()) == NULL || (r = BN_new()) == NULL ||
145 (order = BN_new()) == NULL || (X = BN_new()) == NULL) { 145 (order = BN_new()) == NULL || (x = BN_new()) == NULL) {
146 ECDSAerror(ERR_R_MALLOC_FAILURE); 146 ECDSAerror(ERR_R_MALLOC_FAILURE);
147 goto err; 147 goto err;
148 } 148 }
@@ -169,7 +169,7 @@ ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp
169 /* Preallocate space. */ 169 /* Preallocate space. */
170 if (!BN_set_bit(k, order_bits) || 170 if (!BN_set_bit(k, order_bits) ||
171 !BN_set_bit(r, order_bits) || 171 !BN_set_bit(r, order_bits) ||
172 !BN_set_bit(X, order_bits)) 172 !BN_set_bit(x, order_bits))
173 goto err; 173 goto err;
174 174
175 do { 175 do {
@@ -193,8 +193,8 @@ ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp
193 * conditional copy. 193 * conditional copy.
194 */ 194 */
195 if (!BN_add(r, k, order) || 195 if (!BN_add(r, k, order) ||
196 !BN_add(X, r, order) || 196 !BN_add(x, r, order) ||
197 !bn_copy(k, BN_num_bits(r) > order_bits ? r : X)) 197 !bn_copy(k, BN_num_bits(r) > order_bits ? r : x))
198 goto err; 198 goto err;
199 199
200 BN_set_flags(k, BN_FLG_CONSTTIME); 200 BN_set_flags(k, BN_FLG_CONSTTIME);
@@ -204,12 +204,12 @@ ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp
204 ECDSAerror(ERR_R_EC_LIB); 204 ECDSAerror(ERR_R_EC_LIB);
205 goto err; 205 goto err;
206 } 206 }
207 if (!EC_POINT_get_affine_coordinates(group, point, X, NULL, 207 if (!EC_POINT_get_affine_coordinates(group, point, x, NULL,
208 ctx)) { 208 ctx)) {
209 ECDSAerror(ERR_R_EC_LIB); 209 ECDSAerror(ERR_R_EC_LIB);
210 goto err; 210 goto err;
211 } 211 }
212 if (!BN_nnmod(r, X, order, ctx)) { 212 if (!BN_nnmod(r, x, order, ctx)) {
213 ECDSAerror(ERR_R_BN_LIB); 213 ECDSAerror(ERR_R_BN_LIB);
214 goto err; 214 goto err;
215 } 215 }
@@ -234,7 +234,7 @@ ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp
234 BN_CTX_free(ctx); 234 BN_CTX_free(ctx);
235 BN_free(order); 235 BN_free(order);
236 EC_POINT_free(point); 236 EC_POINT_free(point);
237 BN_free(X); 237 BN_free(x);
238 return (ret); 238 return (ret);
239} 239}
240 240
@@ -429,7 +429,7 @@ ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *
429 EC_KEY *eckey) 429 EC_KEY *eckey)
430{ 430{
431 BN_CTX *ctx; 431 BN_CTX *ctx;
432 BIGNUM *order, *u1, *u2, *m, *X; 432 BIGNUM *order, *u1, *u2, *m, *x;
433 EC_POINT *point = NULL; 433 EC_POINT *point = NULL;
434 const EC_GROUP *group; 434 const EC_GROUP *group;
435 const EC_POINT *pub_key; 435 const EC_POINT *pub_key;
@@ -450,8 +450,8 @@ ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *
450 u1 = BN_CTX_get(ctx); 450 u1 = BN_CTX_get(ctx);
451 u2 = BN_CTX_get(ctx); 451 u2 = BN_CTX_get(ctx);
452 m = BN_CTX_get(ctx); 452 m = BN_CTX_get(ctx);
453 X = BN_CTX_get(ctx); 453 x = BN_CTX_get(ctx);
454 if (X == NULL) { 454 if (x == NULL) {
455 ECDSAerror(ERR_R_BN_LIB); 455 ECDSAerror(ERR_R_BN_LIB);
456 goto err; 456 goto err;
457 } 457 }
@@ -496,11 +496,11 @@ ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *
496 ECDSAerror(ERR_R_EC_LIB); 496 ECDSAerror(ERR_R_EC_LIB);
497 goto err; 497 goto err;
498 } 498 }
499 if (!EC_POINT_get_affine_coordinates(group, point, X, NULL, ctx)) { 499 if (!EC_POINT_get_affine_coordinates(group, point, x, NULL, ctx)) {
500 ECDSAerror(ERR_R_EC_LIB); 500 ECDSAerror(ERR_R_EC_LIB);
501 goto err; 501 goto err;
502 } 502 }
503 if (!BN_nnmod(u1, X, order, ctx)) { 503 if (!BN_nnmod(u1, x, order, ctx)) {
504 ECDSAerror(ERR_R_BN_LIB); 504 ECDSAerror(ERR_R_BN_LIB);
505 goto err; 505 goto err;
506 } 506 }