diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bn_arch.c | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bn_arch.h | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/i386/bn_arch.h | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/mips64/bn_arch.h | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/arch/powerpc/bn_arch.h | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/asm/bn-586.pl | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/asm/mips.pl | 64 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/asm/ppc.pl | 20 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_div.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_local.h | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_mont.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_mul.c | 67 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_sqr.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_word.c | 4 |
14 files changed, 106 insertions, 111 deletions
diff --git a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c index e4fbb4cfc3..ef8eeadec2 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c +++ b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_arch.c,v 1.13 2025/08/30 07:16:06 jsing Exp $ */ | 1 | /* $OpenBSD: bn_arch.c,v 1.14 2025/08/30 07:54:27 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -81,17 +81,17 @@ bn_mod_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, | |||
81 | } | 81 | } |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | #ifdef HAVE_BN_MUL_ADD_WORDS | 84 | #ifdef HAVE_BN_MULW_ADD_WORDS |
85 | BN_ULONG | 85 | BN_ULONG |
86 | bn_mul_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) | 86 | bn_mulw_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) |
87 | { | 87 | { |
88 | return bignum_cmadd(num, (uint64_t *)rd, w, num, (const uint64_t *)ad); | 88 | return bignum_cmadd(num, (uint64_t *)rd, w, num, (const uint64_t *)ad); |
89 | } | 89 | } |
90 | #endif | 90 | #endif |
91 | 91 | ||
92 | #ifdef HAVE_BN_MUL_WORDS | 92 | #ifdef HAVE_BN_MULW_WORDS |
93 | BN_ULONG | 93 | BN_ULONG |
94 | bn_mul_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) | 94 | bn_mulw_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) |
95 | { | 95 | { |
96 | return bignum_cmul(num, (uint64_t *)rd, w, num, (const uint64_t *)ad); | 96 | return bignum_cmul(num, (uint64_t *)rd, w, num, (const uint64_t *)ad); |
97 | } | 97 | } |
diff --git a/src/lib/libcrypto/bn/arch/amd64/bn_arch.h b/src/lib/libcrypto/bn/arch/amd64/bn_arch.h index dd7abd3002..f42c6bc201 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bn_arch.h +++ b/src/lib/libcrypto/bn/arch/amd64/bn_arch.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_arch.h,v 1.17 2025/08/30 07:16:06 jsing Exp $ */ | 1 | /* $OpenBSD: bn_arch.h,v 1.18 2025/08/30 07:54:27 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -30,11 +30,11 @@ | |||
30 | #define HAVE_BN_MOD_ADD_WORDS | 30 | #define HAVE_BN_MOD_ADD_WORDS |
31 | #define HAVE_BN_MOD_SUB_WORDS | 31 | #define HAVE_BN_MOD_SUB_WORDS |
32 | 32 | ||
33 | #define HAVE_BN_MUL_ADD_WORDS | ||
34 | #define HAVE_BN_MUL_COMBA4 | 33 | #define HAVE_BN_MUL_COMBA4 |
35 | #define HAVE_BN_MUL_COMBA6 | 34 | #define HAVE_BN_MUL_COMBA6 |
36 | #define HAVE_BN_MUL_COMBA8 | 35 | #define HAVE_BN_MUL_COMBA8 |
37 | #define HAVE_BN_MUL_WORDS | 36 | #define HAVE_BN_MULW_ADD_WORDS |
37 | #define HAVE_BN_MULW_WORDS | ||
38 | 38 | ||
39 | #define HAVE_BN_SQR_COMBA4 | 39 | #define HAVE_BN_SQR_COMBA4 |
40 | #define HAVE_BN_SQR_COMBA6 | 40 | #define HAVE_BN_SQR_COMBA6 |
diff --git a/src/lib/libcrypto/bn/arch/i386/bn_arch.h b/src/lib/libcrypto/bn/arch/i386/bn_arch.h index eef519fcc7..79f7345b8b 100644 --- a/src/lib/libcrypto/bn/arch/i386/bn_arch.h +++ b/src/lib/libcrypto/bn/arch/i386/bn_arch.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_arch.h,v 1.9 2023/02/16 10:41:03 jsing Exp $ */ | 1 | /* $OpenBSD: bn_arch.h,v 1.10 2025/08/30 07:54:27 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -26,10 +26,10 @@ | |||
26 | 26 | ||
27 | #define HAVE_BN_DIV_WORDS | 27 | #define HAVE_BN_DIV_WORDS |
28 | 28 | ||
29 | #define HAVE_BN_MUL_ADD_WORDS | ||
30 | #define HAVE_BN_MUL_COMBA4 | 29 | #define HAVE_BN_MUL_COMBA4 |
31 | #define HAVE_BN_MUL_COMBA8 | 30 | #define HAVE_BN_MUL_COMBA8 |
32 | #define HAVE_BN_MUL_WORDS | 31 | #define HAVE_BN_MULW_ADD_WORDS |
32 | #define HAVE_BN_MULW_WORDS | ||
33 | 33 | ||
34 | #define HAVE_BN_SQR_COMBA4 | 34 | #define HAVE_BN_SQR_COMBA4 |
35 | #define HAVE_BN_SQR_COMBA8 | 35 | #define HAVE_BN_SQR_COMBA8 |
diff --git a/src/lib/libcrypto/bn/arch/mips64/bn_arch.h b/src/lib/libcrypto/bn/arch/mips64/bn_arch.h index 53771bce1e..b7714c7d72 100644 --- a/src/lib/libcrypto/bn/arch/mips64/bn_arch.h +++ b/src/lib/libcrypto/bn/arch/mips64/bn_arch.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_arch.h,v 1.7 2023/01/23 12:17:58 jsing Exp $ */ | 1 | /* $OpenBSD: bn_arch.h,v 1.8 2025/08/30 07:54:27 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -25,10 +25,10 @@ | |||
25 | #define HAVE_BN_DIV_WORDS | 25 | #define HAVE_BN_DIV_WORDS |
26 | #define HAVE_BN_DIV_3_WORDS | 26 | #define HAVE_BN_DIV_3_WORDS |
27 | 27 | ||
28 | #define HAVE_BN_MUL_ADD_WORDS | ||
29 | #define HAVE_BN_MUL_COMBA4 | 28 | #define HAVE_BN_MUL_COMBA4 |
30 | #define HAVE_BN_MUL_COMBA8 | 29 | #define HAVE_BN_MUL_COMBA8 |
31 | #define HAVE_BN_MUL_WORDS | 30 | #define HAVE_BN_MULW_ADD_WORDS |
31 | #define HAVE_BN_MULW_WORDS | ||
32 | 32 | ||
33 | #define HAVE_BN_SQR_COMBA4 | 33 | #define HAVE_BN_SQR_COMBA4 |
34 | #define HAVE_BN_SQR_COMBA8 | 34 | #define HAVE_BN_SQR_COMBA8 |
diff --git a/src/lib/libcrypto/bn/arch/powerpc/bn_arch.h b/src/lib/libcrypto/bn/arch/powerpc/bn_arch.h index 46e932a2d5..fdddedaf4f 100644 --- a/src/lib/libcrypto/bn/arch/powerpc/bn_arch.h +++ b/src/lib/libcrypto/bn/arch/powerpc/bn_arch.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_arch.h,v 1.6 2023/01/23 12:17:58 jsing Exp $ */ | 1 | /* $OpenBSD: bn_arch.h,v 1.7 2025/08/30 07:54:27 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -24,10 +24,10 @@ | |||
24 | 24 | ||
25 | #define HAVE_BN_DIV_WORDS | 25 | #define HAVE_BN_DIV_WORDS |
26 | 26 | ||
27 | #define HAVE_BN_MUL_ADD_WORDS | ||
28 | #define HAVE_BN_MUL_COMBA4 | 27 | #define HAVE_BN_MUL_COMBA4 |
29 | #define HAVE_BN_MUL_COMBA8 | 28 | #define HAVE_BN_MUL_COMBA8 |
30 | #define HAVE_BN_MUL_WORDS | 29 | #define HAVE_BN_MULW_ADD_WORDS |
30 | #define HAVE_BN_MULW_WORDS | ||
31 | 31 | ||
32 | #define HAVE_BN_SQR_COMBA4 | 32 | #define HAVE_BN_SQR_COMBA4 |
33 | #define HAVE_BN_SQR_COMBA8 | 33 | #define HAVE_BN_SQR_COMBA8 |
diff --git a/src/lib/libcrypto/bn/asm/bn-586.pl b/src/lib/libcrypto/bn/asm/bn-586.pl index 19a1afdbbe..7f550b3b7c 100644 --- a/src/lib/libcrypto/bn/asm/bn-586.pl +++ b/src/lib/libcrypto/bn/asm/bn-586.pl | |||
@@ -10,8 +10,8 @@ $sse2=1; | |||
10 | 10 | ||
11 | &external_label("OPENSSL_ia32cap_P") if ($sse2); | 11 | &external_label("OPENSSL_ia32cap_P") if ($sse2); |
12 | 12 | ||
13 | &bn_mul_add_words("bn_mul_add_words"); | 13 | &bn_mulw_add_words("bn_mulw_add_words"); |
14 | &bn_mul_words("bn_mul_words"); | 14 | &bn_mulw_words("bn_mulw_words"); |
15 | &bn_sqr_words("bn_sqr_words"); | 15 | &bn_sqr_words("bn_sqr_words"); |
16 | &bn_div_words("bn_div_words"); | 16 | &bn_div_words("bn_div_words"); |
17 | &bn_add_words("bn_add_words"); | 17 | &bn_add_words("bn_add_words"); |
@@ -19,7 +19,7 @@ $sse2=1; | |||
19 | 19 | ||
20 | &asm_finish(); | 20 | &asm_finish(); |
21 | 21 | ||
22 | sub bn_mul_add_words | 22 | sub bn_mulw_add_words |
23 | { | 23 | { |
24 | local($name)=@_; | 24 | local($name)=@_; |
25 | 25 | ||
@@ -206,7 +206,7 @@ sub bn_mul_add_words | |||
206 | &function_end($name); | 206 | &function_end($name); |
207 | } | 207 | } |
208 | 208 | ||
209 | sub bn_mul_words | 209 | sub bn_mulw_words |
210 | { | 210 | { |
211 | local($name)=@_; | 211 | local($name)=@_; |
212 | 212 | ||
diff --git a/src/lib/libcrypto/bn/asm/mips.pl b/src/lib/libcrypto/bn/asm/mips.pl index 02d43e15b0..378af371e7 100644 --- a/src/lib/libcrypto/bn/asm/mips.pl +++ b/src/lib/libcrypto/bn/asm/mips.pl | |||
@@ -110,19 +110,19 @@ $code.=<<___; | |||
110 | .set noat | 110 | .set noat |
111 | 111 | ||
112 | .align 5 | 112 | .align 5 |
113 | .globl bn_mul_add_words | 113 | .globl bn_mulw_add_words |
114 | .ent bn_mul_add_words | 114 | .ent bn_mulw_add_words |
115 | bn_mul_add_words: | 115 | bn_mulw_add_words: |
116 | .set noreorder | 116 | .set noreorder |
117 | bgtz $a2,bn_mul_add_words_internal | 117 | bgtz $a2,bn_mulw_add_words_internal |
118 | move $v0,$zero | 118 | move $v0,$zero |
119 | jr $ra | 119 | jr $ra |
120 | move $a0,$v0 | 120 | move $a0,$v0 |
121 | .end bn_mul_add_words | 121 | .end bn_mulw_add_words |
122 | 122 | ||
123 | .align 5 | 123 | .align 5 |
124 | .ent bn_mul_add_words_internal | 124 | .ent bn_mulw_add_words_internal |
125 | bn_mul_add_words_internal: | 125 | bn_mulw_add_words_internal: |
126 | ___ | 126 | ___ |
127 | $code.=<<___ if ($flavour =~ /nubi/i); | 127 | $code.=<<___ if ($flavour =~ /nubi/i); |
128 | .frame $sp,6*$SZREG,$ra | 128 | .frame $sp,6*$SZREG,$ra |
@@ -140,9 +140,9 @@ $code.=<<___; | |||
140 | .set reorder | 140 | .set reorder |
141 | li $minus4,-4 | 141 | li $minus4,-4 |
142 | and $ta0,$a2,$minus4 | 142 | and $ta0,$a2,$minus4 |
143 | beqz $ta0,.L_bn_mul_add_words_tail | 143 | beqz $ta0,.L_bn_mulw_add_words_tail |
144 | 144 | ||
145 | .L_bn_mul_add_words_loop: | 145 | .L_bn_mulw_add_words_loop: |
146 | $LD $t0,0($a1) | 146 | $LD $t0,0($a1) |
147 | $MULTU $t0,$a3 | 147 | $MULTU $t0,$a3 |
148 | $LD $t1,0($a0) | 148 | $LD $t1,0($a0) |
@@ -201,13 +201,13 @@ $code.=<<___; | |||
201 | sltu $at,$ta3,$at | 201 | sltu $at,$ta3,$at |
202 | $ST $ta3,-$BNSZ($a0) | 202 | $ST $ta3,-$BNSZ($a0) |
203 | .set noreorder | 203 | .set noreorder |
204 | bgtz $ta0,.L_bn_mul_add_words_loop | 204 | bgtz $ta0,.L_bn_mulw_add_words_loop |
205 | $ADDU $v0,$at | 205 | $ADDU $v0,$at |
206 | 206 | ||
207 | beqz $a2,.L_bn_mul_add_words_return | 207 | beqz $a2,.L_bn_mulw_add_words_return |
208 | nop | 208 | nop |
209 | 209 | ||
210 | .L_bn_mul_add_words_tail: | 210 | .L_bn_mulw_add_words_tail: |
211 | .set reorder | 211 | .set reorder |
212 | $LD $t0,0($a1) | 212 | $LD $t0,0($a1) |
213 | $MULTU $t0,$a3 | 213 | $MULTU $t0,$a3 |
@@ -222,7 +222,7 @@ $code.=<<___; | |||
222 | sltu $at,$t1,$at | 222 | sltu $at,$t1,$at |
223 | $ST $t1,0($a0) | 223 | $ST $t1,0($a0) |
224 | $ADDU $v0,$at | 224 | $ADDU $v0,$at |
225 | beqz $a2,.L_bn_mul_add_words_return | 225 | beqz $a2,.L_bn_mulw_add_words_return |
226 | 226 | ||
227 | $LD $t0,$BNSZ($a1) | 227 | $LD $t0,$BNSZ($a1) |
228 | $MULTU $t0,$a3 | 228 | $MULTU $t0,$a3 |
@@ -237,7 +237,7 @@ $code.=<<___; | |||
237 | sltu $at,$t1,$at | 237 | sltu $at,$t1,$at |
238 | $ST $t1,$BNSZ($a0) | 238 | $ST $t1,$BNSZ($a0) |
239 | $ADDU $v0,$at | 239 | $ADDU $v0,$at |
240 | beqz $a2,.L_bn_mul_add_words_return | 240 | beqz $a2,.L_bn_mulw_add_words_return |
241 | 241 | ||
242 | $LD $t0,2*$BNSZ($a1) | 242 | $LD $t0,2*$BNSZ($a1) |
243 | $MULTU $t0,$a3 | 243 | $MULTU $t0,$a3 |
@@ -252,7 +252,7 @@ $code.=<<___; | |||
252 | $ST $t1,2*$BNSZ($a0) | 252 | $ST $t1,2*$BNSZ($a0) |
253 | $ADDU $v0,$at | 253 | $ADDU $v0,$at |
254 | 254 | ||
255 | .L_bn_mul_add_words_return: | 255 | .L_bn_mulw_add_words_return: |
256 | .set noreorder | 256 | .set noreorder |
257 | ___ | 257 | ___ |
258 | $code.=<<___ if ($flavour =~ /nubi/i); | 258 | $code.=<<___ if ($flavour =~ /nubi/i); |
@@ -266,22 +266,22 @@ ___ | |||
266 | $code.=<<___; | 266 | $code.=<<___; |
267 | jr $ra | 267 | jr $ra |
268 | move $a0,$v0 | 268 | move $a0,$v0 |
269 | .end bn_mul_add_words_internal | 269 | .end bn_mulw_add_words_internal |
270 | 270 | ||
271 | .align 5 | 271 | .align 5 |
272 | .globl bn_mul_words | 272 | .globl bn_mulw_words |
273 | .ent bn_mul_words | 273 | .ent bn_mulw_words |
274 | bn_mul_words: | 274 | bn_mulw_words: |
275 | .set noreorder | 275 | .set noreorder |
276 | bgtz $a2,bn_mul_words_internal | 276 | bgtz $a2,bn_mulw_words_internal |
277 | move $v0,$zero | 277 | move $v0,$zero |
278 | jr $ra | 278 | jr $ra |
279 | move $a0,$v0 | 279 | move $a0,$v0 |
280 | .end bn_mul_words | 280 | .end bn_mulw_words |
281 | 281 | ||
282 | .align 5 | 282 | .align 5 |
283 | .ent bn_mul_words_internal | 283 | .ent bn_mulw_words_internal |
284 | bn_mul_words_internal: | 284 | bn_mulw_words_internal: |
285 | ___ | 285 | ___ |
286 | $code.=<<___ if ($flavour =~ /nubi/i); | 286 | $code.=<<___ if ($flavour =~ /nubi/i); |
287 | .frame $sp,6*$SZREG,$ra | 287 | .frame $sp,6*$SZREG,$ra |
@@ -299,9 +299,9 @@ $code.=<<___; | |||
299 | .set reorder | 299 | .set reorder |
300 | li $minus4,-4 | 300 | li $minus4,-4 |
301 | and $ta0,$a2,$minus4 | 301 | and $ta0,$a2,$minus4 |
302 | beqz $ta0,.L_bn_mul_words_tail | 302 | beqz $ta0,.L_bn_mulw_words_tail |
303 | 303 | ||
304 | .L_bn_mul_words_loop: | 304 | .L_bn_mulw_words_loop: |
305 | $LD $t0,0($a1) | 305 | $LD $t0,0($a1) |
306 | $MULTU $t0,$a3 | 306 | $MULTU $t0,$a3 |
307 | $LD $t2,$BNSZ($a1) | 307 | $LD $t2,$BNSZ($a1) |
@@ -341,13 +341,13 @@ $code.=<<___; | |||
341 | sltu $ta3,$v0,$at | 341 | sltu $ta3,$v0,$at |
342 | $ST $v0,-$BNSZ($a0) | 342 | $ST $v0,-$BNSZ($a0) |
343 | .set noreorder | 343 | .set noreorder |
344 | bgtz $ta0,.L_bn_mul_words_loop | 344 | bgtz $ta0,.L_bn_mulw_words_loop |
345 | $ADDU $v0,$ta3,$ta2 | 345 | $ADDU $v0,$ta3,$ta2 |
346 | 346 | ||
347 | beqz $a2,.L_bn_mul_words_return | 347 | beqz $a2,.L_bn_mulw_words_return |
348 | nop | 348 | nop |
349 | 349 | ||
350 | .L_bn_mul_words_tail: | 350 | .L_bn_mulw_words_tail: |
351 | .set reorder | 351 | .set reorder |
352 | $LD $t0,0($a1) | 352 | $LD $t0,0($a1) |
353 | $MULTU $t0,$a3 | 353 | $MULTU $t0,$a3 |
@@ -358,7 +358,7 @@ $code.=<<___; | |||
358 | sltu $t1,$v0,$at | 358 | sltu $t1,$v0,$at |
359 | $ST $v0,0($a0) | 359 | $ST $v0,0($a0) |
360 | $ADDU $v0,$t1,$t0 | 360 | $ADDU $v0,$t1,$t0 |
361 | beqz $a2,.L_bn_mul_words_return | 361 | beqz $a2,.L_bn_mulw_words_return |
362 | 362 | ||
363 | $LD $t0,$BNSZ($a1) | 363 | $LD $t0,$BNSZ($a1) |
364 | $MULTU $t0,$a3 | 364 | $MULTU $t0,$a3 |
@@ -369,7 +369,7 @@ $code.=<<___; | |||
369 | sltu $t1,$v0,$at | 369 | sltu $t1,$v0,$at |
370 | $ST $v0,$BNSZ($a0) | 370 | $ST $v0,$BNSZ($a0) |
371 | $ADDU $v0,$t1,$t0 | 371 | $ADDU $v0,$t1,$t0 |
372 | beqz $a2,.L_bn_mul_words_return | 372 | beqz $a2,.L_bn_mulw_words_return |
373 | 373 | ||
374 | $LD $t0,2*$BNSZ($a1) | 374 | $LD $t0,2*$BNSZ($a1) |
375 | $MULTU $t0,$a3 | 375 | $MULTU $t0,$a3 |
@@ -380,7 +380,7 @@ $code.=<<___; | |||
380 | $ST $v0,2*$BNSZ($a0) | 380 | $ST $v0,2*$BNSZ($a0) |
381 | $ADDU $v0,$t1,$t0 | 381 | $ADDU $v0,$t1,$t0 |
382 | 382 | ||
383 | .L_bn_mul_words_return: | 383 | .L_bn_mulw_words_return: |
384 | .set noreorder | 384 | .set noreorder |
385 | ___ | 385 | ___ |
386 | $code.=<<___ if ($flavour =~ /nubi/i); | 386 | $code.=<<___ if ($flavour =~ /nubi/i); |
@@ -394,7 +394,7 @@ ___ | |||
394 | $code.=<<___; | 394 | $code.=<<___; |
395 | jr $ra | 395 | jr $ra |
396 | move $a0,$v0 | 396 | move $a0,$v0 |
397 | .end bn_mul_words_internal | 397 | .end bn_mulw_words_internal |
398 | 398 | ||
399 | .align 5 | 399 | .align 5 |
400 | .globl bn_sqr_words | 400 | .globl bn_sqr_words |
diff --git a/src/lib/libcrypto/bn/asm/ppc.pl b/src/lib/libcrypto/bn/asm/ppc.pl index c9b7f9477d..547baa111c 100644 --- a/src/lib/libcrypto/bn/asm/ppc.pl +++ b/src/lib/libcrypto/bn/asm/ppc.pl | |||
@@ -205,8 +205,8 @@ $data=<<EOF; | |||
205 | # bn_add_words | 205 | # bn_add_words |
206 | # bn_div_words | 206 | # bn_div_words |
207 | # bn_sqr_words | 207 | # bn_sqr_words |
208 | # bn_mul_words | 208 | # bn_mulw_words |
209 | # bn_mul_add_words | 209 | # bn_mulw_add_words |
210 | # | 210 | # |
211 | # NOTE: It is possible to optimize this code more for | 211 | # NOTE: It is possible to optimize this code more for |
212 | # specific PowerPC or Power architectures. On the Northstar | 212 | # specific PowerPC or Power architectures. On the Northstar |
@@ -249,8 +249,8 @@ $data=<<EOF; | |||
249 | .globl .bn_add_words | 249 | .globl .bn_add_words |
250 | .globl .bn_div_words | 250 | .globl .bn_div_words |
251 | .globl .bn_sqr_words | 251 | .globl .bn_sqr_words |
252 | .globl .bn_mul_words | 252 | .globl .bn_mulw_words |
253 | .globl .bn_mul_add_words | 253 | .globl .bn_mulw_add_words |
254 | 254 | ||
255 | # .text section | 255 | # .text section |
256 | 256 | ||
@@ -1740,15 +1740,15 @@ Lppcasm_sqr_adios: | |||
1740 | 1740 | ||
1741 | # | 1741 | # |
1742 | # NOTE: The following label name should be changed to | 1742 | # NOTE: The following label name should be changed to |
1743 | # "bn_mul_words" i.e. remove the first dot | 1743 | # "bn_mulw_words" i.e. remove the first dot |
1744 | # for the gcc compiler. This should be automatically | 1744 | # for the gcc compiler. This should be automatically |
1745 | # done in the build | 1745 | # done in the build |
1746 | # | 1746 | # |
1747 | 1747 | ||
1748 | .align 4 | 1748 | .align 4 |
1749 | .bn_mul_words: | 1749 | .bn_mulw_words: |
1750 | # | 1750 | # |
1751 | # BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) | 1751 | # BN_ULONG bn_mulw_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) |
1752 | # | 1752 | # |
1753 | # r3 = rp | 1753 | # r3 = rp |
1754 | # r4 = ap | 1754 | # r4 = ap |
@@ -1842,15 +1842,15 @@ Lppcasm_mw_OVER: | |||
1842 | 1842 | ||
1843 | # | 1843 | # |
1844 | # NOTE: The following label name should be changed to | 1844 | # NOTE: The following label name should be changed to |
1845 | # "bn_mul_add_words" i.e. remove the first dot | 1845 | # "bn_mulw_add_words" i.e. remove the first dot |
1846 | # for the gcc compiler. This should be automatically | 1846 | # for the gcc compiler. This should be automatically |
1847 | # done in the build | 1847 | # done in the build |
1848 | # | 1848 | # |
1849 | 1849 | ||
1850 | .align 4 | 1850 | .align 4 |
1851 | .bn_mul_add_words: | 1851 | .bn_mulw_add_words: |
1852 | # | 1852 | # |
1853 | # BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) | 1853 | # BN_ULONG bn_mulw_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) |
1854 | # | 1854 | # |
1855 | # r3 = rp | 1855 | # r3 = rp |
1856 | # r4 = ap | 1856 | # r4 = ap |
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c index 1026b43add..e8eef4ed92 100644 --- a/src/lib/libcrypto/bn/bn_div.c +++ b/src/lib/libcrypto/bn/bn_div.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_div.c,v 1.42 2025/05/10 05:54:38 tb Exp $ */ | 1 | /* $OpenBSD: bn_div.c,v 1.43 2025/08/30 07:54:27 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 | * |
@@ -375,7 +375,7 @@ BN_div_internal(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, | |||
375 | * | wnum - sdiv * q | < sdiv | 375 | * | wnum - sdiv * q | < sdiv |
376 | */ | 376 | */ |
377 | q = bn_div_3_words(wnump, d1, d0); | 377 | q = bn_div_3_words(wnump, d1, d0); |
378 | l0 = bn_mul_words(tmp->d, sdiv->d, div_n, q); | 378 | l0 = bn_mulw_words(tmp->d, sdiv->d, div_n, q); |
379 | tmp->d[div_n] = l0; | 379 | tmp->d[div_n] = l0; |
380 | wnum.d--; | 380 | wnum.d--; |
381 | 381 | ||
diff --git a/src/lib/libcrypto/bn/bn_local.h b/src/lib/libcrypto/bn/bn_local.h index 16d270b6a1..f38d841e9a 100644 --- a/src/lib/libcrypto/bn/bn_local.h +++ b/src/lib/libcrypto/bn/bn_local.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_local.h,v 1.55 2025/08/30 07:16:06 jsing Exp $ */ | 1 | /* $OpenBSD: bn_local.h,v 1.56 2025/08/30 07:54:27 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 | * |
@@ -257,8 +257,8 @@ int bn_expand_bits(BIGNUM *a, size_t bits); | |||
257 | int bn_expand_bytes(BIGNUM *a, size_t bytes); | 257 | int bn_expand_bytes(BIGNUM *a, size_t bytes); |
258 | int bn_wexpand(BIGNUM *a, int words); | 258 | int bn_wexpand(BIGNUM *a, int words); |
259 | 259 | ||
260 | BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); | 260 | BN_ULONG bn_mulw_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); |
261 | BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); | 261 | BN_ULONG bn_mulw_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); |
262 | BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); | 262 | BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); |
263 | void bn_div_rem_words(BN_ULONG h, BN_ULONG l, BN_ULONG d, BN_ULONG *out_q, | 263 | void bn_div_rem_words(BN_ULONG h, BN_ULONG l, BN_ULONG d, BN_ULONG *out_q, |
264 | BN_ULONG *out_r); | 264 | BN_ULONG *out_r); |
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c index 8280a8db27..c9e95fb08b 100644 --- a/src/lib/libcrypto/bn/bn_mont.c +++ b/src/lib/libcrypto/bn/bn_mont.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_mont.c,v 1.69 2025/08/03 10:33:46 tb Exp $ */ | 1 | /* $OpenBSD: bn_mont.c,v 1.70 2025/08/30 07:54:27 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 | * |
@@ -332,7 +332,7 @@ bn_montgomery_reduce_words(BN_ULONG *r, BN_ULONG *a, const BN_ULONG *n, | |||
332 | 332 | ||
333 | /* Add multiples of the modulus, so that it becomes divisible by R. */ | 333 | /* Add multiples of the modulus, so that it becomes divisible by R. */ |
334 | for (i = 0; i < n_len; i++) { | 334 | for (i = 0; i < n_len; i++) { |
335 | v = bn_mul_add_words(&a[i], n, n_len, a[i] * n0); | 335 | v = bn_mulw_add_words(&a[i], n, n_len, a[i] * n0); |
336 | bn_addw_addw(v, a[i + n_len], carry, &carry, &a[i + n_len]); | 336 | bn_addw_addw(v, a[i + n_len], carry, &carry, &a[i + n_len]); |
337 | } | 337 | } |
338 | 338 | ||
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c index a30d05fb02..6ba05f2eba 100644 --- a/src/lib/libcrypto/bn/bn_mul.c +++ b/src/lib/libcrypto/bn/bn_mul.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_mul.c,v 1.43 2025/08/14 15:15:04 jsing Exp $ */ | 1 | /* $OpenBSD: bn_mul.c,v 1.44 2025/08/30 07:54:27 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 | * |
@@ -256,14 +256,13 @@ bn_mul_comba8(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b) | |||
256 | #endif | 256 | #endif |
257 | 257 | ||
258 | /* | 258 | /* |
259 | * bn_mul_words() computes (carry:r[i]) = a[i] * w + carry, where a is an array | 259 | * bn_mulw_words() computes (carry:r[i]) = a[i] * w + carry, where a is an array |
260 | * of words and w is a single word. This should really be called bn_mulw_words() | 260 | * of words and w is a single word. This is used as a step in the multiplication |
261 | * since only one input is an array. This is used as a step in the multiplication | ||
262 | * of word arrays. | 261 | * of word arrays. |
263 | */ | 262 | */ |
264 | #ifndef HAVE_BN_MUL_WORDS | 263 | #ifndef HAVE_BN_MULW_WORDS |
265 | BN_ULONG | 264 | BN_ULONG |
266 | bn_mul_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) | 265 | bn_mulw_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) |
267 | { | 266 | { |
268 | BN_ULONG carry = 0; | 267 | BN_ULONG carry = 0; |
269 | 268 | ||
@@ -289,14 +288,13 @@ bn_mul_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) | |||
289 | #endif | 288 | #endif |
290 | 289 | ||
291 | /* | 290 | /* |
292 | * bn_mul_add_words() computes (carry:r[i]) = a[i] * w + r[i] + carry, where | 291 | * bn_mulw_add_words() computes (carry:r[i]) = a[i] * w + r[i] + carry, where |
293 | * a is an array of words and w is a single word. This should really be called | 292 | * a is an array of words and w is a single word. This is used as a step in the |
294 | * bn_mulw_add_words() since only one input is an array. This is used as a step | 293 | * multiplication of word arrays. |
295 | * in the multiplication of word arrays. | ||
296 | */ | 294 | */ |
297 | #ifndef HAVE_BN_MUL_ADD_WORDS | 295 | #ifndef HAVE_BN_MULW_ADD_WORDS |
298 | BN_ULONG | 296 | BN_ULONG |
299 | bn_mul_add_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) | 297 | bn_mulw_add_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) |
300 | { | 298 | { |
301 | BN_ULONG carry = 0; | 299 | BN_ULONG carry = 0; |
302 | 300 | ||
@@ -323,62 +321,59 @@ bn_mul_add_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) | |||
323 | } | 321 | } |
324 | #endif | 322 | #endif |
325 | 323 | ||
324 | #ifndef HAVE_BN_MUL_WORDS | ||
326 | void | 325 | void |
327 | bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb) | 326 | bn_mul_words(BN_ULONG *r, BN_ULONG *a, int a_len, BN_ULONG *b, int b_len) |
328 | { | 327 | { |
329 | BN_ULONG *rr; | 328 | BN_ULONG *rr; |
330 | 329 | ||
331 | 330 | if (a_len < b_len) { | |
332 | if (na < nb) { | ||
333 | int itmp; | 331 | int itmp; |
334 | BN_ULONG *ltmp; | 332 | BN_ULONG *ltmp; |
335 | 333 | ||
336 | itmp = na; | 334 | itmp = a_len; |
337 | na = nb; | 335 | a_len = b_len; |
338 | nb = itmp; | 336 | b_len = itmp; |
339 | ltmp = a; | 337 | ltmp = a; |
340 | a = b; | 338 | a = b; |
341 | b = ltmp; | 339 | b = ltmp; |
342 | 340 | ||
343 | } | 341 | } |
344 | rr = &(r[na]); | 342 | rr = &(r[a_len]); |
345 | if (nb <= 0) { | 343 | if (b_len <= 0) { |
346 | (void)bn_mul_words(r, a, na, 0); | 344 | (void)bn_mulw_words(r, a, a_len, 0); |
347 | return; | 345 | return; |
348 | } else | 346 | } else |
349 | rr[0] = bn_mul_words(r, a, na, b[0]); | 347 | rr[0] = bn_mulw_words(r, a, a_len, b[0]); |
350 | 348 | ||
351 | for (;;) { | 349 | for (;;) { |
352 | if (--nb <= 0) | 350 | if (--b_len <= 0) |
353 | return; | 351 | return; |
354 | rr[1] = bn_mul_add_words(&(r[1]), a, na, b[1]); | 352 | rr[1] = bn_mulw_add_words(&(r[1]), a, a_len, b[1]); |
355 | if (--nb <= 0) | 353 | if (--b_len <= 0) |
356 | return; | 354 | return; |
357 | rr[2] = bn_mul_add_words(&(r[2]), a, na, b[2]); | 355 | rr[2] = bn_mulw_add_words(&(r[2]), a, a_len, b[2]); |
358 | if (--nb <= 0) | 356 | if (--b_len <= 0) |
359 | return; | 357 | return; |
360 | rr[3] = bn_mul_add_words(&(r[3]), a, na, b[3]); | 358 | rr[3] = bn_mulw_add_words(&(r[3]), a, a_len, b[3]); |
361 | if (--nb <= 0) | 359 | if (--b_len <= 0) |
362 | return; | 360 | return; |
363 | rr[4] = bn_mul_add_words(&(r[4]), a, na, b[4]); | 361 | rr[4] = bn_mulw_add_words(&(r[4]), a, a_len, b[4]); |
364 | rr += 4; | 362 | rr += 4; |
365 | r += 4; | 363 | r += 4; |
366 | b += 4; | 364 | b += 4; |
367 | } | 365 | } |
368 | } | 366 | } |
367 | #endif | ||
369 | 368 | ||
370 | 369 | static int | |
371 | #ifndef HAVE_BN_MUL | ||
372 | int | ||
373 | bn_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, int rn, BN_CTX *ctx) | 370 | bn_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, int rn, BN_CTX *ctx) |
374 | { | 371 | { |
375 | bn_mul_normal(r->d, a->d, a->top, b->d, b->top); | 372 | bn_mul_words(r->d, a->d, a->top, b->d, b->top); |
376 | 373 | ||
377 | return 1; | 374 | return 1; |
378 | } | 375 | } |
379 | 376 | ||
380 | #endif /* HAVE_BN_MUL */ | ||
381 | |||
382 | int | 377 | int |
383 | BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | 378 | BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) |
384 | { | 379 | { |
diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c index 3a6eed06c6..64f275f9d4 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.39 2025/08/30 07:16:06 jsing Exp $ */ | 1 | /* $OpenBSD: bn_sqr.c,v 1.40 2025/08/30 07:54:27 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 | * |
@@ -267,7 +267,7 @@ bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int a_len) | |||
267 | /* Compute initial product - r[n:1] = a[n:1] * a[0] */ | 267 | /* Compute initial product - r[n:1] = a[n:1] * a[0] */ |
268 | n = a_len - 1; | 268 | n = a_len - 1; |
269 | if (n > 0) { | 269 | if (n > 0) { |
270 | rp[n] = bn_mul_words(rp, ap, n, w); | 270 | rp[n] = bn_mulw_words(rp, ap, n, w); |
271 | } | 271 | } |
272 | rp += 2; | 272 | rp += 2; |
273 | n--; | 273 | n--; |
@@ -277,7 +277,7 @@ bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int a_len) | |||
277 | w = ap[0]; | 277 | w = ap[0]; |
278 | ap++; | 278 | ap++; |
279 | 279 | ||
280 | rp[n] = bn_mul_add_words(rp, ap, n, w); | 280 | rp[n] = bn_mulw_add_words(rp, ap, n, w); |
281 | rp += 2; | 281 | rp += 2; |
282 | n--; | 282 | n--; |
283 | } | 283 | } |
diff --git a/src/lib/libcrypto/bn/bn_word.c b/src/lib/libcrypto/bn/bn_word.c index a82b911e67..e035878cb9 100644 --- a/src/lib/libcrypto/bn/bn_word.c +++ b/src/lib/libcrypto/bn/bn_word.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_word.c,v 1.21 2023/07/08 12:21:58 beck Exp $ */ | 1 | /* $OpenBSD: bn_word.c,v 1.22 2025/08/30 07:54:27 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 | * |
@@ -232,7 +232,7 @@ BN_mul_word(BIGNUM *a, BN_ULONG w) | |||
232 | if (w == 0) | 232 | if (w == 0) |
233 | BN_zero(a); | 233 | BN_zero(a); |
234 | else { | 234 | else { |
235 | ll = bn_mul_words(a->d, a->d, a->top, w); | 235 | ll = bn_mulw_words(a->d, a->d, a->top, w); |
236 | if (ll) { | 236 | if (ll) { |
237 | if (!bn_wexpand(a, a->top + 1)) | 237 | if (!bn_wexpand(a, a->top + 1)) |
238 | return (0); | 238 | return (0); |