summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_asm.c
diff options
context:
space:
mode:
authorjsing <>2023-01-23 12:17:58 +0000
committerjsing <>2023-01-23 12:17:58 +0000
commitfa7433bffa7c26069e9ca9d343af05899fc9aba5 (patch)
tree10c581cd8389dbcd504052384435cac542a3ce73 /src/lib/libcrypto/bn/bn_asm.c
parent4da0d188e0e1d972397bcdd91fcf1bd43d78d844 (diff)
downloadopenbsd-fa7433bffa7c26069e9ca9d343af05899fc9aba5.tar.gz
openbsd-fa7433bffa7c26069e9ca9d343af05899fc9aba5.tar.bz2
openbsd-fa7433bffa7c26069e9ca9d343af05899fc9aba5.zip
Move bn_mul_add_words() and bn_mul_words() from bn_asm.c to bn_mul.c.
These are wrapped with #ifndef HAVE_BN_ADD_MUL_WORDS/HAVE_BN_MUL_WORDS, which are defined for architectures that provide their own assembly versions.
Diffstat (limited to 'src/lib/libcrypto/bn/bn_asm.c')
-rw-r--r--src/lib/libcrypto/bn/bn_asm.c133
1 files changed, 1 insertions, 132 deletions
diff --git a/src/lib/libcrypto/bn/bn_asm.c b/src/lib/libcrypto/bn/bn_asm.c
index 143c939367..e2b584ee85 100644
--- a/src/lib/libcrypto/bn/bn_asm.c
+++ b/src/lib/libcrypto/bn/bn_asm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_asm.c,v 1.22 2023/01/23 12:09:06 jsing Exp $ */ 1/* $OpenBSD: bn_asm.c,v 1.23 2023/01/23 12:17:57 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 *
@@ -63,137 +63,6 @@
63 63
64#include "bn_local.h" 64#include "bn_local.h"
65 65
66#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
67
68BN_ULONG
69bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
70{
71 BN_ULONG c1 = 0;
72
73 assert(num >= 0);
74 if (num <= 0)
75 return (c1);
76
77#ifndef OPENSSL_SMALL_FOOTPRINT
78 while (num & ~3) {
79 mul_add(rp[0], ap[0], w, c1);
80 mul_add(rp[1], ap[1], w, c1);
81 mul_add(rp[2], ap[2], w, c1);
82 mul_add(rp[3], ap[3], w, c1);
83 ap += 4;
84 rp += 4;
85 num -= 4;
86 }
87#endif
88 while (num) {
89 mul_add(rp[0], ap[0], w, c1);
90 ap++;
91 rp++;
92 num--;
93 }
94
95 return (c1);
96}
97
98BN_ULONG
99bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
100{
101 BN_ULONG c1 = 0;
102
103 assert(num >= 0);
104 if (num <= 0)
105 return (c1);
106
107#ifndef OPENSSL_SMALL_FOOTPRINT
108 while (num & ~3) {
109 mul(rp[0], ap[0], w, c1);
110 mul(rp[1], ap[1], w, c1);
111 mul(rp[2], ap[2], w, c1);
112 mul(rp[3], ap[3], w, c1);
113 ap += 4;
114 rp += 4;
115 num -= 4;
116 }
117#endif
118 while (num) {
119 mul(rp[0], ap[0], w, c1);
120 ap++;
121 rp++;
122 num--;
123 }
124 return (c1);
125}
126
127#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
128
129BN_ULONG
130bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
131{
132 BN_ULONG c = 0;
133 BN_ULONG bl, bh;
134
135 assert(num >= 0);
136 if (num <= 0)
137 return ((BN_ULONG)0);
138
139 bl = LBITS(w);
140 bh = HBITS(w);
141
142#ifndef OPENSSL_SMALL_FOOTPRINT
143 while (num & ~3) {
144 mul_add(rp[0], ap[0], bl, bh, c);
145 mul_add(rp[1], ap[1], bl, bh, c);
146 mul_add(rp[2], ap[2], bl, bh, c);
147 mul_add(rp[3], ap[3], bl, bh, c);
148 ap += 4;
149 rp += 4;
150 num -= 4;
151 }
152#endif
153 while (num) {
154 mul_add(rp[0], ap[0], bl, bh, c);
155 ap++;
156 rp++;
157 num--;
158 }
159 return (c);
160}
161
162BN_ULONG
163bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
164{
165 BN_ULONG carry = 0;
166 BN_ULONG bl, bh;
167
168 assert(num >= 0);
169 if (num <= 0)
170 return ((BN_ULONG)0);
171
172 bl = LBITS(w);
173 bh = HBITS(w);
174
175#ifndef OPENSSL_SMALL_FOOTPRINT
176 while (num & ~3) {
177 mul(rp[0], ap[0], bl, bh, carry);
178 mul(rp[1], ap[1], bl, bh, carry);
179 mul(rp[2], ap[2], bl, bh, carry);
180 mul(rp[3], ap[3], bl, bh, carry);
181 ap += 4;
182 rp += 4;
183 num -= 4;
184 }
185#endif
186 while (num) {
187 mul(rp[0], ap[0], bl, bh, carry);
188 ap++;
189 rp++;
190 num--;
191 }
192 return (carry);
193}
194
195#endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
196
197#if defined(BN_MUL_COMBA) && !defined(OPENSSL_SMALL_FOOTPRINT) 66#if defined(BN_MUL_COMBA) && !defined(OPENSSL_SMALL_FOOTPRINT)
198 67
199#ifdef OPENSSL_NO_ASM 68#ifdef OPENSSL_NO_ASM