-/* $OpenBSD: bn_arch.h,v 1.5 2023/01/23 12:02:48 jsing Exp $ */
+/* $OpenBSD: bn_arch.h,v 1.6 2023/01/23 12:09:06 jsing Exp $ */
/*
* Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
*
#define HAVE_BN_SQR
#define HAVE_BN_SQR_COMBA4
#define HAVE_BN_SQR_COMBA8
+#define HAVE_BN_SQR_WORDS
#define HAVE_BN_SUB_WORDS
-/* $OpenBSD: bn_arch.h,v 1.4 2023/01/23 12:02:48 jsing Exp $ */
+/* $OpenBSD: bn_arch.h,v 1.5 2023/01/23 12:09:06 jsing Exp $ */
/*
* Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
*
#define HAVE_BN_SQR_COMBA4
#define HAVE_BN_SQR_COMBA8
+#define HAVE_BN_SQR_WORDS
#define HAVE_BN_SUB_WORDS
-/* $OpenBSD: bn_arch.h,v 1.5 2023/01/23 12:02:48 jsing Exp $ */
+/* $OpenBSD: bn_arch.h,v 1.6 2023/01/23 12:09:06 jsing Exp $ */
/*
* Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
*
#define HAVE_BN_SQR_COMBA4
#define HAVE_BN_SQR_COMBA8
+#define HAVE_BN_SQR_WORDS
#define HAVE_BN_SUB_WORDS
-/* $OpenBSD: bn_arch.h,v 1.4 2023/01/23 12:02:48 jsing Exp $ */
+/* $OpenBSD: bn_arch.h,v 1.5 2023/01/23 12:09:06 jsing Exp $ */
/*
* Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
*
#define HAVE_BN_SQR_COMBA4
#define HAVE_BN_SQR_COMBA8
+#define HAVE_BN_SQR_WORDS
#define HAVE_BN_SUB_WORDS
-/* $OpenBSD: bn_arch.h,v 1.4 2023/01/23 12:02:48 jsing Exp $ */
+/* $OpenBSD: bn_arch.h,v 1.5 2023/01/23 12:09:06 jsing Exp $ */
/*
* Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
*
#define HAVE_BN_SQR_COMBA4
#define HAVE_BN_SQR_COMBA8
+#define HAVE_BN_SQR_WORDS
#define HAVE_BN_SUB_WORDS
-/* $OpenBSD: bn_asm.c,v 1.21 2023/01/23 12:02:48 jsing Exp $ */
+/* $OpenBSD: bn_asm.c,v 1.22 2023/01/23 12:09:06 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
return (c1);
}
-void
-bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
-{
- assert(n >= 0);
- if (n <= 0)
- return;
-
-#ifndef OPENSSL_SMALL_FOOTPRINT
- while (n & ~3) {
- sqr(r[0], r[1], a[0]);
- sqr(r[2], r[3], a[1]);
- sqr(r[4], r[5], a[2]);
- sqr(r[6], r[7], a[3]);
- a += 4;
- r += 8;
- n -= 4;
- }
-#endif
- while (n) {
- sqr(r[0], r[1], a[0]);
- a++;
- r += 2;
- n--;
- }
-}
-
#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
BN_ULONG
return (carry);
}
-void
-bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
-{
- assert(n >= 0);
- if (n <= 0)
- return;
-
-#ifndef OPENSSL_SMALL_FOOTPRINT
- while (n & ~3) {
- sqr64(r[0], r[1], a[0]);
- sqr64(r[2], r[3], a[1]);
- sqr64(r[4], r[5], a[2]);
- sqr64(r[6], r[7], a[3]);
- a += 4;
- r += 8;
- n -= 4;
- }
-#endif
- while (n) {
- sqr64(r[0], r[1], a[0]);
- a++;
- r += 2;
- n--;
- }
-}
-
#endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
#if defined(BN_MUL_COMBA) && !defined(OPENSSL_SMALL_FOOTPRINT)
-/* $OpenBSD: bn_sqr.c,v 1.21 2023/01/21 14:10:46 jsing Exp $ */
+/* $OpenBSD: bn_sqr.c,v 1.22 2023/01/23 12:09:06 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* [including the GNU Public Licence.]
*/
+#include <assert.h>
#include <stdio.h>
#include <string.h>
}
#endif
+#ifndef HAVE_BN_SQR_WORDS
+#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
+void
+bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
+{
+ assert(n >= 0);
+ if (n <= 0)
+ return;
+
+#ifndef OPENSSL_SMALL_FOOTPRINT
+ while (n & ~3) {
+ sqr(r[0], r[1], a[0]);
+ sqr(r[2], r[3], a[1]);
+ sqr(r[4], r[5], a[2]);
+ sqr(r[6], r[7], a[3]);
+ a += 4;
+ r += 8;
+ n -= 4;
+ }
+#endif
+ while (n) {
+ sqr(r[0], r[1], a[0]);
+ a++;
+ r += 2;
+ n--;
+ }
+}
+#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
+void
+bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
+{
+ assert(n >= 0);
+ if (n <= 0)
+ return;
+
+#ifndef OPENSSL_SMALL_FOOTPRINT
+ while (n & ~3) {
+ sqr64(r[0], r[1], a[0]);
+ sqr64(r[2], r[3], a[1]);
+ sqr64(r[4], r[5], a[2]);
+ sqr64(r[6], r[7], a[3]);
+ a += 4;
+ r += 8;
+ n -= 4;
+ }
+#endif
+ while (n) {
+ sqr64(r[0], r[1], a[0]);
+ a++;
+ r += 2;
+ n--;
+ }
+}
+#endif
+#endif
+
/* tmp must have 2*n words */
void
bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)