From 88482f0a47d4b8537b1915105df160318515321b Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sat, 24 Jun 2023 17:06:54 +0000 Subject: Add conditional around bn_mul_words() call. At least one of our bn_mul_words() assembly implementation fails to handle n = 0 correctly... *sigh* --- src/lib/libcrypto/bn/bn_sqr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c index 56664e2e36..5ea1bd45b9 100644 --- a/src/lib/libcrypto/bn/bn_sqr.c +++ b/src/lib/libcrypto/bn/bn_sqr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_sqr.c,v 1.33 2023/06/24 16:19:52 jsing Exp $ */ +/* $OpenBSD: bn_sqr.c,v 1.34 2023/06/24 17:06:54 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -214,7 +214,9 @@ bn_sqr_normal(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, /* Compute initial product - r[n:1] = a[n:1] * a[0] */ n = a_len - 1; - rp[n] = bn_mul_words(rp, ap, n, w); + if (n > 0) { + rp[n] = bn_mul_words(rp, ap, n, w); + } rp += 2; n--; -- cgit v1.2.3-55-g6feb