50
50
* (eay@cryptsoft.com). This product includes software written by Tim
51
51
* Hudson (tjh@cryptsoft.com). */
52
52
53
+ #ifndef DEPS_NCRYPTO_DH_PRIMES_H_
54
+ #define DEPS_NCRYPTO_DH_PRIMES_H_
55
+
53
56
#include <openssl/dh.h>
54
57
55
58
#include <openssl/bn.h>
56
59
#include <openssl/err.h>
57
60
#include <openssl/mem.h>
58
61
59
- extern "C" int bn_set_words (BIGNUM * bn , const BN_ULONG * words , size_t num );
62
+ extern "C" int bn_set_words (BIGNUM * bn , const BN_ULONG * words , size_t num );
60
63
61
- // Backporting primes that may not be supported in earlier boringssl versions. Intentionally
62
- // keeping the existing C-style formatting.
64
+ // Backporting primes that may not be supported in earlier boringssl versions.
65
+ // Intentionally keeping the existing C-style formatting.
63
66
64
67
#define OPENSSL_ARRAY_SIZE (array ) (sizeof(array) / sizeof((array)[0]))
65
68
@@ -71,25 +74,27 @@ extern "C" int bn_set_words(BIGNUM *bn, const BN_ULONG *words, size_t num);
71
74
#error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
72
75
#endif
73
76
74
- static BIGNUM * get_params (BIGNUM * ret , const BN_ULONG * words , size_t num_words ) {
75
- BIGNUM * alloc = NULL ;
76
- if (ret == NULL ) {
77
+ static BIGNUM * get_params (BIGNUM * ret ,
78
+ const BN_ULONG * words ,
79
+ size_t num_words ) {
80
+ BIGNUM * alloc = nullptr ;
81
+ if (ret == nullptr ) {
77
82
alloc = BN_new ();
78
- if (alloc == NULL ) {
79
- return NULL ;
83
+ if (alloc == nullptr ) {
84
+ return nullptr ;
80
85
}
81
86
ret = alloc ;
82
87
}
83
88
84
89
if (!bn_set_words (ret , words , num_words )) {
85
90
BN_free (alloc );
86
- return NULL ;
91
+ return nullptr ;
87
92
}
88
93
89
94
return ret ;
90
95
}
91
96
92
- BIGNUM * BN_get_rfc3526_prime_2048 (BIGNUM * ret ) {
97
+ BIGNUM * BN_get_rfc3526_prime_2048 (BIGNUM * ret ) {
93
98
static const BN_ULONG kWords [] = {
94
99
TOBN (0xffffffff , 0xffffffff ), TOBN (0x15728e5a , 0x8aacaa68 ),
95
100
TOBN (0x15d22618 , 0x98fa0510 ), TOBN (0x3995497c , 0xea956ae5 ),
@@ -111,7 +116,7 @@ BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *ret) {
111
116
return get_params (ret , kWords , OPENSSL_ARRAY_SIZE (kWords ));
112
117
}
113
118
114
- BIGNUM * BN_get_rfc3526_prime_3072 (BIGNUM * ret ) {
119
+ BIGNUM * BN_get_rfc3526_prime_3072 (BIGNUM * ret ) {
115
120
static const BN_ULONG kWords [] = {
116
121
TOBN (0xffffffff , 0xffffffff ), TOBN (0x4b82d120 , 0xa93ad2ca ),
117
122
TOBN (0x43db5bfc , 0xe0fd108e ), TOBN (0x08e24fa0 , 0x74e5ab31 ),
@@ -141,7 +146,7 @@ BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *ret) {
141
146
return get_params (ret , kWords , OPENSSL_ARRAY_SIZE (kWords ));
142
147
}
143
148
144
- BIGNUM * BN_get_rfc3526_prime_4096 (BIGNUM * ret ) {
149
+ BIGNUM * BN_get_rfc3526_prime_4096 (BIGNUM * ret ) {
145
150
static const BN_ULONG kWords [] = {
146
151
TOBN (0xffffffff , 0xffffffff ), TOBN (0x4df435c9 , 0x34063199 ),
147
152
TOBN (0x86ffb7dc , 0x90a6c08f ), TOBN (0x93b4ea98 , 0x8d8fddc1 ),
@@ -179,7 +184,7 @@ BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *ret) {
179
184
return get_params (ret , kWords , OPENSSL_ARRAY_SIZE (kWords ));
180
185
}
181
186
182
- BIGNUM * BN_get_rfc3526_prime_6144 (BIGNUM * ret ) {
187
+ BIGNUM * BN_get_rfc3526_prime_6144 (BIGNUM * ret ) {
183
188
static const BN_ULONG kWords [] = {
184
189
TOBN (0xffffffff , 0xffffffff ), TOBN (0xe694f91e , 0x6dcc4024 ),
185
190
TOBN (0x12bf2d5b , 0x0b7474d6 ), TOBN (0x043e8f66 , 0x3f4860ee ),
@@ -233,7 +238,7 @@ BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *ret) {
233
238
return get_params (ret , kWords , OPENSSL_ARRAY_SIZE (kWords ));
234
239
}
235
240
236
- BIGNUM * BN_get_rfc3526_prime_8192 (BIGNUM * ret ) {
241
+ BIGNUM * BN_get_rfc3526_prime_8192 (BIGNUM * ret ) {
237
242
static const BN_ULONG kWords [] = {
238
243
TOBN (0xffffffff , 0xffffffff ), TOBN (0x60c980dd , 0x98edd3df ),
239
244
TOBN (0xc81f56e8 , 0x80b96e71 ), TOBN (0x9e3050e2 , 0x765694df ),
@@ -302,3 +307,5 @@ BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *ret) {
302
307
};
303
308
return get_params (ret , kWords , OPENSSL_ARRAY_SIZE (kWords ));
304
309
}
310
+
311
+ #endif // DEPS_NCRYPTO_DH_PRIMES_H_
0 commit comments