summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-11-21 15:03:56 +0000
committertb <>2024-11-21 15:03:56 +0000
commit047732fc7cf66381d8b22c9c5e20e3069994efa3 (patch)
treedeca96c16dc2e6983f2569d977da3ea9af17e30a /src/lib
parent4c4b392670e9a18150e22a1e4f41fce87c78e1ff (diff)
downloadopenbsd-047732fc7cf66381d8b22c9c5e20e3069994efa3.tar.gz
openbsd-047732fc7cf66381d8b22c9c5e20e3069994efa3.tar.bz2
openbsd-047732fc7cf66381d8b22c9c5e20e3069994efa3.zip
ec_wNAF_mul(): lose two levels of indentation
This makes the mess a bit more readable. ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/ec/ec_mult.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c
index e336cf0fac..8ef655690e 100644
--- a/src/lib/libcrypto/ec/ec_mult.c
+++ b/src/lib/libcrypto/ec/ec_mult.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_mult.c,v 1.36 2024/11/21 14:36:03 tb Exp $ */ 1/* $OpenBSD: ec_mult.c,v 1.37 2024/11/21 15:03:56 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project. 3 * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -371,27 +371,28 @@ ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *m,
371 goto err; 371 goto err;
372 372
373 for (i = 0; i < totalnum; i++) { 373 for (i = 0; i < totalnum; i++) {
374 if (wNAF_len[i] > (size_t) k) { 374 int digit;
375 int digit = wNAF[i][k]; 375 int is_neg = 0;
376 int is_neg;
377 376
378 if (digit) { 377 if (k >= wNAF_len[i])
379 is_neg = digit < 0; 378 continue;
380 379
381 if (is_neg) 380 if ((digit = wNAF[i][k]) == 0)
382 digit = -digit; 381 continue;
383 382
384 if (is_neg != r_is_inverted) { 383 if (digit < 0) {
385 if (!EC_POINT_invert(group, r, ctx)) 384 is_neg = 1;
386 goto err; 385 digit = 0 - digit;
387 r_is_inverted = !r_is_inverted; 386 }
388 }
389 /* digit > 0 */
390 387
391 if (!EC_POINT_add(group, r, r, val_sub[i][digit >> 1], ctx)) 388 if (is_neg != r_is_inverted) {
392 goto err; 389 if (!EC_POINT_invert(group, r, ctx))
393 } 390 goto err;
391 r_is_inverted = !r_is_inverted;
394 } 392 }
393
394 if (!EC_POINT_add(group, r, r, val_sub[i][digit >> 1], ctx))
395 goto err;
395 } 396 }
396 } 397 }
397 398