summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2025-05-25 04:53:05 +0000
committerjsing <>2025-05-25 04:53:05 +0000
commit6bb5c601c21b47afb4744e7bc8a8350c392822bd (patch)
tree9494bd58b828a31228e34d081f64fe9586327d6e /src
parent0e050e6526943c7e04e6e1dd84130e91a12d8798 (diff)
downloadopenbsd-6bb5c601c21b47afb4744e7bc8a8350c392822bd.tar.gz
openbsd-6bb5c601c21b47afb4744e7bc8a8350c392822bd.tar.bz2
openbsd-6bb5c601c21b47afb4744e7bc8a8350c392822bd.zip
Fix previous.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/Makefile3
-rw-r--r--src/lib/libcrypto/bn/bn_add.c69
-rw-r--r--src/lib/libcrypto/bn/bn_internal.h6
3 files changed, 6 insertions, 72 deletions
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile
index db3bc767d9..a05042986c 100644
--- a/src/lib/libcrypto/Makefile
+++ b/src/lib/libcrypto/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.231 2024/12/19 23:56:32 tb Exp $ 1# $OpenBSD: Makefile,v 1.232 2025/05/25 04:53:05 jsing Exp $
2 2
3LIB= crypto 3LIB= crypto
4LIBREBUILD=y 4LIBREBUILD=y
@@ -159,6 +159,7 @@ SRCS+= bss_sock.c
159 159
160# bn/ 160# bn/
161SRCS+= bn_add.c 161SRCS+= bn_add.c
162SRCS+= bn_add_sub.c
162SRCS+= bn_bpsw.c 163SRCS+= bn_bpsw.c
163SRCS+= bn_const.c 164SRCS+= bn_const.c
164SRCS+= bn_convert.c 165SRCS+= bn_convert.c
diff --git a/src/lib/libcrypto/bn/bn_add.c b/src/lib/libcrypto/bn/bn_add.c
index db1767ea55..81fa60e429 100644
--- a/src/lib/libcrypto/bn/bn_add.c
+++ b/src/lib/libcrypto/bn/bn_add.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_add.c,v 1.28 2025/05/25 04:16:36 jsing Exp $ */ 1/* $OpenBSD: bn_add.c,v 1.29 2025/05/25 04:53:05 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 *
@@ -66,39 +66,6 @@
66#include "err_local.h" 66#include "err_local.h"
67 67
68/* 68/*
69 * bn_add_words() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b
70 * are both arrays of words. Any carry resulting from the addition is returned.
71 */
72#ifndef HAVE_BN_ADD_WORDS
73BN_ULONG
74bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
75{
76 BN_ULONG carry = 0;
77
78 assert(n >= 0);
79 if (n <= 0)
80 return 0;
81
82 while (n & ~3) {
83 bn_qwaddqw(a[3], a[2], a[1], a[0], b[3], b[2], b[1], b[0],
84 carry, &carry, &r[3], &r[2], &r[1], &r[0]);
85 a += 4;
86 b += 4;
87 r += 4;
88 n -= 4;
89 }
90 while (n) {
91 bn_addw_addw(a[0], b[0], carry, &carry, &r[0]);
92 a++;
93 b++;
94 r++;
95 n--;
96 }
97 return carry;
98}
99#endif
100
101/*
102 * bn_add() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b are both 69 * bn_add() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b are both
103 * arrays of words (r may be the same as a or b). The length of a and b may 70 * arrays of words (r may be the same as a or b). The length of a and b may
104 * differ, while r must be at least max(a_len, b_len) in length. Any carry 71 * differ, while r must be at least max(a_len, b_len) in length. Any carry
@@ -146,40 +113,6 @@ bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b,
146#endif 113#endif
147 114
148/* 115/*
149 * bn_sub_words() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b
150 * are both arrays of words. Any borrow resulting from the subtraction is
151 * returned.
152 */
153#ifndef HAVE_BN_SUB_WORDS
154BN_ULONG
155bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
156{
157 BN_ULONG borrow = 0;
158
159 assert(n >= 0);
160 if (n <= 0)
161 return 0;
162
163 while (n & ~3) {
164 bn_qwsubqw(a[3], a[2], a[1], a[0], b[3], b[2], b[1], b[0],
165 borrow, &borrow, &r[3], &r[2], &r[1], &r[0]);
166 a += 4;
167 b += 4;
168 r += 4;
169 n -= 4;
170 }
171 while (n) {
172 bn_subw_subw(a[0], b[0], borrow, &borrow, &r[0]);
173 a++;
174 b++;
175 r++;
176 n--;
177 }
178 return borrow;
179}
180#endif
181
182/*
183 * bn_sub() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b are both 116 * bn_sub() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b are both
184 * arrays of words (r may be the same as a or b). The length of a and b may 117 * arrays of words (r may be the same as a or b). The length of a and b may
185 * differ, while r must be at least max(a_len, b_len) in length. Any borrow 118 * differ, while r must be at least max(a_len, b_len) in length. Any borrow
diff --git a/src/lib/libcrypto/bn/bn_internal.h b/src/lib/libcrypto/bn/bn_internal.h
index 18fd7550a6..895a194c93 100644
--- a/src/lib/libcrypto/bn/bn_internal.h
+++ b/src/lib/libcrypto/bn/bn_internal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_internal.h,v 1.16 2025/05/25 04:30:55 jsing Exp $ */ 1/* $OpenBSD: bn_internal.h,v 1.17 2025/05/25 04:53:05 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -31,9 +31,9 @@ BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
31BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, 31BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
32 int num); 32 int num);
33BN_ULONG bn_sub_words_borrow(const BN_ULONG *a, const BN_ULONG *b, size_t n); 33BN_ULONG bn_sub_words_borrow(const BN_ULONG *a, const BN_ULONG *b, size_t n);
34void bn_add_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, 34BN_ULONG bn_add_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
35 BN_ULONG mask, size_t n); 35 BN_ULONG mask, size_t n);
36void bn_sub_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, 36BN_ULONG bn_sub_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
37 BN_ULONG mask, size_t n); 37 BN_ULONG mask, size_t n);
38 38
39#ifndef HAVE_BN_CT_NE_ZERO 39#ifndef HAVE_BN_CT_NE_ZERO