summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2023-06-24 17:06:54 +0000
committerjsing <>2023-06-24 17:06:54 +0000
commit88482f0a47d4b8537b1915105df160318515321b (patch)
tree2ff172c30d92e33b53f4881509f918ed7bbe3107
parent83f48b75515222b3e27dc71507e77779306f1629 (diff)
downloadopenbsd-88482f0a47d4b8537b1915105df160318515321b.tar.gz
openbsd-88482f0a47d4b8537b1915105df160318515321b.tar.bz2
openbsd-88482f0a47d4b8537b1915105df160318515321b.zip
Add conditional around bn_mul_words() call.
At least one of our bn_mul_words() assembly implementation fails to handle n = 0 correctly... *sigh*
-rw-r--r--src/lib/libcrypto/bn/bn_sqr.c6
1 files 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 @@
1/* $OpenBSD: bn_sqr.c,v 1.33 2023/06/24 16:19:52 jsing Exp $ */ 1/* $OpenBSD: bn_sqr.c,v 1.34 2023/06/24 17:06:54 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 *
@@ -214,7 +214,9 @@ bn_sqr_normal(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len,
214 214
215 /* Compute initial product - r[n:1] = a[n:1] * a[0] */ 215 /* Compute initial product - r[n:1] = a[n:1] * a[0] */
216 n = a_len - 1; 216 n = a_len - 1;
217 rp[n] = bn_mul_words(rp, ap, n, w); 217 if (n > 0) {
218 rp[n] = bn_mul_words(rp, ap, n, w);
219 }
218 rp += 2; 220 rp += 2;
219 n--; 221 n--;
220 222