Namespace crypto/dsa's internal symbols. Down from 865 to 864 unintended exported symbols. Bug: 42220000 Change-Id: I0db9c479d9c12f5bbc532e56440fa2b03e3cbaee Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/86369 Reviewed-by: Xiangfei Ding <xfding@google.com> Commit-Queue: Rudolf Polzer <rpolzer@google.com>
diff --git a/crypto/dsa/dsa.cc b/crypto/dsa/dsa.cc index f280182..6d9c1fd 100644 --- a/crypto/dsa/dsa.cc +++ b/crypto/dsa/dsa.cc
@@ -32,6 +32,8 @@ #include "internal.h" +using namespace bssl; + static_assert(OPENSSL_DSA_MAX_MODULUS_BITS <= BN_MONTGOMERY_MAX_WORDS * BN_BITS2, "Max DSA size too big for Montgomery arithmetic"); @@ -202,11 +204,11 @@ OPENSSL_memcpy(seed, seed_in, seed_len); } - bssl::UniquePtr<BN_CTX> ctx(BN_CTX_new()); + UniquePtr<BN_CTX> ctx(BN_CTX_new()); if (ctx == nullptr) { return 0; } - bssl::BN_CTXScope scope(ctx.get()); + BN_CTXScope scope(ctx.get()); r0 = BN_CTX_get(ctx.get()); g = BN_CTX_get(ctx.get()); @@ -363,7 +365,7 @@ return 0; } - bssl::UniquePtr<BN_MONT_CTX> mont(BN_MONT_CTX_new_for_modulus(p, ctx.get())); + UniquePtr<BN_MONT_CTX> mont(BN_MONT_CTX_new_for_modulus(p, ctx.get())); if (mont == nullptr || !BN_set_word(test, h)) { return 0; } @@ -425,7 +427,7 @@ return 0; } - bssl::UniquePtr<BN_CTX> ctx(BN_CTX_new()); + UniquePtr<BN_CTX> ctx(BN_CTX_new()); if (ctx == nullptr) { return 0; } @@ -517,7 +519,7 @@ // neither inputs nor outputs are in Montgomery form. static int mod_mul_consttime(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BN_MONT_CTX *mont, BN_CTX *ctx) { - bssl::BN_CTXScope scope(ctx); + BN_CTXScope scope(ctx); BIGNUM *tmp = BN_CTX_get(ctx); // |BN_mod_mul_montgomery| removes a factor of R, so we cancel it with a // single |BN_to_montgomery| which adds one factor of R. @@ -918,7 +920,7 @@ return nullptr; } - bssl::UniquePtr<DH> ret(DH_new()); + UniquePtr<DH> ret(DH_new()); if (ret == nullptr) { return nullptr; }
diff --git a/crypto/dsa/dsa_asn1.cc b/crypto/dsa/dsa_asn1.cc index b4ad573..31223e4 100644 --- a/crypto/dsa/dsa_asn1.cc +++ b/crypto/dsa/dsa_asn1.cc
@@ -25,10 +25,12 @@ #include "../bytestring/internal.h" +using namespace bssl; + // This function is in dsa_asn1.c rather than dsa.c because it is reachable from // |EVP_PKEY| parsers. This makes it easier for the static linker to drop most // of the DSA implementation. -int dsa_check_key(const DSA *dsa) { +int bssl::dsa_check_key(const DSA *dsa) { if (!dsa->p || !dsa->q || !dsa->g) { OPENSSL_PUT_ERROR(DSA, DSA_R_MISSING_PARAMETERS); return 0; @@ -136,7 +138,7 @@ } DSA *DSA_parse_public_key(CBS *cbs) { - bssl::UniquePtr<DSA> ret(DSA_new()); + UniquePtr<DSA> ret(DSA_new()); if (ret == nullptr) { return nullptr; } @@ -171,7 +173,7 @@ } DSA *DSA_parse_parameters(CBS *cbs) { - bssl::UniquePtr<DSA> ret(DSA_new()); + UniquePtr<DSA> ret(DSA_new()); if (ret == nullptr) { return nullptr; } @@ -204,7 +206,7 @@ } DSA *DSA_parse_private_key(CBS *cbs) { - bssl::UniquePtr<DSA> ret(DSA_new()); + UniquePtr<DSA> ret(DSA_new()); if (ret == nullptr) { return nullptr; } @@ -255,41 +257,41 @@ } DSA_SIG *d2i_DSA_SIG(DSA_SIG **out_sig, const uint8_t **inp, long len) { - return bssl::D2IFromCBS(out_sig, inp, len, DSA_SIG_parse); + return D2IFromCBS(out_sig, inp, len, DSA_SIG_parse); } int i2d_DSA_SIG(const DSA_SIG *in, uint8_t **outp) { - return bssl::I2DFromCBB( + return I2DFromCBB( /*initial_capacity=*/256, outp, [&](CBB *cbb) -> bool { return DSA_SIG_marshal(cbb, in); }); } DSA *d2i_DSAPublicKey(DSA **out, const uint8_t **inp, long len) { - return bssl::D2IFromCBS(out, inp, len, DSA_parse_public_key); + return D2IFromCBS(out, inp, len, DSA_parse_public_key); } int i2d_DSAPublicKey(const DSA *in, uint8_t **outp) { - return bssl::I2DFromCBB( + return I2DFromCBB( /*initial_capacity=*/256, outp, [&](CBB *cbb) -> bool { return DSA_marshal_public_key(cbb, in); }); } DSA *d2i_DSAPrivateKey(DSA **out, const uint8_t **inp, long len) { - return bssl::D2IFromCBS(out, inp, len, DSA_parse_private_key); + return D2IFromCBS(out, inp, len, DSA_parse_private_key); } int i2d_DSAPrivateKey(const DSA *in, uint8_t **outp) { - return bssl::I2DFromCBB( + return I2DFromCBB( /*initial_capacity=*/256, outp, [&](CBB *cbb) -> bool { return DSA_marshal_private_key(cbb, in); }); } DSA *d2i_DSAparams(DSA **out, const uint8_t **inp, long len) { - return bssl::D2IFromCBS(out, inp, len, DSA_parse_parameters); + return D2IFromCBS(out, inp, len, DSA_parse_parameters); } int i2d_DSAparams(const DSA *in, uint8_t **outp) { - return bssl::I2DFromCBB( + return I2DFromCBB( /*initial_capacity=*/256, outp, [&](CBB *cbb) -> bool { return DSA_marshal_parameters(cbb, in); }); }
diff --git a/crypto/dsa/internal.h b/crypto/dsa/internal.h index a94d436..1726e2b 100644 --- a/crypto/dsa/internal.h +++ b/crypto/dsa/internal.h
@@ -19,10 +19,6 @@ #include "../internal.h" -#if defined(__cplusplus) -extern "C" { -#endif - struct dsa_st { BIGNUM *p; @@ -40,13 +36,12 @@ CRYPTO_EX_DATA ex_data; }; +BSSL_NAMESPACE_BEGIN + // dsa_check_key performs cheap self-checks on |dsa|, and ensures it is within // DoS bounds. It returns one on success and zero on error. int dsa_check_key(const DSA *dsa); - -#if defined(__cplusplus) -} // extern C -#endif +BSSL_NAMESPACE_END #endif // OPENSSL_HEADER_CRYPTO_DSA_INTERNAL_H
diff --git a/crypto/evp/p_dsa.cc b/crypto/evp/p_dsa.cc index 881aca2..7c26dbc 100644 --- a/crypto/evp/p_dsa.cc +++ b/crypto/evp/p_dsa.cc
@@ -24,6 +24,8 @@ #include "internal.h" +using namespace bssl; + namespace { extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meth; @@ -36,7 +38,7 @@ // Decode parameters. RFC 3279 permits DSA parameters to be omitted, in which // case they are implicitly determined from the issuing certificate, or // somewhere unspecified and out-of-band. We do not support this mode. - bssl::UniquePtr<DSA> dsa(DSA_parse_parameters(params)); + UniquePtr<DSA> dsa(DSA_parse_parameters(params)); if (dsa == nullptr || CBS_len(params) != 0) { OPENSSL_PUT_ERROR(EVP, EVP_R_DECODE_ERROR); return evp_decode_error; @@ -84,7 +86,7 @@ // See PKCS#11, v2.40, section 2.5. // Decode parameters. - bssl::UniquePtr<DSA> dsa(DSA_parse_parameters(params)); + UniquePtr<DSA> dsa(DSA_parse_parameters(params)); if (dsa == nullptr || CBS_len(params) != 0) { OPENSSL_PUT_ERROR(EVP, EVP_R_DECODE_ERROR); return evp_decode_error; @@ -108,7 +110,7 @@ } // Calculate the public key. - bssl::UniquePtr<BN_CTX> ctx(BN_CTX_new()); + UniquePtr<BN_CTX> ctx(BN_CTX_new()); dsa->pub_key = BN_new(); if (ctx == nullptr || dsa->pub_key == nullptr || !BN_mod_exp_mont_consttime(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, @@ -164,7 +166,7 @@ } static int dup_bn_into(BIGNUM **out, BIGNUM *src) { - bssl::UniquePtr<BIGNUM> a(BN_dup(src)); + UniquePtr<BIGNUM> a(BN_dup(src)); if (a == nullptr) { return 0; }