summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2021-02-19 19:15:41 +1000
committerShane Lontis <shane.lontis@oracle.com>2021-02-26 10:32:22 +1000
commit94553e85b68af4513a8ee89cd2a0d4e044d75139 (patch)
tree2150abcbe848f0d1973b0186bd6864595e3f18a2 /crypto
parent2d968951227acd422f0e712035de3216d47fc980 (diff)
Fix external symbols for bn
Partial fix for #12964 This adds ossl_ names for symbols related to bn_* Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14296)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/bn/bn_const.c12
-rw-r--r--crypto/bn/bn_ctx.c2
-rw-r--r--crypto/bn/bn_dh.c14
-rw-r--r--crypto/bn/bn_prime.c8
-rw-r--r--crypto/bn/bn_rand.c4
-rw-r--r--crypto/bn/bn_rsa_fips186_4.c28
-rw-r--r--crypto/dh/dh_rfc5114.c6
-rw-r--r--crypto/ec/ec_cvt.c4
-rw-r--r--crypto/ffc/ffc_dh.c9
-rw-r--r--crypto/ffc/ffc_params_generate.c4
-rw-r--r--crypto/rsa/rsa_sp800_56b_check.c11
-rw-r--r--crypto/rsa/rsa_sp800_56b_gen.c8
12 files changed, 60 insertions, 50 deletions
diff --git a/crypto/bn/bn_const.c b/crypto/bn/bn_const.c
index 7d0a9f901e..06a40d6fba 100644
--- a/crypto/bn/bn_const.c
+++ b/crypto/bn/bn_const.c
@@ -84,7 +84,7 @@ BIGNUM *BN_get_rfc2409_prime_1024(BIGNUM *bn)
BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn)
{
- return COPY_BN(bn, _bignum_modp_1536_p);
+ return COPY_BN(bn, ossl_bignum_modp_1536_p);
}
/*-
@@ -97,7 +97,7 @@ BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn)
BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn)
{
- return COPY_BN(bn, _bignum_modp_2048_p);
+ return COPY_BN(bn, ossl_bignum_modp_2048_p);
}
/*-
@@ -110,7 +110,7 @@ BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn)
BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn)
{
- return COPY_BN(bn, _bignum_modp_3072_p);
+ return COPY_BN(bn, ossl_bignum_modp_3072_p);
}
/*-
@@ -123,7 +123,7 @@ BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn)
BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn)
{
- return COPY_BN(bn, _bignum_modp_4096_p);
+ return COPY_BN(bn, ossl_bignum_modp_4096_p);
}
/*-
@@ -136,7 +136,7 @@ BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn)
BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn)
{
- return COPY_BN(bn, _bignum_modp_6144_p);
+ return COPY_BN(bn, ossl_bignum_modp_6144_p);
}
/*-
@@ -149,5 +149,5 @@ BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn)
BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn)
{
- return COPY_BN(bn, _bignum_modp_8192_p);
+ return COPY_BN(bn, ossl_bignum_modp_8192_p);
}
diff --git a/crypto/bn/bn_ctx.c b/crypto/bn/bn_ctx.c
index 6234c51435..360b708221 100644
--- a/crypto/bn/bn_ctx.c
+++ b/crypto/bn/bn_ctx.c
@@ -249,7 +249,7 @@ BIGNUM *BN_CTX_get(BN_CTX *ctx)
return ret;
}
-OSSL_LIB_CTX *bn_get_libctx(BN_CTX *ctx)
+OSSL_LIB_CTX *ossl_bn_get_libctx(BN_CTX *ctx)
{
if (ctx == NULL)
return NULL;
diff --git a/crypto/bn/bn_dh.c b/crypto/bn/bn_dh.c
index 9f5b80cb8e..58f545642e 100644
--- a/crypto/bn/bn_dh.c
+++ b/crypto/bn/bn_dh.c
@@ -1003,15 +1003,17 @@ static const BN_ULONG ffdhe8192_q[] = {
/* Macro to make a BIGNUM from static data */
-# define make_dh_bn(x) extern const BIGNUM _bignum_##x; \
- const BIGNUM _bignum_##x = { (BN_ULONG *) x, \
- OSSL_NELEM(x),\
- OSSL_NELEM(x),\
- 0, BN_FLG_STATIC_DATA };
+# define make_dh_bn(x) \
+ extern const BIGNUM ossl_bignum_##x; \
+ const BIGNUM ossl_bignum_##x = { \
+ (BN_ULONG *) x, \
+ OSSL_NELEM(x), \
+ OSSL_NELEM(x), \
+ 0, BN_FLG_STATIC_DATA };
static const BN_ULONG value_2 = 2;
-const BIGNUM _bignum_const_2 = {
+const BIGNUM ossl_bignum_const_2 = {
(BN_ULONG *)&value_2, 1, 1, 0, BN_FLG_STATIC_DATA
};
diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c
index eba402d2f2..33a2c85129 100644
--- a/crypto/bn/bn_prime.c
+++ b/crypto/bn/bn_prime.c
@@ -62,7 +62,7 @@ static const BIGNUM _bignum_small_prime_factors = {
BN_FLG_STATIC_DATA
};
-const BIGNUM *bn_get0_small_factors(void)
+const BIGNUM *ossl_bn_get0_small_factors(void)
{
return &_bignum_small_prime_factors;
}
@@ -308,7 +308,7 @@ static int bn_is_prime_int(const BIGNUM *w, int checks, BN_CTX *ctx,
goto err;
#endif
- ret = bn_miller_rabin_is_prime(w, checks, ctx, cb, 0, &status);
+ ret = ossl_bn_miller_rabin_is_prime(w, checks, ctx, cb, 0, &status);
if (!ret)
goto err;
ret = (status == BN_PRIMETEST_PROBABLY_PRIME);
@@ -334,8 +334,8 @@ err:
*
* returns 0 if there was an error, otherwise it returns 1.
*/
-int bn_miller_rabin_is_prime(const BIGNUM *w, int iterations, BN_CTX *ctx,
- BN_GENCB *cb, int enhanced, int *status)
+int ossl_bn_miller_rabin_is_prime(const BIGNUM *w, int iterations, BN_CTX *ctx,
+ BN_GENCB *cb, int enhanced, int *status)
{
int i, j, a, ret = 0;
BIGNUM *g, *w1, *w3, *x, *m, *z, *b;
diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c
index 1f12e81fb7..79e44ab960 100644
--- a/crypto/bn/bn_rand.c
+++ b/crypto/bn/bn_rand.c
@@ -25,7 +25,7 @@ static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom,
{
unsigned char *buf = NULL;
int b, ret = 0, bit, bytes, mask;
- OSSL_LIB_CTX *libctx = bn_get_libctx(ctx);
+ OSSL_LIB_CTX *libctx = ossl_bn_get_libctx(ctx);
if (bits == 0) {
if (top != BN_RAND_TOP_ANY || bottom != BN_RAND_BOTTOM_ANY)
@@ -256,7 +256,7 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
unsigned char *k_bytes = NULL;
int ret = 0;
EVP_MD *md = NULL;
- OSSL_LIB_CTX *libctx = bn_get_libctx(ctx);
+ OSSL_LIB_CTX *libctx = ossl_bn_get_libctx(ctx);
if (mdctx == NULL)
goto err;
diff --git a/crypto/bn/bn_rsa_fips186_4.c b/crypto/bn/bn_rsa_fips186_4.c
index ab1e1f14ae..a49166b9c3 100644
--- a/crypto/bn/bn_rsa_fips186_4.c
+++ b/crypto/bn/bn_rsa_fips186_4.c
@@ -45,7 +45,7 @@ static const BN_ULONG inv_sqrt_2_val[] = {
BN_DEF(0x754ABE9FUL, 0x597D89B3UL), BN_DEF(0xF9DE6484UL, 0xB504F333UL)
};
-const BIGNUM bn_inv_sqrt_2 = {
+const BIGNUM ossl_bn_inv_sqrt_2 = {
(BN_ULONG *)inv_sqrt_2_val,
OSSL_NELEM(inv_sqrt_2_val),
OSSL_NELEM(inv_sqrt_2_val),
@@ -147,11 +147,12 @@ err:
* cb An optional BIGNUM callback.
* Returns: 1 on success otherwise it returns 0.
*/
-int bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout,
- BIGNUM *p1, BIGNUM *p2,
- const BIGNUM *Xp, const BIGNUM *Xp1,
- const BIGNUM *Xp2, int nlen,
- const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb)
+int ossl_bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout,
+ BIGNUM *p1, BIGNUM *p2,
+ const BIGNUM *Xp, const BIGNUM *Xp1,
+ const BIGNUM *Xp2, int nlen,
+ const BIGNUM *e, BN_CTX *ctx,
+ BN_GENCB *cb)
{
int ret = 0;
BIGNUM *p1i = NULL, *p2i = NULL, *Xp1i = NULL, *Xp2i = NULL;
@@ -197,7 +198,8 @@ int bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout,
bn_rsa_fips186_4_aux_prime_max_sum_size_for_prob_primes(nlen))
goto err;
/* (Steps 4.3/5.3) - generate prime */
- if (!bn_rsa_fips186_4_derive_prime(p, Xpout, Xp, p1i, p2i, nlen, e, ctx, cb))
+ if (!ossl_bn_rsa_fips186_4_derive_prime(p, Xpout, Xp, p1i, p2i, nlen, e,
+ ctx, cb))
goto err;
ret = 1;
err:
@@ -235,9 +237,10 @@ err:
* Assumptions:
* Y, X, r1, r2, e are not NULL.
*/
-int bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin,
- const BIGNUM *r1, const BIGNUM *r2, int nlen,
- const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb)
+int ossl_bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin,
+ const BIGNUM *r1, const BIGNUM *r2,
+ int nlen, const BIGNUM *e, BN_CTX *ctx,
+ BN_GENCB *cb)
{
int ret = 0;
int i, imax;
@@ -270,9 +273,10 @@ int bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin,
* We only have the first 256 bit of 1/sqrt(2)
*/
if (Xin == NULL) {
- if (bits < BN_num_bits(&bn_inv_sqrt_2))
+ if (bits < BN_num_bits(&ossl_bn_inv_sqrt_2))
goto err;
- if (!BN_lshift(base, &bn_inv_sqrt_2, bits - BN_num_bits(&bn_inv_sqrt_2))
+ if (!BN_lshift(base, &ossl_bn_inv_sqrt_2,
+ bits - BN_num_bits(&ossl_bn_inv_sqrt_2))
|| !BN_lshift(range, BN_value_one(), bits)
|| !BN_sub(range, range, base))
goto err;
diff --git a/crypto/dh/dh_rfc5114.c b/crypto/dh/dh_rfc5114.c
index 4e7daaefc7..c578a89a58 100644
--- a/crypto/dh/dh_rfc5114.c
+++ b/crypto/dh/dh_rfc5114.c
@@ -32,9 +32,9 @@ DH *DH_get_##x(void) \
\
if (dh == NULL) \
return NULL; \
- dh->params.p = BN_dup(&_bignum_dh##x##_p); \
- dh->params.g = BN_dup(&_bignum_dh##x##_g); \
- dh->params.q = BN_dup(&_bignum_dh##x##_q); \
+ dh->params.p = BN_dup(&ossl_bignum_dh##x##_p); \
+ dh->params.g = BN_dup(&ossl_bignum_dh##x##_g); \
+ dh->params.q = BN_dup(&ossl_bignum_dh##x##_q); \
if (dh->params.p == NULL || dh->params.q == NULL || dh->params.g == NULL) {\
DH_free(dh); \
return NULL; \
diff --git a/crypto/ec/ec_cvt.c b/crypto/ec/ec_cvt.c
index c841ad741d..00a5c48c8f 100644
--- a/crypto/ec/ec_cvt.c
+++ b/crypto/ec/ec_cvt.c
@@ -54,7 +54,7 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
meth = EC_GFp_mont_method();
#endif
- ret = ec_group_new_ex(bn_get_libctx(ctx), NULL, meth);
+ ret = ec_group_new_ex(ossl_bn_get_libctx(ctx), NULL, meth);
if (ret == NULL)
return NULL;
@@ -75,7 +75,7 @@ EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,
meth = EC_GF2m_simple_method();
- ret = ec_group_new_ex(bn_get_libctx(ctx), NULL, meth);
+ ret = ec_group_new_ex(ossl_bn_get_libctx(ctx), NULL, meth);
if (ret == NULL)
return NULL;
diff --git a/crypto/ffc/ffc_dh.c b/crypto/ffc/ffc_dh.c
index db472febb0..17888e9291 100644
--- a/crypto/ffc/ffc_dh.c
+++ b/crypto/ffc/ffc_dh.c
@@ -17,19 +17,22 @@
# define FFDHE(sz) { \
SN_ffdhe##sz, NID_ffdhe##sz, \
sz, \
- &_bignum_ffdhe##sz##_p, &_bignum_ffdhe##sz##_q, &_bignum_const_2, \
+ &ossl_bignum_ffdhe##sz##_p, &ossl_bignum_ffdhe##sz##_q, \
+ &ossl_bignum_const_2, \
}
# define MODP(sz) { \
SN_modp_##sz, NID_modp_##sz, \
sz, \
- &_bignum_modp_##sz##_p, &_bignum_modp_##sz##_q, &_bignum_const_2 \
+ &ossl_bignum_modp_##sz##_p, &ossl_bignum_modp_##sz##_q, \
+ &ossl_bignum_const_2 \
}
# define RFC5114(name, uid, sz, tag) { \
name, uid, \
sz, \
- &_bignum_dh##tag##_p, &_bignum_dh##tag##_q, &_bignum_dh##tag##_g \
+ &ossl_bignum_dh##tag##_p, &ossl_bignum_dh##tag##_q, \
+ &ossl_bignum_dh##tag##_g \
}
#else
diff --git a/crypto/ffc/ffc_params_generate.c b/crypto/ffc/ffc_params_generate.c
index 2e50c2b801..e0ce7485cf 100644
--- a/crypto/ffc/ffc_params_generate.c
+++ b/crypto/ffc/ffc_params_generate.c
@@ -320,7 +320,7 @@ static int generate_q_fips186_4(BN_CTX *ctx, BIGNUM *q, const EVP_MD *evpmd,
unsigned char md[EVP_MAX_MD_SIZE];
int mdsize = EVP_MD_size(evpmd);
unsigned char *pmd;
- OSSL_LIB_CTX *libctx = bn_get_libctx(ctx);
+ OSSL_LIB_CTX *libctx = ossl_bn_get_libctx(ctx);
/* find q */
for (;;) {
@@ -391,7 +391,7 @@ static int generate_q_fips186_2(BN_CTX *ctx, BIGNUM *q, const EVP_MD *evpmd,
unsigned char buf2[EVP_MAX_MD_SIZE];
unsigned char md[EVP_MAX_MD_SIZE];
int i, r, ret = 0, m = *retm;
- OSSL_LIB_CTX *libctx = bn_get_libctx(ctx);
+ OSSL_LIB_CTX *libctx = ossl_bn_get_libctx(ctx);
/* find q */
for (;;) {
diff --git a/crypto/rsa/rsa_sp800_56b_check.c b/crypto/rsa/rsa_sp800_56b_check.c
index 173bc5e253..c2066236f9 100644
--- a/crypto/rsa/rsa_sp800_56b_check.c
+++ b/crypto/rsa/rsa_sp800_56b_check.c
@@ -92,7 +92,7 @@ int ossl_rsa_check_prime_factor_range(const BIGNUM *p, int nbits, BN_CTX *ctx)
int shift;
nbits >>= 1;
- shift = nbits - BN_num_bits(&bn_inv_sqrt_2);
+ shift = nbits - BN_num_bits(&ossl_bn_inv_sqrt_2);
/* Upper bound check */
if (BN_num_bits(p) != nbits)
@@ -104,12 +104,12 @@ int ossl_rsa_check_prime_factor_range(const BIGNUM *p, int nbits, BN_CTX *ctx)
goto err;
/* set low = (√2)(2^(nbits/2 - 1) */
- if (!BN_copy(low, &bn_inv_sqrt_2))
+ if (!BN_copy(low, &ossl_bn_inv_sqrt_2))
goto err;
if (shift >= 0) {
/*
- * We don't have all the bits. bn_inv_sqrt_2 contains a rounded up
+ * We don't have all the bits. ossl_bn_inv_sqrt_2 contains a rounded up
* value, so there is a very low probability that we'll reject a valid
* value.
*/
@@ -329,12 +329,13 @@ int ossl_rsa_sp800_56b_check_public(const RSA *rsa)
* The modulus is composite, but not a power of a prime.
* The modulus has no factors smaller than 752.
*/
- if (!BN_gcd(gcd, rsa->n, bn_get0_small_factors(), ctx) || !BN_is_one(gcd)) {
+ if (!BN_gcd(gcd, rsa->n, ossl_bn_get0_small_factors(), ctx)
+ || !BN_is_one(gcd)) {
ERR_raise(ERR_LIB_RSA, RSA_R_INVALID_MODULUS);
goto err;
}
- ret = bn_miller_rabin_is_prime(rsa->n, 0, ctx, NULL, 1, &status);
+ ret = ossl_bn_miller_rabin_is_prime(rsa->n, 0, ctx, NULL, 1, &status);
if (ret != 1 || status != BN_PRIMETEST_COMPOSITE_NOT_POWER_OF_PRIME) {
ERR_raise(ERR_LIB_RSA, RSA_R_INVALID_MODULUS);
ret = 0;
diff --git a/crypto/rsa/rsa_sp800_56b_gen.c b/crypto/rsa/rsa_sp800_56b_gen.c
index 3fffb3b80a..87fd4ad50c 100644
--- a/crypto/rsa/rsa_sp800_56b_gen.c
+++ b/crypto/rsa/rsa_sp800_56b_gen.c
@@ -121,13 +121,13 @@ int ossl_rsa_fips186_4_gen_prob_primes(RSA *rsa, RSA_ACVP_TEST *test,
BN_set_flags(rsa->q, BN_FLG_CONSTTIME);
/* (Step 4) Generate p, Xp */
- if (!bn_rsa_fips186_4_gen_prob_primes(rsa->p, Xpo, p1, p2, Xp, Xp1, Xp2,
- nbits, e, ctx, cb))
+ if (!ossl_bn_rsa_fips186_4_gen_prob_primes(rsa->p, Xpo, p1, p2, Xp, Xp1, Xp2,
+ nbits, e, ctx, cb))
goto err;
for(;;) {
/* (Step 5) Generate q, Xq*/
- if (!bn_rsa_fips186_4_gen_prob_primes(rsa->q, Xqo, q1, q2, Xq, Xq1,
- Xq2, nbits, e, ctx, cb))
+ if (!ossl_bn_rsa_fips186_4_gen_prob_primes(rsa->q, Xqo, q1, q2, Xq, Xq1,
+ Xq2, nbits, e, ctx, cb))
goto err;
/* (Step 6) |Xp - Xq| > 2^(nbitlen/2 - 100) */