summaryrefslogtreecommitdiff
path: root/lib/libcrypto
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2022-07-30 18:03:37 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2022-07-30 18:03:37 +0000
commita20c95a283e30b98f87b7d7bd464b933b692cc88 (patch)
tree6fa838b6bfec1639dad1b5596156b22607c3ae1c /lib/libcrypto
parenta33de5b8491b7332ba603c0e58732a9143eebda7 (diff)
Use named initialisers for BIGNUMs.
Also move the _bignum_nist_p_.*_sqr static BIGNUMs out of individual functions. ok tb@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r--lib/libcrypto/bn/bn_nist.c126
1 files changed, 65 insertions, 61 deletions
diff --git a/lib/libcrypto/bn/bn_nist.c b/lib/libcrypto/bn/bn_nist.c
index 871b37cf893..51b59020c7c 100644
--- a/lib/libcrypto/bn/bn_nist.c
+++ b/lib/libcrypto/bn/bn_nist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bn_nist.c,v 1.20 2022/05/07 07:47:24 jsing Exp $ */
+/* $OpenBSD: bn_nist.c,v 1.21 2022/07/30 18:03:36 jsing Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project
*/
@@ -287,45 +287,84 @@ static const BN_ULONG _nist_p_521_sqr[] = {
#endif
static const BIGNUM _bignum_nist_p_192 = {
- (BN_ULONG *)_nist_p_192[0],
- BN_NIST_192_TOP,
- BN_NIST_192_TOP,
- 0,
- BN_FLG_STATIC_DATA
+ .d = (BN_ULONG *)_nist_p_192[0],
+ .top = BN_NIST_192_TOP,
+ .dmax = BN_NIST_192_TOP,
+ .neg = 0,
+ .flags = BN_FLG_STATIC_DATA,
+};
+
+static const BIGNUM _bignum_nist_p_192_sqr = {
+ .d = (BN_ULONG *)_nist_p_192_sqr,
+ .top = sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]),
+ .dmax = sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]),
+ .neg = 0,
+ .flags = BN_FLG_STATIC_DATA,
};
static const BIGNUM _bignum_nist_p_224 = {
- (BN_ULONG *)_nist_p_224[0],
- BN_NIST_224_TOP,
- BN_NIST_224_TOP,
- 0,
- BN_FLG_STATIC_DATA
+ .d = (BN_ULONG *)_nist_p_224[0],
+ .top = BN_NIST_224_TOP,
+ .dmax = BN_NIST_224_TOP,
+ .neg = 0,
+ .flags = BN_FLG_STATIC_DATA,
+};
+
+static const BIGNUM _bignum_nist_p_224_sqr = {
+ .d = (BN_ULONG *)_nist_p_224_sqr,
+ .top = sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]),
+ .dmax = sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]),
+ .neg = 0,
+ .flags = BN_FLG_STATIC_DATA,
};
static const BIGNUM _bignum_nist_p_256 = {
- (BN_ULONG *)_nist_p_256[0],
- BN_NIST_256_TOP,
- BN_NIST_256_TOP,
- 0,
- BN_FLG_STATIC_DATA
+ .d = (BN_ULONG *)_nist_p_256[0],
+ .top = BN_NIST_256_TOP,
+ .dmax = BN_NIST_256_TOP,
+ .neg = 0,
+ .flags = BN_FLG_STATIC_DATA,
+};
+
+static const BIGNUM _bignum_nist_p_256_sqr = {
+ .d = (BN_ULONG *)_nist_p_256_sqr,
+ .top = sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]),
+ .dmax = sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]),
+ .neg = 0,
+ .flags = BN_FLG_STATIC_DATA,
};
static const BIGNUM _bignum_nist_p_384 = {
- (BN_ULONG *)_nist_p_384[0],
- BN_NIST_384_TOP,
- BN_NIST_384_TOP,
- 0,
- BN_FLG_STATIC_DATA
+ .d = (BN_ULONG *)_nist_p_384[0],
+ .top = BN_NIST_384_TOP,
+ .dmax = BN_NIST_384_TOP,
+ .neg = 0,
+ .flags = BN_FLG_STATIC_DATA,
+};
+
+static const BIGNUM _bignum_nist_p_384_sqr = {
+ .d = (BN_ULONG *)_nist_p_384_sqr,
+ .top = sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]),
+ .dmax = sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]),
+ .neg = 0,
+ .flags = BN_FLG_STATIC_DATA,
};
static const BIGNUM _bignum_nist_p_521 = {
- (BN_ULONG *)_nist_p_521,
- BN_NIST_521_TOP,
- BN_NIST_521_TOP,
- 0,
- BN_FLG_STATIC_DATA
+ .d = (BN_ULONG *)_nist_p_521,
+ .top = BN_NIST_521_TOP,
+ .dmax = BN_NIST_521_TOP,
+ .neg = 0,
+ .flags = BN_FLG_STATIC_DATA,
};
+static const BIGNUM _bignum_nist_p_521_sqr = {
+ .d = (BN_ULONG *)_nist_p_521_sqr,
+ .top = sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]),
+ .dmax = sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]),
+ .neg = 0,
+ .flags = BN_FLG_STATIC_DATA,
+};
const BIGNUM *
BN_get0_nist_prime_192(void)
@@ -431,13 +470,6 @@ BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx)
BN_ULONG bnbuf[BN_NIST_192_TOP] = { 0 };
BN_ULONG c_d[BN_NIST_192_TOP], *res;
uintptr_t mask;
- static const BIGNUM _bignum_nist_p_192_sqr = {
- (BN_ULONG *)_nist_p_192_sqr,
- sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]),
- sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]),
- 0,
- BN_FLG_STATIC_DATA
- };
field = &_bignum_nist_p_192; /* just to make sure */
@@ -586,13 +618,6 @@ BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx)
BN_ULONG c_d[BN_NIST_224_TOP], *res;
uintptr_t mask;
bn_addsub_f addsubf;
- static const BIGNUM _bignum_nist_p_224_sqr = {
- (BN_ULONG *)_nist_p_224_sqr,
- sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]),
- sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]),
- 0,
- BN_FLG_STATIC_DATA
- };
field = &_bignum_nist_p_224; /* just to make sure */
@@ -776,13 +801,6 @@ BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx)
BN_ULONG c_d[BN_NIST_256_TOP] = {0}, *res;
uintptr_t mask;
bn_addsub_f addsubf;
- static const BIGNUM _bignum_nist_p_256_sqr = {
- (BN_ULONG *)_nist_p_256_sqr,
- sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]),
- sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]),
- 0,
- BN_FLG_STATIC_DATA
- };
field = &_bignum_nist_p_256; /* just to make sure */
@@ -1014,13 +1032,6 @@ BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx)
BN_ULONG c_d[BN_NIST_384_TOP], *res;
uintptr_t mask;
bn_addsub_f addsubf;
- static const BIGNUM _bignum_nist_p_384_sqr = {
- (BN_ULONG *)_nist_p_384_sqr,
- sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]),
- sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]),
- 0,
- BN_FLG_STATIC_DATA
- };
field = &_bignum_nist_p_384; /* just to make sure */
@@ -1269,13 +1280,6 @@ BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx)
int top = a->top, i;
BN_ULONG *r_d, *a_d = a->d, t_d[BN_NIST_521_TOP], val, tmp, *res;
uintptr_t mask;
- static const BIGNUM _bignum_nist_p_521_sqr = {
- (BN_ULONG *)_nist_p_521_sqr,
- sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]),
- sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]),
- 0,
- BN_FLG_STATIC_DATA
- };
field = &_bignum_nist_p_521; /* just to make sure */