summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2023-06-24 16:10:23 +0000
committerjsing <>2023-06-24 16:10:23 +0000
commit14594075895390dd7aac69fd2c11f65ca275ad4e (patch)
treec1885ab6f54f8998af91385a864e232bef49b830
parent7d512d54bfa4ced3119d0fe31adc99aa92bbc6ea (diff)
downloadopenbsd-14594075895390dd7aac69fd2c11f65ca275ad4e.tar.gz
openbsd-14594075895390dd7aac69fd2c11f65ca275ad4e.tar.bz2
openbsd-14594075895390dd7aac69fd2c11f65ca275ad4e.zip
Check for non-zero length rather than a zero value.
This removes a data dependent timing path from BN_sqr(). ok tb@
-rw-r--r--src/lib/libcrypto/bn/bn_sqr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c
index 4eab796c90..5f3be22304 100644
--- a/src/lib/libcrypto/bn/bn_sqr.c
+++ b/src/lib/libcrypto/bn/bn_sqr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_sqr.c,v 1.31 2023/06/24 16:01:43 jsing Exp $ */ 1/* $OpenBSD: bn_sqr.c,v 1.32 2023/06/24 16:10:23 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -274,7 +274,7 @@ BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
274 274
275 BN_CTX_start(ctx); 275 BN_CTX_start(ctx);
276 276
277 if (BN_is_zero(a)) { 277 if (a->top < 1) {
278 BN_zero(r); 278 BN_zero(r);
279 goto done; 279 goto done;
280 } 280 }