Skip to content

Commit 312c653

Browse files
committed
Make many unused BN_* macros internal (DO NOT MERGE)
1 parent 000396d commit 312c653

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

patches/bn_macros.patch

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
diff --git include/openssl/bn.h include/openssl/bn.h
2+
index e64fcf355f..be6be8c219 100644
3+
--- include/openssl/bn.h
4+
+++ include/openssl/bn.h
5+
@@ -143,42 +143,18 @@
6+
#if defined(_LP64) || defined(_WIN64)
7+
#undef BN_LLONG
8+
#define BN_ULONG uint64_t
9+
-#define BN_LONG int64_t
10+
-#define BN_BITS 128
11+
#define BN_BYTES 8
12+
#define BN_BITS2 64
13+
-#define BN_BITS4 32
14+
-#define BN_MASK2 UINT64_C(0xffffffffffffffff)
15+
-#define BN_MASK2l UINT64_C(0xffffffff)
16+
-#define BN_MASK2h UINT64_C(0xffffffff00000000)
17+
-#define BN_MASK2h1 UINT64_C(0xffffffff80000000)
18+
-#define BN_TBIT UINT64_C(0x8000000000000000)
19+
-#define BN_DEC_CONV UINT64_C(10000000000000000000)
20+
#define BN_DEC_FMT1 "%" PRIu64
21+
-#define BN_DEC_FMT2 "%019" PRIu64
22+
-#define BN_DEC_NUM 19
23+
#define BN_HEX_FMT1 "%" PRIX64
24+
-#define BN_HEX_FMT2 "%016" PRIX64
25+
#else
26+
#define BN_ULLONG uint64_t
27+
#define BN_LLONG
28+
#define BN_ULONG uint32_t
29+
-#define BN_LONG int32_t
30+
-#define BN_BITS 64
31+
#define BN_BYTES 4
32+
#define BN_BITS2 32
33+
-#define BN_BITS4 16
34+
-#define BN_MASK UINT64_C(0xffffffffffffffff)
35+
-#define BN_MASK2 UINT32_C(0xffffffff)
36+
-#define BN_MASK2l UINT32_C(0xffff)
37+
-#define BN_MASK2h1 UINT32_C(0xffff8000)
38+
#define BN_MASK2h UINT32_C(0xffff0000)
39+
-#define BN_TBIT UINT32_C(0x80000000)
40+
-#define BN_DEC_CONV UINT32_C(1000000000)
41+
#define BN_DEC_FMT1 "%" PRIu32
42+
-#define BN_DEC_FMT2 "%09" PRIu32
43+
-#define BN_DEC_NUM 9
44+
#define BN_HEX_FMT1 "%" PRIX32
45+
-#define BN_HEX_FMT2 "%08" PRIX32
46+
#endif
47+
48+
diff --git crypto/bn/bn_convert.c crypto/bn/bn_convert.c
49+
index ca5c7d7865..6949cab91c 100644
50+
--- crypto/bn/bn_convert.c
51+
+++ crypto/bn/bn_convert.c
52+
@@ -71,6 +71,14 @@
53+
#include "crypto_internal.h"
54+
#include "err_local.h"
55+
56+
+#if BN_BYTES == 8
57+
+#define BN_DEC_CONV UINT64_C(10000000000000000000)
58+
+#define BN_DEC_NUM 19
59+
+#else
60+
+#define BN_DEC_CONV UINT32_C(1000000000)
61+
+#define BN_DEC_NUM 9
62+
+#endif
63+
+
64+
static int bn_dec2bn_cbs(BIGNUM **bnp, CBS *cbs);
65+
static int bn_hex2bn_cbs(BIGNUM **bnp, CBS *cbs);
66+
67+
diff --git crypto/bn/bn_local.h crypto/bn/bn_local.h
68+
index a7d61f1b03..1a90de2a19 100644
69+
--- crypto/bn/bn_local.h
70+
+++ crypto/bn/bn_local.h
71+
@@ -116,6 +116,18 @@
72+
73+
#include <openssl/bn.h>
74+
75+
+#if BN_BYTES == 8
76+
+#define BN_MASK2 UINT64_C(0xffffffffffffffff)
77+
+#define BN_MASK2l UINT64_C(0xffffffff)
78+
+#define BN_BITS 128
79+
+#define BN_BITS4 32
80+
+#else
81+
+#define BN_MASK2 UINT32_C(0xffffffff)
82+
+#define BN_MASK2l UINT32_C(0xffff)
83+
+#define BN_BITS 64
84+
+#define BN_BITS4 16
85+
+#endif
86+
+
87+
__BEGIN_HIDDEN_DECLS
88+
89+
struct bignum_st {
90+
diff --git crypto/ec/ec_internal.h crypto/ec/ec_internal.h
91+
index 327d9ea94d..bfc1a32db3 100644
92+
--- crypto/ec/ec_internal.h
93+
+++ crypto/ec/ec_internal.h
94+
@@ -24,7 +24,7 @@
95+
#define EC_FIELD_ELEMENT_MAX_BYTES \
96+
(EC_FIELD_ELEMENT_MAX_BITS + 7) / 8
97+
#define EC_FIELD_ELEMENT_MAX_WORDS \
98+
- ((EC_FIELD_ELEMENT_MAX_BYTES + BN_BYTES - 1) / BN_BYTES)
99+
+ ((EC_FIELD_ELEMENT_MAX_BYTES + sizeof(BN_ULONG) - 1) / sizeof(BN_ULONG))
100+
101+
typedef struct {
102+
BN_ULONG w[EC_FIELD_ELEMENT_MAX_WORDS];
103+
diff --git crypto/bn/bn_internal.h crypto/bn/bn_internal.h
104+
index 8b5145e225..6058c53cd3 100644
105+
--- crypto/bn/bn_internal.h
106+
+++ crypto/bn/bn_internal.h
107+
@@ -18,6 +18,7 @@
108+
#include <openssl/bn.h>
109+
110+
#include "bn_arch.h"
111+
+#include "bn_local.h"
112+
113+
#ifndef HEADER_BN_INTERNAL_H
114+
#define HEADER_BN_INTERNAL_H
115+
diff --git tests/bn_word.c tests/bn_word.c
116+
index 2ec518ed1b..4a1edc6906 100644
117+
--- tests/bn_word.c
118+
+++ tests/bn_word.c
119+
@@ -20,6 +20,8 @@
120+
121+
#include <openssl/bn.h>
122+
123+
+#include "bn_local.h"
124+
+
125+
struct bn_word_test {
126+
const char *in_hex;
127+
BN_ULONG in_word;

0 commit comments

Comments
 (0)