summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_sqr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn_sqr.c')
-rw-r--r--src/lib/libcrypto/bn/bn_sqr.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c
index ff254764e3..74d5eded94 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.21 2023/01/21 14:10:46 jsing Exp $ */ 1/* $OpenBSD: bn_sqr.c,v 1.22 2023/01/23 12:09:06 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 *
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <assert.h>
59#include <stdio.h> 60#include <stdio.h>
60#include <string.h> 61#include <string.h>
61 62
@@ -178,6 +179,62 @@ bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)
178} 179}
179#endif 180#endif
180 181
182#ifndef HAVE_BN_SQR_WORDS
183#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
184void
185bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
186{
187 assert(n >= 0);
188 if (n <= 0)
189 return;
190
191#ifndef OPENSSL_SMALL_FOOTPRINT
192 while (n & ~3) {
193 sqr(r[0], r[1], a[0]);
194 sqr(r[2], r[3], a[1]);
195 sqr(r[4], r[5], a[2]);
196 sqr(r[6], r[7], a[3]);
197 a += 4;
198 r += 8;
199 n -= 4;
200 }
201#endif
202 while (n) {
203 sqr(r[0], r[1], a[0]);
204 a++;
205 r += 2;
206 n--;
207 }
208}
209#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
210void
211bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
212{
213 assert(n >= 0);
214 if (n <= 0)
215 return;
216
217#ifndef OPENSSL_SMALL_FOOTPRINT
218 while (n & ~3) {
219 sqr64(r[0], r[1], a[0]);
220 sqr64(r[2], r[3], a[1]);
221 sqr64(r[4], r[5], a[2]);
222 sqr64(r[6], r[7], a[3]);
223 a += 4;
224 r += 8;
225 n -= 4;
226 }
227#endif
228 while (n) {
229 sqr64(r[0], r[1], a[0]);
230 a++;
231 r += 2;
232 n--;
233 }
234}
235#endif
236#endif
237
181/* tmp must have 2*n words */ 238/* tmp must have 2*n words */
182void 239void
183bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp) 240bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)