From bc591847e51645c65de8e7dd9927cade552c8ff6 Mon Sep 17 00:00:00 2001 From: jsing Date: Sat, 24 Jun 2023 16:10:23 +0000 Subject: [PATCH] Check for non-zero length rather than a zero value. This removes a data dependent timing path from BN_sqr(). ok tb@ --- lib/libcrypto/bn/bn_sqr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libcrypto/bn/bn_sqr.c b/lib/libcrypto/bn/bn_sqr.c index 4eab796c906..5f3be22304c 100644 --- a/lib/libcrypto/bn/bn_sqr.c +++ b/lib/libcrypto/bn/bn_sqr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_sqr.c,v 1.31 2023/06/24 16:01:43 jsing Exp $ */ +/* $OpenBSD: bn_sqr.c,v 1.32 2023/06/24 16:10:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -274,7 +274,7 @@ BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) BN_CTX_start(ctx); - if (BN_is_zero(a)) { + if (a->top < 1) { BN_zero(r); goto done; } -- 2.20.1