diff options
55 files changed, 450 insertions, 701 deletions
diff --git a/crypto/asn1/asn1_test.cc b/crypto/asn1/asn1_test.cc index e3e310bd..8b024427 100644 --- a/crypto/asn1/asn1_test.cc +++ b/crypto/asn1/asn1_test.cc @@ -21,8 +21,6 @@ #include "../test/scoped_types.h" -namespace bssl { - // kTag128 is an ASN.1 structure with a universal tag with number 128. static const uint8_t kTag128[] = { 0x1f, 0x81, 0x00, 0x01, 0x00, @@ -71,12 +69,10 @@ static bool TestLargeTags() { return true; } -} // namespace bssl - int main() { CRYPTO_library_init(); - if (!bssl::TestLargeTags()) { + if (!TestLargeTags()) { return 1; } diff --git a/crypto/bio/bio_test.cc b/crypto/bio/bio_test.cc index e7c061eb..f2eb20ba 100644 --- a/crypto/bio/bio_test.cc +++ b/crypto/bio/bio_test.cc @@ -43,8 +43,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #include "../test/scoped_types.h" -namespace bssl { - #if !defined(OPENSSL_WINDOWS) static int closesocket(int sock) { return close(sock); @@ -341,7 +339,7 @@ static bool ReadASN1(bool should_succeed, const uint8_t *data, size_t data_len, if (!ok) { out = nullptr; } - ScopedBytes out_storage(out); + ScopedOpenSSLBytes out_storage(out); if (should_succeed != (ok == 1)) { return false; @@ -371,7 +369,7 @@ static bool TestASN1() { static const size_t kLargePayloadLen = 8000; static const uint8_t kLargePrefix[] = {0x30, 0x82, kLargePayloadLen >> 8, kLargePayloadLen & 0xff}; - ScopedBytes large(reinterpret_cast<uint8_t *>( + ScopedOpenSSLBytes large(reinterpret_cast<uint8_t *>( OPENSSL_malloc(sizeof(kLargePrefix) + kLargePayloadLen))); if (!large) { return false; @@ -412,8 +410,6 @@ static bool TestASN1() { return true; } -} // namespace bssl - int main(void) { CRYPTO_library_init(); @@ -432,10 +428,10 @@ int main(void) { } #endif - if (!bssl::TestSocketConnect() || - !bssl::TestPrintf() || - !bssl::TestZeroCopyBioPairs() || - !bssl::TestASN1()) { + if (!TestSocketConnect() || + !TestPrintf() || + !TestZeroCopyBioPairs() || + !TestASN1()) { return 1; } diff --git a/crypto/bn/bn_test.cc b/crypto/bn/bn_test.cc index 3028745c..3405cbdc 100644 --- a/crypto/bn/bn_test.cc +++ b/crypto/bn/bn_test.cc @@ -90,8 +90,6 @@ #include "../crypto/test/test_util.h" -namespace bssl { - static int HexToBIGNUM(ScopedBIGNUM *out, const char *in) { BIGNUM *raw = NULL; int ret = BN_hex2bn(&raw, in); @@ -134,8 +132,8 @@ static bool ExpectBIGNUMsEqual(FileTest *t, const char *operation, return true; } - ScopedString expected_str(BN_bn2hex(expected)); - ScopedString actual_str(BN_bn2hex(actual)); + ScopedOpenSSLString expected_str(BN_bn2hex(expected)); + ScopedOpenSSLString actual_str(BN_bn2hex(actual)); if (!expected_str || !actual_str) { return false; } @@ -999,7 +997,7 @@ static bool TestASN1() { CBB_cleanup(&cbb); return false; } - ScopedBytes delete_der(der); + ScopedOpenSSLBytes delete_der(der); if (der_len != test.der_len || memcmp(der, reinterpret_cast<const uint8_t*>(test.der), der_len) != 0) { fprintf(stderr, "Bad serialization.\n"); @@ -1265,8 +1263,6 @@ static bool TestSmallPrime(BN_CTX *ctx) { return true; } -} // namespace bssl - int main(int argc, char *argv[]) { CRYPTO_library_init(); @@ -1275,24 +1271,24 @@ int main(int argc, char *argv[]) { return 1; } - bssl::ScopedBN_CTX ctx(BN_CTX_new()); + ScopedBN_CTX ctx(BN_CTX_new()); if (!ctx) { return 1; } - if (!bssl::TestBN2BinPadded(ctx.get()) || - !bssl::TestDec2BN(ctx.get()) || - !bssl::TestHex2BN(ctx.get()) || - !bssl::TestASC2BN(ctx.get()) || - !bssl::TestMPI() || - !bssl::TestRand() || - !bssl::TestASN1() || - !bssl::TestNegativeZero(ctx.get()) || - !bssl::TestBadModulus(ctx.get()) || - !bssl::TestExpModZero() || - !bssl::TestSmallPrime(ctx.get())) { + if (!TestBN2BinPadded(ctx.get()) || + !TestDec2BN(ctx.get()) || + !TestHex2BN(ctx.get()) || + !TestASC2BN(ctx.get()) || + !TestMPI() || + !TestRand() || + !TestASN1() || + !TestNegativeZero(ctx.get()) || + !TestBadModulus(ctx.get()) || + !TestExpModZero() || + !TestSmallPrime(ctx.get())) { return 1; } - return bssl::FileTestMain(bssl::RunTest, ctx.get(), argv[1]); + return FileTestMain(RunTest, ctx.get(), argv[1]); } diff --git a/crypto/bytestring/bytestring_test.cc b/crypto/bytestring/bytestring_test.cc index 95d9b85c..31ee51c4 100644 --- a/crypto/bytestring/bytestring_test.cc +++ b/crypto/bytestring/bytestring_test.cc @@ -29,8 +29,6 @@ #include "../test/scoped_types.h" -namespace bssl { - static bool TestSkip() { static const uint8_t kData[] = {1, 2, 3}; CBS data; @@ -294,7 +292,7 @@ static bool TestCBBBasic() { return false; } - ScopedBytes scoper(buf); + ScopedOpenSSLBytes scoper(buf); return buf_len == sizeof(kExpected) && memcmp(buf, kExpected, buf_len) == 0; } @@ -339,7 +337,7 @@ static bool TestCBBFinishChild() { CBB_cleanup(&cbb); return false; } - ScopedBytes scoper(out_buf); + ScopedOpenSSLBytes scoper(out_buf); return out_size == 1 && out_buf[0] == 0; } @@ -372,7 +370,7 @@ static bool TestCBBPrefixed() { return false; } - ScopedBytes scoper(buf); + ScopedOpenSSLBytes scoper(buf); return buf_len == sizeof(kExpected) && memcmp(buf, kExpected, buf_len) == 0; } @@ -412,7 +410,7 @@ static bool TestCBBDiscardChild() { if (!CBB_finish(cbb.get(), &buf, &buf_len)) { return false; } - ScopedBytes scoper(buf); + ScopedOpenSSLBytes scoper(buf); static const uint8_t kExpected[] = { 0xaa, @@ -458,7 +456,7 @@ static bool TestCBBMisuse() { CBB_cleanup(&cbb); return false; } - ScopedBytes scoper(buf); + ScopedOpenSSLBytes scoper(buf); if (buf_len != 3 || memcmp(buf, "\x01\x01\x02", 3) != 0) { @@ -482,7 +480,7 @@ static bool TestCBBASN1() { CBB_cleanup(&cbb); return false; } - ScopedBytes scoper(buf); + ScopedOpenSSLBytes scoper(buf); if (buf_len != sizeof(kExpected) || memcmp(buf, kExpected, buf_len) != 0) { return false; @@ -557,7 +555,7 @@ static bool DoBerConvert(const char *name, fprintf(stderr, "%s: CBS_asn1_ber_to_der failed.\n", name); return false; } - ScopedBytes scoper(out); + ScopedOpenSSLBytes scoper(out); if (out == NULL) { if (ber_len != der_len || @@ -670,7 +668,7 @@ static bool TestImplicitString() { int ok = CBS_get_asn1_implicit_string(&in, &out, &storage, CBS_ASN1_CONTEXT_SPECIFIC | 0, CBS_ASN1_OCTETSTRING); - ScopedBytes scoper(storage); + ScopedOpenSSLBytes scoper(storage); if (static_cast<bool>(ok) != test.ok) { fprintf(stderr, "CBS_get_asn1_implicit_string unexpectedly %s\n", @@ -749,7 +747,7 @@ static bool TestASN1Uint64() { CBB_cleanup(&cbb); return false; } - ScopedBytes scoper(out); + ScopedOpenSSLBytes scoper(out); if (len != test->encoding_len || memcmp(out, test->encoding, len) != 0) { return false; } @@ -799,29 +797,27 @@ static bool TestCBBReserve() { return true; } -} // namespace bssl - int main(void) { CRYPTO_library_init(); - if (!bssl::TestSkip() || - !bssl::TestGetUint() || - !bssl::TestGetPrefixed() || - !bssl::TestGetPrefixedBad() || - !bssl::TestGetASN1() || - !bssl::TestCBBBasic() || - !bssl::TestCBBFixed() || - !bssl::TestCBBFinishChild() || - !bssl::TestCBBMisuse() || - !bssl::TestCBBPrefixed() || - !bssl::TestCBBDiscardChild() || - !bssl::TestCBBASN1() || - !bssl::TestBerConvert() || - !bssl::TestImplicitString() || - !bssl::TestASN1Uint64() || - !bssl::TestGetOptionalASN1Bool() || - !bssl::TestZero() || - !bssl::TestCBBReserve()) { + if (!TestSkip() || + !TestGetUint() || + !TestGetPrefixed() || + !TestGetPrefixedBad() || + !TestGetASN1() || + !TestCBBBasic() || + !TestCBBFixed() || + !TestCBBFinishChild() || + !TestCBBMisuse() || + !TestCBBPrefixed() || + !TestCBBDiscardChild() || + !TestCBBASN1() || + !TestBerConvert() || + !TestImplicitString() || + !TestASN1Uint64() || + !TestGetOptionalASN1Bool() || + !TestZero() || + !TestCBBReserve()) { return 1; } diff --git a/crypto/cipher/aead_test.cc b/crypto/cipher/aead_test.cc index cf0f24a6..8bad93f5 100644 --- a/crypto/cipher/aead_test.cc +++ b/crypto/cipher/aead_test.cc @@ -25,8 +25,6 @@ #include "../test/scoped_types.h" -namespace bssl { - // This program tests an AEAD against a series of test vectors from a file, // using the FileTest format. As an example, here's a valid test case: // @@ -329,7 +327,7 @@ static const struct KnownAEAD kAEADs[] = { { "", NULL, false }, }; -static int Main(int argc, char **argv) { +int main(int argc, char **argv) { CRYPTO_library_init(); if (argc != 3) { @@ -362,9 +360,3 @@ static int Main(int argc, char **argv) { return FileTestMain(TestAEAD, const_cast<EVP_AEAD*>(aead), argv[2]); } - -} // namespace bssl - -int main(int argc, char **argv) { - return bssl::Main(argc, argv); -} diff --git a/crypto/cipher/cipher_test.cc b/crypto/cipher/cipher_test.cc index 221eb67e..fa384c69 100644 --- a/crypto/cipher/cipher_test.cc +++ b/crypto/cipher/cipher_test.cc @@ -65,8 +65,6 @@ #include "../test/scoped_types.h" -namespace bssl { - static const EVP_CIPHER *GetCipher(const std::string &name) { if (name == "DES-CBC") { return EVP_des_cbc(); @@ -286,8 +284,6 @@ static bool TestCipher(FileTest *t, void *arg) { return true; } -} // namespace bssl - int main(int argc, char **argv) { CRYPTO_library_init(); @@ -296,5 +292,5 @@ int main(int argc, char **argv) { return 1; } - return bssl::FileTestMain(bssl::TestCipher, nullptr, argv[1]); + return FileTestMain(TestCipher, nullptr, argv[1]); } diff --git a/crypto/cmac/cmac_test.cc b/crypto/cmac/cmac_test.cc index 11b7ad69..2496f2a9 100644 --- a/crypto/cmac/cmac_test.cc +++ b/crypto/cmac/cmac_test.cc @@ -22,8 +22,6 @@ #include "../test/test_util.h" -namespace bssl { - static void dump(const uint8_t *got, const uint8_t *want, size_t len) { hexdump(stderr, "got :", got, len); hexdump(stderr, "want:", want, len); @@ -143,10 +141,8 @@ static int rfc_4493_test_vectors(void) { return 1; } -} // namespace bssl - int main(int argc, char **argv) { - if (!bssl::rfc_4493_test_vectors()) { + if (!rfc_4493_test_vectors()) { return 1; } diff --git a/crypto/curve25519/ed25519_test.cc b/crypto/curve25519/ed25519_test.cc index 3c08cc9a..1b6a0b61 100644 --- a/crypto/curve25519/ed25519_test.cc +++ b/crypto/curve25519/ed25519_test.cc @@ -20,8 +20,6 @@ #include "../test/file_test.h" -namespace bssl { - static bool TestSignature(FileTest *t, void *arg) { std::vector<uint8_t> private_key, public_key, message, expected_signature; if (!t->GetBytes(&private_key, "PRIV") || @@ -55,13 +53,11 @@ static bool TestSignature(FileTest *t, void *arg) { return true; } -} // namespace bssl - int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "%s <test input.txt>\n", argv[0]); return 1; } - return bssl::FileTestMain(bssl::TestSignature, nullptr, argv[1]); + return FileTestMain(TestSignature, nullptr, argv[1]); } diff --git a/crypto/curve25519/spake25519_test.cc b/crypto/curve25519/spake25519_test.cc index b8742ed9..d97a8602 100644 --- a/crypto/curve25519/spake25519_test.cc +++ b/crypto/curve25519/spake25519_test.cc @@ -22,8 +22,6 @@ #include "../test/scoped_types.h" -namespace bssl { - struct SPAKE2Run { bool Run() { ScopedSPAKE2_CTX alice(SPAKE2_CTX_new( @@ -156,15 +154,13 @@ static bool TestCorruptMessages() { return true; } -} // namespace bssl - /* TODO(agl): add tests with fixed vectors once SPAKE2 is nailed down. */ int main(int argc, char **argv) { - if (!bssl::TestSPAKE2() || - !bssl::TestWrongPassword() || - !bssl::TestWrongNames() || - !bssl::TestCorruptMessages()) { + if (!TestSPAKE2() || + !TestWrongPassword() || + !TestWrongNames() || + !TestCorruptMessages()) { return 1; } diff --git a/crypto/dh/dh_test.cc b/crypto/dh/dh_test.cc index 8fe496c9..1c244283 100644 --- a/crypto/dh/dh_test.cc +++ b/crypto/dh/dh_test.cc @@ -71,7 +71,25 @@ #include "../test/scoped_types.h" -namespace bssl { +static bool RunBasicTests(); +static bool RunRFC5114Tests(); +static bool TestBadY(); +static bool TestASN1(); + +int main(int argc, char *argv[]) { + CRYPTO_library_init(); + + if (!RunBasicTests() || + !RunRFC5114Tests() || + !TestBadY() || + !TestASN1()) { + ERR_print_errors_fp(stderr); + return 1; + } + + printf("PASS\n"); + return 0; +} static int GenerateCallback(int p, int n, BN_GENCB *arg) { char c = '*'; @@ -557,7 +575,7 @@ static bool TestASN1() { !CBB_finish(cbb.get(), &der, &der_len)) { return false; } - ScopedBytes free_der(der); + ScopedOpenSSLBytes free_der(der); if (der_len != sizeof(kParams) || memcmp(der, kParams, der_len) != 0) { return false; } @@ -599,27 +617,10 @@ static bool TestASN1() { !CBB_finish(cbb.get(), &der, &der_len)) { return false; } - ScopedBytes free_der2(der); + ScopedOpenSSLBytes free_der2(der); if (der_len != sizeof(kParamsDSA) || memcmp(der, kParamsDSA, der_len) != 0) { return false; } return true; } - -} // namespace bssl - -int main(int argc, char *argv[]) { - CRYPTO_library_init(); - - if (!bssl::RunBasicTests() || - !bssl::RunRFC5114Tests() || - !bssl::TestBadY() || - !bssl::TestASN1()) { - ERR_print_errors_fp(stderr); - return 1; - } - - printf("PASS\n"); - return 0; -} diff --git a/crypto/digest/digest_test.cc b/crypto/digest/digest_test.cc index 32d12d24..39ceaffc 100644 --- a/crypto/digest/digest_test.cc +++ b/crypto/digest/digest_test.cc @@ -26,8 +26,6 @@ #include "../test/scoped_types.h" -namespace bssl { - struct MD { // name is the name of the digest. const char* name; @@ -245,7 +243,7 @@ static int TestGetters() { return true; } -static int Main() { +int main(void) { CRYPTO_library_init(); for (size_t i = 0; i < sizeof(kTestVectors) / sizeof(kTestVectors[0]); i++) { @@ -262,9 +260,3 @@ static int Main() { printf("PASS\n"); return 0; } - -} // namespace bssl - -int main() { - return bssl::Main(); -} diff --git a/crypto/ec/ec_test.cc b/crypto/ec/ec_test.cc index 864cd499..23befeb2 100644 --- a/crypto/ec/ec_test.cc +++ b/crypto/ec/ec_test.cc @@ -26,8 +26,6 @@ #include "../test/scoped_types.h" -namespace bssl { - // kECKeyWithoutPublic is an ECPrivateKey with the optional publicKey field // omitted. static const uint8_t kECKeyWithoutPublic[] = { @@ -163,8 +161,8 @@ static bool Testd2i_ECPrivateKey() { fprintf(stderr, "Failed to get public key in affine coordinates.\n"); return false; } - ScopedString x_hex(BN_bn2hex(x.get())); - ScopedString y_hex(BN_bn2hex(y.get())); + ScopedOpenSSLString x_hex(BN_bn2hex(x.get())); + ScopedOpenSSLString y_hex(BN_bn2hex(y.get())); if (!x_hex || !y_hex) { return false; } @@ -473,17 +471,15 @@ static bool ForEachCurve(bool (*test_func)(int nid)) { return true; } -} // namespace bssl - int main(void) { CRYPTO_library_init(); - if (!bssl::Testd2i_ECPrivateKey() || - !bssl::TestZeroPadding() || - !bssl::TestSpecifiedCurve() || - !bssl::ForEachCurve(bssl::TestSetAffine) || - !bssl::ForEachCurve(bssl::TestAddingEqualPoints) || - !bssl::TestArbitraryCurve()) { + if (!Testd2i_ECPrivateKey() || + !TestZeroPadding() || + !TestSpecifiedCurve() || + !ForEachCurve(TestSetAffine) || + !ForEachCurve(TestAddingEqualPoints) || + !TestArbitraryCurve()) { fprintf(stderr, "failed\n"); return 1; } diff --git a/crypto/ecdsa/ecdsa_test.cc b/crypto/ecdsa/ecdsa_test.cc index ad2325b6..8d7827df 100644 --- a/crypto/ecdsa/ecdsa_test.cc +++ b/crypto/ecdsa/ecdsa_test.cc @@ -64,9 +64,6 @@ #include "../test/scoped_types.h" - -namespace bssl { - enum Api { kEncodedApi, kRawApi, @@ -85,7 +82,7 @@ static bool VerifyECDSASig(Api api, const uint8_t *digest, if (!ECDSA_SIG_to_bytes(&der, &der_len, ecdsa_sig)) { return false; } - ScopedBytes delete_der(der); + ScopedOpenSSLBytes delete_der(der); actual_result = ECDSA_verify(0, digest, digest_len, der, der_len, eckey); break; } @@ -331,7 +328,7 @@ static bool TestECDSA_SIG_max_len(size_t order_len) { if (!ECDSA_SIG_to_bytes(&der, &der_len, sig.get())) { return false; } - ScopedBytes delete_der(der); + ScopedOpenSSLBytes delete_der(der); size_t max_len = ECDSA_SIG_max_len(order_len); if (max_len != der_len) { @@ -343,8 +340,6 @@ static bool TestECDSA_SIG_max_len(size_t order_len) { return true; } -} // namespace bssl - static size_t BitsToBytes(size_t bits) { return (bits / 8) + (7 + (bits % 8)) / 8; } @@ -352,12 +347,12 @@ static size_t BitsToBytes(size_t bits) { int main(void) { CRYPTO_library_init(); - if (!bssl::TestBuiltin(stdout) || - !bssl::TestECDSA_SIG_max_len(BitsToBytes(224)) || - !bssl::TestECDSA_SIG_max_len(BitsToBytes(256)) || - !bssl::TestECDSA_SIG_max_len(BitsToBytes(384)) || - !bssl::TestECDSA_SIG_max_len(BitsToBytes(521)) || - !bssl::TestECDSA_SIG_max_len(BitsToBytes(10000))) { + if (!TestBuiltin(stdout) || + !TestECDSA_SIG_max_len(BitsToBytes(224)) || + !TestECDSA_SIG_max_len(BitsToBytes(256)) || + !TestECDSA_SIG_max_len(BitsToBytes(384)) || + !TestECDSA_SIG_max_len(BitsToBytes(521)) || + !TestECDSA_SIG_max_len(BitsToBytes(10000))) { printf("\nECDSA test failed\n"); ERR_print_errors_fp(stdout); return 1; diff --git a/crypto/evp/evp_extra_test.cc b/crypto/evp/evp_extra_test.cc index 2253c56b..9bc36ad8 100644 --- a/crypto/evp/evp_extra_test.cc +++ b/crypto/evp/evp_extra_test.cc @@ -30,8 +30,6 @@ #include "../test/scoped_types.h" -namespace bssl { - // kExampleRSAKeyDER is an RSA private key in ASN.1, DER format. Of course, you // should never use this key anywhere but in an example. static const uint8_t kExampleRSAKeyDER[] = { @@ -673,7 +671,7 @@ static bool Testd2i_PrivateKey(void) { return true; } -static int Main() { +int main(void) { CRYPTO_library_init(); if (!TestEVP_DigestSignInit()) { @@ -721,9 +719,3 @@ static int Main() { printf("PASS\n"); return 0; } - -} // namespace bssl - -int main() { - return bssl::Main(); -} diff --git a/crypto/evp/evp_test.cc b/crypto/evp/evp_test.cc index 9b8a6839..b01d1e47 100644 --- a/crypto/evp/evp_test.cc +++ b/crypto/evp/evp_test.cc @@ -77,8 +77,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #include "../test/scoped_types.h" -namespace bssl { - // evp_test dispatches between multiple test types. PrivateKey tests take a key // name parameter and single block, decode it as a PEM private key, and save it // under that key name. Decrypt, Sign, and Verify tests take a previously @@ -151,7 +149,7 @@ static bool ImportKey(FileTest *t, KeyMap *key_map, !CBB_finish(cbb.get(), &der, &der_len)) { return false; } - ScopedBytes free_der(der); + ScopedOpenSSLBytes free_der(der); std::vector<uint8_t> output = input; if (t->HasAttribute("Output") && @@ -255,8 +253,6 @@ static bool TestEVP(FileTest *t, void *arg) { return true; } -} // namespace bssl - int main(int argc, char **argv) { CRYPTO_library_init(); if (argc != 2) { @@ -264,6 +260,6 @@ int main(int argc, char **argv) { return 1; } - bssl::KeyMap map; - return bssl::FileTestMain(bssl::TestEVP, &map, argv[1]); + KeyMap map; + return FileTestMain(TestEVP, &map, argv[1]); } diff --git a/crypto/hmac/hmac_test.cc b/crypto/hmac/hmac_test.cc index ba84cc22..da390ef8 100644 --- a/crypto/hmac/hmac_test.cc +++ b/crypto/hmac/hmac_test.cc @@ -68,8 +68,6 @@ #include "../test/scoped_types.h" -namespace bssl { - static const EVP_MD *GetDigest(const std::string &name) { if (name == "MD5") { return EVP_md5(); @@ -154,8 +152,6 @@ static bool TestHMAC(FileTest *t, void *arg) { return true; } -} // namespace bssl - int main(int argc, char *argv[]) { CRYPTO_library_init(); @@ -164,5 +160,5 @@ int main(int argc, char *argv[]) { return 1; } - return bssl::FileTestMain(bssl::TestHMAC, nullptr, argv[1]); + return FileTestMain(TestHMAC, nullptr, argv[1]); } diff --git a/crypto/newhope/newhope_statistical_test.cc b/crypto/newhope/newhope_statistical_test.cc index d3a54430..44fac48a 100644 --- a/crypto/newhope/newhope_statistical_test.cc +++ b/crypto/newhope/newhope_statistical_test.cc @@ -25,8 +25,6 @@ #include "internal.h" -namespace bssl { - static const unsigned kNumTests = 1000; static bool TestNoise(void) { @@ -148,11 +146,9 @@ static bool TestKeys(void) { return true; } -} // namespace bssl - int main(void) { - if (!bssl::TestKeys() || - !bssl::TestNoise()) { + if (!TestKeys() || + !TestNoise()) { return 1; } printf("PASS\n"); diff --git a/crypto/newhope/newhope_test.cc b/crypto/newhope/newhope_test.cc index d94eee8f..6637393f 100644 --- a/crypto/newhope/newhope_test.cc +++ b/crypto/newhope/newhope_test.cc @@ -23,8 +23,6 @@ #include "internal.h" -namespace bssl { - // Set to 10 for quick execution. Tested up to 1,000,000. static const int kNumTests = 10; @@ -130,13 +128,11 @@ static bool TestInvalidAcceptMsg(void) { return true; } -} // namespace bssl - int main(void) { - for (int i = 0; i < bssl::kNumTests; i++) { - if (!bssl::TestKeys() || - !bssl::TestInvalidSK() || - !bssl::TestInvalidAcceptMsg()) { + for (int i = 0; i < kNumTests; i++) { + if (!TestKeys() || + !TestInvalidSK() || + !TestInvalidAcceptMsg()) { return 1; } } diff --git a/crypto/newhope/newhope_vectors_test.cc b/crypto/newhope/newhope_vectors_test.cc index 691d693b..fe84cd4b 100644 --- a/crypto/newhope/newhope_vectors_test.cc +++ b/crypto/newhope/newhope_vectors_test.cc @@ -24,8 +24,6 @@ #include "internal.h" -namespace bssl { - static bool TestNewhope(FileTest *t, void *arg) { ScopedNEWHOPE_POLY a(NEWHOPE_POLY_new()); ScopedNEWHOPE_POLY s(NEWHOPE_POLY_new()), sp(NEWHOPE_POLY_new()); @@ -112,8 +110,6 @@ static bool TestNewhope(FileTest *t, void *arg) { } } -} // namespace bssl - int main(int argc, char **argv) { CRYPTO_library_init(); @@ -122,5 +118,5 @@ int main(int argc, char **argv) { return 1; } - return bssl::FileTestMain(bssl::TestNewhope, nullptr, argv[1]); + return FileTestMain(TestNewhope, nullptr, argv[1]); } diff --git a/crypto/pkcs8/pkcs12_test.cc b/crypto/pkcs8/pkcs12_test.cc index 10694446..17bcd273 100644 --- a/crypto/pkcs8/pkcs12_test.cc +++ b/crypto/pkcs8/pkcs12_test.cc @@ -681,8 +681,6 @@ static const uint8_t kWindows[] = { 0xfe, 0x3a, 0x66, 0x47, 0x40, 0x49, 0x02, 0x02, 0x07, 0xd0, }; -namespace bssl { - static const char kPassword[] = "foo"; static bool Test(const char *name, const uint8_t *der, size_t der_len) { @@ -757,15 +755,13 @@ static bool TestCompat(const uint8_t *der, size_t der_len) { return true; } -} // namespace bssl - int main(int argc, char **argv) { CRYPTO_library_init(); - if (!bssl::Test("OpenSSL", kOpenSSL, sizeof(kOpenSSL)) || - !bssl::Test("NSS", kNSS, sizeof(kNSS)) || - !bssl::Test("Windows", kWindows, sizeof(kWindows)) || - !bssl::TestCompat(kWindows, sizeof(kWindows))) { + if (!Test("OpenSSL", kOpenSSL, sizeof(kOpenSSL)) || + !Test("NSS", kNSS, sizeof(kNSS)) || + !Test("Windows", kWindows, sizeof(kWindows)) || + !TestCompat(kWindows, sizeof(kWindows))) { return 1; } diff --git a/crypto/pkcs8/pkcs8_test.cc b/crypto/pkcs8/pkcs8_test.cc index e54a6997..7a88ddf4 100644 --- a/crypto/pkcs8/pkcs8_test.cc +++ b/crypto/pkcs8/pkcs8_test.cc @@ -62,9 +62,7 @@ static const uint8_t kDER[] = { 0xd6, 0x2d, }; -namespace bssl { - -static bool Test(const uint8_t *der, size_t der_len) { +static bool test(const uint8_t *der, size_t der_len) { const uint8_t *data = der; ScopedX509_SIG sig(d2i_X509_SIG(NULL, &data, der_len)); if (sig.get() == NULL || data != der + der_len) { @@ -83,10 +81,8 @@ static bool Test(const uint8_t *der, size_t der_len) { return true; } -} // namespace bssl - int main(int argc, char **argv) { - if (!bssl::Test(kDER, sizeof(kDER))) { + if (!test(kDER, sizeof(kDER))) { return 1; } diff --git a/crypto/poly1305/poly1305_test.cc b/crypto/poly1305/poly1305_test.cc index a3272250..2c25e93b 100644 --- a/crypto/poly1305/poly1305_test.cc +++ b/crypto/poly1305/poly1305_test.cc @@ -24,8 +24,6 @@ #include "../test/file_test.h" -namespace bssl { - static bool TestSIMD(FileTest *t, unsigned excess, const std::vector<uint8_t> &key, const std::vector<uint8_t> &in, @@ -121,8 +119,6 @@ static bool TestPoly1305(FileTest *t, void *arg) { return true; } -} // namespace bssl - int main(int argc, char **argv) { CRYPTO_library_init(); @@ -131,5 +127,5 @@ int main(int argc, char **argv) { return 1; } - return bssl::FileTestMain(bssl::TestPoly1305, nullptr, argv[1]); + return FileTestMain(TestPoly1305, nullptr, argv[1]); } diff --git a/crypto/rsa/rsa_test.cc b/crypto/rsa/rsa_test.cc index 5307f2cb..62177a4c 100644 --- a/crypto/rsa/rsa_test.cc +++ b/crypto/rsa/rsa_test.cc @@ -523,8 +523,6 @@ static const uint8_t kExponent1RSAKey[] = { 0xdd, 0x02, 0x01, 0x01, }; -namespace bssl { - static bool TestRSA(const uint8_t *der, size_t der_len, const uint8_t *oaep_ciphertext, size_t oaep_ciphertext_len) { @@ -857,7 +855,7 @@ static bool TestASN1() { if (!RSA_private_key_to_bytes(&der, &der_len, rsa.get())) { return false; } - ScopedBytes delete_der(der); + ScopedOpenSSLBytes delete_der(der); if (der_len != sizeof(kKey1) - 1 || memcmp(der, kKey1, der_len) != 0) { return false; } @@ -880,7 +878,7 @@ static bool TestASN1() { if (!RSA_public_key_to_bytes(&der2, &der2_len, rsa.get())) { return false; } - ScopedBytes delete_der2(der2); + ScopedOpenSSLBytes delete_der2(der2); if (der_len != der2_len || memcmp(der, der2, der_len) != 0) { return false; } @@ -924,32 +922,30 @@ static bool TestBadExponent() { return true; } -} // namespace bssl - int main(int argc, char *argv[]) { CRYPTO_library_init(); - if (!bssl::TestRSA(kKey1, sizeof(kKey1) - 1, kOAEPCiphertext1, - sizeof(kOAEPCiphertext1) - 1) || - !bssl::TestRSA(kKey2, sizeof(kKey2) - 1, kOAEPCiphertext2, - sizeof(kOAEPCiphertext2) - 1) || - !bssl::TestRSA(kKey3, sizeof(kKey3) - 1, kOAEPCiphertext3, - sizeof(kOAEPCiphertext3) - 1) || - !bssl::TestOnlyDGiven() || - !bssl::TestRecoverCRTParams() || - !bssl::TestBadKey() || - !bssl::TestMultiPrimeKey(2, kTwoPrimeKey, sizeof(kTwoPrimeKey) - 1, - kTwoPrimeEncryptedMessage, - sizeof(kTwoPrimeEncryptedMessage)) || - !bssl::TestMultiPrimeKey(3, kThreePrimeKey, sizeof(kThreePrimeKey) - 1, - kThreePrimeEncryptedMessage, - sizeof(kThreePrimeEncryptedMessage)) || - !bssl::TestMultiPrimeKey(6, kSixPrimeKey, sizeof(kSixPrimeKey) - 1, - kSixPrimeEncryptedMessage, - sizeof(kSixPrimeEncryptedMessage)) || - !bssl::TestMultiPrimeKeygen() || - !bssl::TestASN1() || - !bssl::TestBadExponent()) { + if (!TestRSA(kKey1, sizeof(kKey1) - 1, kOAEPCiphertext1, + sizeof(kOAEPCiphertext1) - 1) || + !TestRSA(kKey2, sizeof(kKey2) - 1, kOAEPCiphertext2, + sizeof(kOAEPCiphertext2) - 1) || + !TestRSA(kKey3, sizeof(kKey3) - 1, kOAEPCiphertext3, + sizeof(kOAEPCiphertext3) - 1) || + !TestOnlyDGiven() || + !TestRecoverCRTParams() || + !TestBadKey() || + !TestMultiPrimeKey(2, kTwoPrimeKey, sizeof(kTwoPrimeKey) - 1, + kTwoPrimeEncryptedMessage, + sizeof(kTwoPrimeEncryptedMessage)) || + !TestMultiPrimeKey(3, kThreePrimeKey, sizeof(kThreePrimeKey) - 1, + kThreePrimeEncryptedMessage, + sizeof(kThreePrimeEncryptedMessage)) || + !TestMultiPrimeKey(6, kSixPrimeKey, sizeof(kSixPrimeKey) - 1, + kSixPrimeEncryptedMessage, + sizeof(kSixPrimeEncryptedMessage)) || + !TestMultiPrimeKeygen() || + !TestASN1() || + !TestBadExponent()) { return 1; } diff --git a/crypto/test/file_test.cc b/crypto/test/file_test.cc index 7e99316d..d684aa09 100644 --- a/crypto/test/file_test.cc +++ b/crypto/test/file_test.cc @@ -25,8 +25,6 @@ #include <openssl/err.h> -namespace bssl { - FileTest::FileTest(const char *path) { file_ = fopen(path, "r"); if (file_ == nullptr) { @@ -302,5 +300,3 @@ int FileTestMain(bool (*run_test)(FileTest *t, void *arg), void *arg, printf("PASS\n"); return 0; } - -} // namespace bssl diff --git a/crypto/test/file_test.h b/crypto/test/file_test.h index 447b1ee6..a8591277 100644 --- a/crypto/test/file_test.h +++ b/crypto/test/file_test.h @@ -30,9 +30,6 @@ OPENSSL_MSVC_PRAGMA(warning(disable: 4702)) OPENSSL_MSVC_PRAGMA(warning(pop)) - -namespace bssl { - // File-based test framework. // // This module provides a file-based test framework. The file format is based on @@ -156,7 +153,5 @@ class FileTest { int FileTestMain(bool (*run_test)(FileTest *t, void *arg), void *arg, const char *path); -} // namespace bssl - #endif /* OPENSSL_HEADER_CRYPTO_TEST_FILE_TEST_H */ diff --git a/crypto/test/scoped_types.h b/crypto/test/scoped_types.h index 7e4a48e8..2a2c3713 100644 --- a/crypto/test/scoped_types.h +++ b/crypto/test/scoped_types.h @@ -15,8 +15,6 @@ #ifndef OPENSSL_HEADER_CRYPTO_TEST_SCOPED_TYPES_H #define OPENSSL_HEADER_CRYPTO_TEST_SCOPED_TYPES_H -#include <openssl/base.h> - #include <stdint.h> #include <stdio.h> @@ -42,7 +40,28 @@ #include <openssl/stack.h> #include <openssl/x509.h> -namespace bssl { + +template<typename T, void (*func)(T*)> +struct OpenSSLDeleter { + void operator()(T *obj) { + func(obj); + } +}; + +template<typename StackType, typename T, void (*func)(T*)> +struct OpenSSLStackDeleter { + void operator()(StackType *obj) { + sk_pop_free(reinterpret_cast<_STACK*>(obj), + reinterpret_cast<void (*)(void *)>(func)); + } +}; + +template<typename T> +struct OpenSSLFree { + void operator()(T *buf) { + OPENSSL_free(buf); + } +}; struct FileCloser { void operator()(FILE *file) { @@ -50,48 +69,77 @@ struct FileCloser { } }; -using ScopedASN1_TYPE = ScopedType<ASN1_TYPE, ASN1_TYPE_free>; -using ScopedBIO = ScopedType<BIO, BIO_vfree>; -using ScopedBIGNUM = ScopedType<BIGNUM, BN_free>; -using ScopedBN_CTX = ScopedType<BN_CTX, BN_CTX_free>; -using ScopedBN_MONT_CTX = ScopedType<BN_MONT_CTX, BN_MONT_CTX_free>; -using ScopedCMAC_CTX = ScopedType<CMAC_CTX, CMAC_CTX_free>; -using ScopedDH = ScopedType<DH, DH_free>; -using ScopedECDSA_SIG = ScopedType<ECDSA_SIG, ECDSA_SIG_free>; -using ScopedEC_GROUP = ScopedType<EC_GROUP, EC_GROUP_free>; -using ScopedEC_KEY = ScopedType<EC_KEY, EC_KEY_free>; -using ScopedEC_POINT = ScopedType<EC_POINT, EC_POINT_free>; -using ScopedEVP_PKEY = ScopedType<EVP_PKEY, EVP_PKEY_free>; -using ScopedEVP_PKEY_CTX = ScopedType<EVP_PKEY_CTX, EVP_PKEY_CTX_free>; -using ScopedNEWHOPE_POLY = ScopedType<NEWHOPE_POLY, NEWHOPE_POLY_free>; -using ScopedPKCS8_PRIV_KEY_INFO = - ScopedType<PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_free>; -using ScopedPKCS12 = ScopedType<PKCS12, PKCS12_free>; -using ScopedSPAKE2_CTX = ScopedType<SPAKE2_CTX, SPAKE2_CTX_free>; -using ScopedRSA = ScopedType<RSA, RSA_free>; -using ScopedX509 = ScopedType<X509, X509_free>; -using ScopedX509_ALGOR = ScopedType<X509_ALGOR, X509_ALGOR_free>; -using ScopedX509_SIG = ScopedType<X509_SIG, X509_SIG_free>; -using ScopedX509_STORE_CTX = ScopedType<X509_STORE_CTX, X509_STORE_CTX_free>; - -using ScopedX509Stack = ScopedStack<STACK_OF(X509), X509, X509_free>; - -using ScopedCBB = ScopedContext<CBB, void, CBB_zero, CBB_cleanup>; -using ScopedEVP_AEAD_CTX = - ScopedContext<EVP_AEAD_CTX, void, EVP_AEAD_CTX_zero, EVP_AEAD_CTX_cleanup>; -using ScopedEVP_CIPHER_CTX = - ScopedContext<EVP_CIPHER_CTX, int, EVP_CIPHER_CTX_init, - EVP_CIPHER_CTX_cleanup>; -using ScopedEVP_MD_CTX = - ScopedContext<EVP_MD_CTX, int, EVP_MD_CTX_init, EVP_MD_CTX_cleanup>; -using ScopedHMAC_CTX = - ScopedContext<HMAC_CTX, void, HMAC_CTX_init, HMAC_CTX_cleanup>; - -using ScopedBytes = std::unique_ptr<uint8_t, Free<uint8_t>>; -using ScopedString = std::unique_ptr<char, Free<char>>; +template<typename T, void (*func)(T*)> +using ScopedOpenSSLType = std::unique_ptr<T, OpenSSLDeleter<T, func>>; -using ScopedFILE = std::unique_ptr<FILE, FileCloser>; +template<typename StackType, typename T, void (*func)(T*)> +using ScopedOpenSSLStack = + std::unique_ptr<StackType, OpenSSLStackDeleter<StackType, T, func>>; + +template<typename T, typename CleanupRet, void (*init_func)(T*), + CleanupRet (*cleanup_func)(T*)> +class ScopedOpenSSLContext { + public: + ScopedOpenSSLContext() { + init_func(&ctx_); + } + ~ScopedOpenSSLContext() { + cleanup_func(&ctx_); + } + + T *get() { return &ctx_; } + const T *get() const { return &ctx_; } + + void Reset() { + cleanup_func(&ctx_); + init_func(&ctx_); + } + + private: + T ctx_; +}; + +using ScopedASN1_TYPE = ScopedOpenSSLType<ASN1_TYPE, ASN1_TYPE_free>; +using ScopedBIO = ScopedOpenSSLType<BIO, BIO_vfree>; +using ScopedBIGNUM = ScopedOpenSSLType<BIGNUM, BN_free>; +using ScopedBN_CTX = ScopedOpenSSLType<BN_CTX, BN_CTX_free>; +using ScopedBN_MONT_CTX = ScopedOpenSSLType<BN_MONT_CTX, BN_MONT_CTX_free>; +using ScopedCMAC_CTX = ScopedOpenSSLType<CMAC_CTX, CMAC_CTX_free>; +using ScopedDH = ScopedOpenSSLType<DH, DH_free>; +using ScopedECDSA_SIG = ScopedOpenSSLType<ECDSA_SIG, ECDSA_SIG_free>; +using ScopedEC_GROUP = ScopedOpenSSLType<EC_GROUP, EC_GROUP_free>; +using ScopedEC_KEY = ScopedOpenSSLType<EC_KEY, EC_KEY_free>; +using ScopedEC_POINT = ScopedOpenSSLType<EC_POINT, EC_POINT_free>; +using ScopedEVP_PKEY = ScopedOpenSSLType<EVP_PKEY, EVP_PKEY_free>; +using ScopedEVP_PKEY_CTX = ScopedOpenSSLType<EVP_PKEY_CTX, EVP_PKEY_CTX_free>; +using ScopedNEWHOPE_POLY = ScopedOpenSSLType<NEWHOPE_POLY, NEWHOPE_POLY_free>; +using ScopedPKCS8_PRIV_KEY_INFO = ScopedOpenSSLType<PKCS8_PRIV_KEY_INFO, + PKCS8_PRIV_KEY_INFO_free>; +using ScopedPKCS12 = ScopedOpenSSLType<PKCS12, PKCS12_free>; +using ScopedSPAKE2_CTX = ScopedOpenSSLType<SPAKE2_CTX, SPAKE2_CTX_free>; +using ScopedRSA = ScopedOpenSSLType<RSA, RSA_free>; +using ScopedX509 = ScopedOpenSSLType<X509, X509_free>; +using ScopedX509_ALGOR = ScopedOpenSSLType<X509_ALGOR, X509_ALGOR_free>; +using ScopedX509_SIG = ScopedOpenSSLType<X509_SIG, X509_SIG_free>; +using ScopedX509_STORE_CTX = ScopedOpenSSLType<X509_STORE_CTX, X509_STORE_CTX_free>; + +using ScopedX509Stack = ScopedOpenSSLStack<STACK_OF(X509), X509, X509_free>; -} // namespace bssl +using ScopedCBB = ScopedOpenSSLContext<CBB, void, CBB_zero, CBB_cleanup>; +using ScopedEVP_AEAD_CTX = ScopedOpenSSLContext<EVP_AEAD_CTX, void, + EVP_AEAD_CTX_zero, + EVP_AEAD_CTX_cleanup>; +using ScopedEVP_CIPHER_CTX = ScopedOpenSSLContext<EVP_CIPHER_CTX, int, + EVP_CIPHER_CTX_init, + EVP_CIPHER_CTX_cleanup>; +using ScopedEVP_MD_CTX = ScopedOpenSSLContext<EVP_MD_CTX, int, EVP_MD_CTX_init, + EVP_MD_CTX_cleanup>; +using ScopedHMAC_CTX = ScopedOpenSSLContext<HMAC_CTX, void, HMAC_CTX_init, + HMAC_CTX_cleanup>; + +using ScopedOpenSSLBytes = std::unique_ptr<uint8_t, OpenSSLFree<uint8_t>>; +using ScopedOpenSSLString = std::unique_ptr<char, OpenSSLFree<char>>; + +using ScopedFILE = std::unique_ptr<FILE, FileCloser>; #endif // OPENSSL_HEADER_CRYPTO_TEST_SCOPED_TYPES_H diff --git a/crypto/x509/x509_test.cc b/crypto/x509/x509_test.cc index cb28df70..650163a8 100644 --- a/crypto/x509/x509_test.cc +++ b/crypto/x509/x509_test.cc @@ -27,8 +27,6 @@ #include "../test/scoped_types.h" -namespace bssl { - static const char kCrossSigningRootPEM[] = "-----BEGIN CERTIFICATE-----\n" "MIICcTCCAdqgAwIBAgIIagJHiPvE0MowDQYJKoZIhvcNAQELBQAwPDEaMBgGA1UE\n" @@ -459,15 +457,13 @@ static bool TestSignCtx() { return true; } -} // namespace bssl - int main(int argc, char **argv) { CRYPTO_library_init(); - if (!bssl::TestVerify() || - !bssl::TestPSS() || - !bssl::TestBadPSSParameters() || - !bssl::TestSignCtx()) { + if (!TestVerify() || + !TestPSS() || + !TestBadPSSParameters() || + !TestSignCtx()) { return 1; } diff --git a/include/openssl/base.h b/include/openssl/base.h index 68df1078..7a3adfb1 100644 --- a/include/openssl/base.h +++ b/include/openssl/base.h @@ -67,8 +67,6 @@ #endif #if defined(__cplusplus) -#include <memory> - extern "C" { #endif @@ -292,44 +290,6 @@ typedef void *OPENSSL_BLOCK; #if defined(__cplusplus) } /* extern C */ - -namespace bssl { - -template<typename T, void (*func)(T*)> -struct Deleter { - void operator()(T *obj) { - func(obj); - } -}; - -template<typename T, void (*func)(T*)> -using ScopedType = std::unique_ptr<T, Deleter<T, func>>; - -template<typename T, typename CleanupRet, void (*init_func)(T*), - CleanupRet (*cleanup_func)(T*)> -class ScopedContext { - public: - ScopedContext() { - init_func(&ctx_); - } - ~ScopedContext() { - cleanup_func(&ctx_); - } - - T *get() { return &ctx_; } - const T *get() const { return &ctx_; } - - void Reset() { - cleanup_func(&ctx_); - init_func(&ctx_); - } - - private: - T ctx_; -}; - -} // namespace bssl - #endif #endif /* OPENSSL_HEADER_BASE_H */ diff --git a/include/openssl/mem.h b/include/openssl/mem.h index d7737526..31756f03 100644 --- a/include/openssl/mem.h +++ b/include/openssl/mem.h @@ -133,18 +133,6 @@ OPENSSL_EXPORT int BIO_vsnprintf(char *buf, size_t n, const char *format, #if defined(__cplusplus) } /* extern C */ - -namespace bssl { - -template<typename T> -struct Free { - void operator()(T *buf) { - OPENSSL_free(buf); - } -}; - -} // namespace bssl - #endif #endif /* OPENSSL_HEADER_MEM_H */ diff --git a/include/openssl/stack.h b/include/openssl/stack.h index 913db504..16b9f4f6 100644 --- a/include/openssl/stack.h +++ b/include/openssl/stack.h @@ -290,22 +290,6 @@ OPENSSL_EXPORT _STACK *sk_deep_copy(const _STACK *sk, #if defined(__cplusplus) } /* extern C */ - -namespace bssl { - -template<typename StackType, typename T, void (*func)(T*)> -struct StackDeleter { - void operator()(StackType *obj) { - sk_pop_free(reinterpret_cast<_STACK*>(obj), - reinterpret_cast<void (*)(void *)>(func)); - } -}; - -template <typename StackType, typename T, void (*func)(T *)> -using ScopedStack = - std::unique_ptr<StackType, StackDeleter<StackType, T, func>>; - -} // namespace bssl #endif #endif /* OPENSSL_HEADER_STACK_H */ diff --git a/ssl/ssl_test.cc b/ssl/ssl_test.cc index 92fad05d..be3b8b7c 100644 --- a/ssl/ssl_test.cc +++ b/ssl/ssl_test.cc @@ -33,190 +33,6 @@ #include "../crypto/test/test_util.h" -// kOpenSSLSession is a serialized SSL_SESSION generated from openssl -// s_client -sess_out. -static const char kOpenSSLSession[] = - "MIIFpQIBAQICAwMEAsAvBCAG5Q1ndq4Yfmbeo1zwLkNRKmCXGdNgWvGT3cskV0yQ" - "kAQwJlrlzkAWBOWiLj/jJ76D7l+UXoizP2KI2C7I2FccqMmIfFmmkUy32nIJ0mZH" - "IWoJoQYCBFRDO46iBAICASyjggR6MIIEdjCCA16gAwIBAgIIK9dUvsPWSlUwDQYJ" - "KoZIhvcNAQEFBQAwSTELMAkGA1UEBhMCVVMxEzARBgNVBAoTCkd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HR8EKTAnMCWgI6Ahhh9odHRw" - "Oi8vcGtpLmdvb2dsZS5jb20vR0lBRzIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCa" - "OXCBdoqUy5bxyq+Wrh1zsyyCFim1PH5VU2+yvDSWrgDY8ibRGJmfff3r4Lud5kal" - "dKs9k8YlKD3ITG7P0YT/Rk8hLgfEuLcq5cc0xqmE42xJ+Eo2uzq9rYorc5emMCxf" - "5L0TJOXZqHQpOEcuptZQ4OjdYMfSxk5UzueUhA3ogZKRcRkdB3WeWRp+nYRhx4St" - "o2rt2A0MKmY9165GHUqMK9YaaXHDXqBu7Sefr1uSoAP9gyIJKeihMivsGqJ1TD6Z" - "cc6LMe+dN2P8cZEQHtD1y296ul4Mivqk3jatUVL8/hCwgch9A8O4PGZq9WqBfEWm" - "IyHh1dPtbg1lOXdYCWtjpAIEAKUDAgEUqQUCAwGJwKqBpwSBpBwUQvoeOk0Kg36S" - "YTcLEkXqKwOBfF9vE4KX0NxeLwjcDTpsuh3qXEaZ992r1N38VDcyS6P7I6HBYN9B" - "sNHM362zZnY27GpTw+Kwd751CLoXFPoaMOe57dbBpXoro6Pd3BTbf/Tzr88K06yE" - "OTDKPNj3+inbMaVigtK4PLyPq+Topyzvx9USFgRvyuoxn0Hgb+R0A3j6SLRuyOdA" - "i4gv7Y5oliyn"; - -// kCustomSession is a custom serialized SSL_SESSION generated by -// filling in missing fields from |kOpenSSLSession|. This includes -// providing |peer_sha256|, so |peer| is not serialized. -static const char kCustomSession[] = - "MIIBdgIBAQICAwMEAsAvBCAG5Q1ndq4Yfmbeo1zwLkNRKmCXGdNgWvGT3cskV0yQ" - "kAQwJlrlzkAWBOWiLj/jJ76D7l+UXoizP2KI2C7I2FccqMmIfFmmkUy32nIJ0mZH" - "IWoJoQYCBFRDO46iBAICASykAwQBAqUDAgEUphAEDnd3dy5nb29nbGUuY29tqAcE" - "BXdvcmxkqQUCAwGJwKqBpwSBpBwUQvoeOk0Kg36SYTcLEkXqKwOBfF9vE4KX0Nxe" - "LwjcDTpsuh3qXEaZ992r1N38VDcyS6P7I6HBYN9BsNHM362zZnY27GpTw+Kwd751" - "CLoXFPoaMOe57dbBpXoro6Pd3BTbf/Tzr88K06yEOTDKPNj3+inbMaVigtK4PLyP" - "q+Topyzvx9USFgRvyuoxn0Hgb+R0A3j6SLRuyOdAi4gv7Y5oliynrSIEIAYGBgYG" - "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGrgMEAQevAwQBBLADBAEF"; - -// kBoringSSLSession is a serialized SSL_SESSION generated from bssl client. -static const char kBoringSSLSession[] = - "MIIRwQIBAQICAwMEAsAvBCDdoGxGK26mR+8lM0uq6+k9xYuxPnwAjpcF9n0Yli9R" - "kQQwbyshfWhdi5XQ1++7n2L1qqrcVlmHBPpr6yknT/u4pUrpQB5FZ7vqvNn8MdHf" - "9rWgoQYCBFXgs7uiBAICHCCjggR6MIIEdjCCA16gAwIBAgIIf+yfD7Y6UicwDQYJ" - "KoZIhvcNAQELBQAwSTELMAkGA1UEBhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMx" - "JTAjBgNVBAMTHEdvb2dsZSBJbnRlcm5ldCBBdXRob3JpdHkgRzIwHhcNMTUwODEy" - "MTQ1MzE1WhcNMTUxMTEwMDAwMDAwWjBoMQswCQYDVQQGEwJVUzETMBEGA1UECAwK" - "Q2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzETMBEGA1UECgwKR29v" - "Z2xlIEluYzEXMBUGA1UEAwwOd3d3Lmdvb2dsZS5jb20wggEiMA0GCSqGSIb3DQEB" - "AQUAA4IBDwAwggEKAoIBAQC0MeG5YGQ0t+IeJeoneP/PrhEaieibeKYkbKVLNZpo" - "PLuBinvhkXZo3DC133NpCBpy6ZktBwamqyixAyuk/NU6OjgXqwwxfQ7di1AInLIU" - "792c7hFyNXSUCG7At8Ifi3YwBX9Ba6u/1d6rWTGZJrdCq3QU11RkKYyTq2KT5mce" - "T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gEWLWh0dHBzOi8vd3d3" - "Lmdlb3RydXN0LmNvbS9yZXNvdXJjZXMvcmVwb3NpdG9yeTANBgkqhkiG9w0BAQUF" - "AAOBgQB24RJuTksWEoYwBrKBCM/wCMfHcX5m7sLt1Dsf//DwyE7WQziwuTB9GNBV" - "g6JqyzYRnOhIZqNtf7gT1Ef+i1pcc/yu2RsyGTirlzQUqpbS66McFAhJtrvlke+D" - "NusdVm/K2rxzY5Dkf3s+Iss9B+1fOHSc4wNQTqGvmO5h8oQ/Eg=="; - -// kBadSessionExtraField is a custom serialized SSL_SESSION generated by replacing -// the final (optional) element of |kCustomSession| with tag number 30. -static const char kBadSessionExtraField[] = - "MIIBdgIBAQICAwMEAsAvBCAG5Q1ndq4Yfmbeo1zwLkNRKmCXGdNgWvGT3cskV0yQ" - "kAQwJlrlzkAWBOWiLj/jJ76D7l+UXoizP2KI2C7I2FccqMmIfFmmkUy32nIJ0mZH" - "IWoJoQYCBFRDO46iBAICASykAwQBAqUDAgEUphAEDnd3dy5nb29nbGUuY29tqAcE" - "BXdvcmxkqQUCAwGJwKqBpwSBpBwUQvoeOk0Kg36SYTcLEkXqKwOBfF9vE4KX0Nxe" - "LwjcDTpsuh3qXEaZ992r1N38VDcyS6P7I6HBYN9BsNHM362zZnY27GpTw+Kwd751" - "CLoXFPoaMOe57dbBpXoro6Pd3BTbf/Tzr88K06yEOTDKPNj3+inbMaVigtK4PLyP" - "q+Topyzvx9USFgRvyuoxn0Hgb+R0A3j6SLRuyOdAi4gv7Y5oliynrSIEIAYGBgYG" - "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGrgMEAQevAwQBBL4DBAEF"; - -// kBadSessionVersion is a custom serialized SSL_SESSION generated by replacing -// the version of |kCustomSession| with 2. -static const char kBadSessionVersion[] = - "MIIBdgIBAgICAwMEAsAvBCAG5Q1ndq4Yfmbeo1zwLkNRKmCXGdNgWvGT3cskV0yQ" - "kAQwJlrlzkAWBOWiLj/jJ76D7l+UXoizP2KI2C7I2FccqMmIfFmmkUy32nIJ0mZH" - "IWoJoQYCBFRDO46iBAICASykAwQBAqUDAgEUphAEDnd3dy5nb29nbGUuY29tqAcE" - "BXdvcmxkqQUCAwGJwKqBpwSBpBwUQvoeOk0Kg36SYTcLEkXqKwOBfF9vE4KX0Nxe" - "LwjcDTpsuh3qXEaZ992r1N38VDcyS6P7I6HBYN9BsNHM362zZnY27GpTw+Kwd751" - "CLoXFPoaMOe57dbBpXoro6Pd3BTbf/Tzr88K06yEOTDKPNj3+inbMaVigtK4PLyP" - "q+Topyzvx9USFgRvyuoxn0Hgb+R0A3j6SLRuyOdAi4gv7Y5oliynrSIEIAYGBgYG" - "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGrgMEAQevAwQBBLADBAEF"; - -// kBadSessionTrailingData is a custom serialized SSL_SESSION with trailing data -// appended. -static const char kBadSessionTrailingData[] = - "MIIBdgIBAQICAwMEAsAvBCAG5Q1ndq4Yfmbeo1zwLkNRKmCXGdNgWvGT3cskV0yQ" - "kAQwJlrlzkAWBOWiLj/jJ76D7l+UXoizP2KI2C7I2FccqMmIfFmmkUy32nIJ0mZH" - "IWoJoQYCBFRDO46iBAICASykAwQBAqUDAgEUphAEDnd3dy5nb29nbGUuY29tqAcE" - "BXdvcmxkqQUCAwGJwKqBpwSBpBwUQvoeOk0Kg36SYTcLEkXqKwOBfF9vE4KX0Nxe" - "LwjcDTpsuh3qXEaZ992r1N38VDcyS6P7I6HBYN9BsNHM362zZnY27GpTw+Kwd751" - "CLoXFPoaMOe57dbBpXoro6Pd3BTbf/Tzr88K06yEOTDKPNj3+inbMaVigtK4PLyP" - "q+Topyzvx9USFgRvyuoxn0Hgb+R0A3j6SLRuyOdAi4gv7Y5oliynrSIEIAYGBgYG" - "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGrgMEAQevAwQBBLADBAEFAAAA"; - -namespace bssl { - struct ExpectedCipher { unsigned long id; int in_group_flag; @@ -585,6 +401,188 @@ static bool TestCipherRules() { return true; } +// kOpenSSLSession is a serialized SSL_SESSION generated from openssl +// s_client -sess_out. +static const char kOpenSSLSession[] = + "MIIFpQIBAQICAwMEAsAvBCAG5Q1ndq4Yfmbeo1zwLkNRKmCXGdNgWvGT3cskV0yQ" + "kAQwJlrlzkAWBOWiLj/jJ76D7l+UXoizP2KI2C7I2FccqMmIfFmmkUy32nIJ0mZH" + "IWoJoQYCBFRDO46iBAICASyjggR6MIIEdjCCA16gAwIBAgIIK9dUvsPWSlUwDQYJ" + "KoZIhvcNAQEFBQAwSTELMAkGA1UEBhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMx" + "JTAjBgNVBAMTHEdvb2dsZSBJbnRlcm5ldCBBdXRob3JpdHkgRzIwHhcNMTQxMDA4" + "MTIwNzU3WhcNMTUwMTA2MDAwMDAwWjBoMQswCQYDVQQGEwJVUzETMBEGA1UECAwK" + "Q2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzETMBEGA1UECgwKR29v" + "Z2xlIEluYzEXMBUGA1UEAwwOd3d3Lmdvb2dsZS5jb20wggEiMA0GCSqGSIb3DQEB" + "AQUAA4IBDwAwggEKAoIBAQCcKeLrplAC+Lofy8t/wDwtB6eu72CVp0cJ4V3lknN6" + "huH9ct6FFk70oRIh/VBNBBz900jYy+7111Jm1b8iqOTQ9aT5C7SEhNcQFJvqzH3e" + "MPkb6ZSWGm1yGF7MCQTGQXF20Sk/O16FSjAynU/b3oJmOctcycWYkY0ytS/k3LBu" + "Id45PJaoMqjB0WypqvNeJHC3q5JjCB4RP7Nfx5jjHSrCMhw8lUMW4EaDxjaR9KDh" + "PLgjsk+LDIySRSRDaCQGhEOWLJZVLzLo4N6/UlctCHEllpBUSvEOyFga52qroGjg" + "rf3WOQ925MFwzd6AK+Ich0gDRg8sQfdLH5OuP1cfLfU1AgMBAAGjggFBMIIBPTAd" + "BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwGQYD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custom serialized SSL_SESSION generated by +// filling in missing fields from |kOpenSSLSession|. This includes +// providing |peer_sha256|, so |peer| is not serialized. +static const char kCustomSession[] = + "MIIBdgIBAQICAwMEAsAvBCAG5Q1ndq4Yfmbeo1zwLkNRKmCXGdNgWvGT3cskV0yQ" + "kAQwJlrlzkAWBOWiLj/jJ76D7l+UXoizP2KI2C7I2FccqMmIfFmmkUy32nIJ0mZH" + "IWoJoQYCBFRDO46iBAICASykAwQBAqUDAgEUphAEDnd3dy5nb29nbGUuY29tqAcE" + "BXdvcmxkqQUCAwGJwKqBpwSBpBwUQvoeOk0Kg36SYTcLEkXqKwOBfF9vE4KX0Nxe" + "LwjcDTpsuh3qXEaZ992r1N38VDcyS6P7I6HBYN9BsNHM362zZnY27GpTw+Kwd751" + "CLoXFPoaMOe57dbBpXoro6Pd3BTbf/Tzr88K06yEOTDKPNj3+inbMaVigtK4PLyP" + "q+Topyzvx9USFgRvyuoxn0Hgb+R0A3j6SLRuyOdAi4gv7Y5oliynrSIEIAYGBgYG" + "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGrgMEAQevAwQBBLADBAEF"; + +// kBoringSSLSession is a serialized SSL_SESSION generated from bssl client. +static const char kBoringSSLSession[] = + "MIIRwQIBAQICAwMEAsAvBCDdoGxGK26mR+8lM0uq6+k9xYuxPnwAjpcF9n0Yli9R" + "kQQwbyshfWhdi5XQ1++7n2L1qqrcVlmHBPpr6yknT/u4pUrpQB5FZ7vqvNn8MdHf" + "9rWgoQYCBFXgs7uiBAICHCCjggR6MIIEdjCCA16gAwIBAgIIf+yfD7Y6UicwDQYJ" + "KoZIhvcNAQELBQAwSTELMAkGA1UEBhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMx" + "JTAjBgNVBAMTHEdvb2dsZSBJbnRlcm5ldCBBdXRob3JpdHkgRzIwHhcNMTUwODEy" + "MTQ1MzE1WhcNMTUxMTEwMDAwMDAwWjBoMQswCQYDVQQGEwJVUzETMBEGA1UECAwK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FL0y6xgDKFIE" + "ceWrMz3hOLsHNoRinHnqFjD0X8Ar6HFr5PkCAwEAAaOB8DCB7TAfBgNVHSMEGDAW" + "gBRI5mj5K9KylddH2CMgEE8zmJCf1DAdBgNVHQ4EFgQUwHqYaI2J+6sFZAwRfap9" + "ZbjKzE4wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwOgYDVR0fBDMw" + "MTAvoC2gK4YpaHR0cDovL2NybC5nZW90cnVzdC5jb20vY3Jscy9zZWN1cmVjYS5j" + "cmwwTgYDVR0gBEcwRTBDBgRVHSAAMDswOQYIKwYBBQUHAgEWLWh0dHBzOi8vd3d3" + "Lmdlb3RydXN0LmNvbS9yZXNvdXJjZXMvcmVwb3NpdG9yeTANBgkqhkiG9w0BAQUF" + "AAOBgQB24RJuTksWEoYwBrKBCM/wCMfHcX5m7sLt1Dsf//DwyE7WQziwuTB9GNBV" + "g6JqyzYRnOhIZqNtf7gT1Ef+i1pcc/yu2RsyGTirlzQUqpbS66McFAhJtrvlke+D" + "NusdVm/K2rxzY5Dkf3s+Iss9B+1fOHSc4wNQTqGvmO5h8oQ/Eg=="; + +// kBadSessionExtraField is a custom serialized SSL_SESSION generated by replacing +// the final (optional) element of |kCustomSession| with tag number 30. +static const char kBadSessionExtraField[] = + "MIIBdgIBAQICAwMEAsAvBCAG5Q1ndq4Yfmbeo1zwLkNRKmCXGdNgWvGT3cskV0yQ" + "kAQwJlrlzkAWBOWiLj/jJ76D7l+UXoizP2KI2C7I2FccqMmIfFmmkUy32nIJ0mZH" + "IWoJoQYCBFRDO46iBAICASykAwQBAqUDAgEUphAEDnd3dy5nb29nbGUuY29tqAcE" + "BXdvcmxkqQUCAwGJwKqBpwSBpBwUQvoeOk0Kg36SYTcLEkXqKwOBfF9vE4KX0Nxe" + "LwjcDTpsuh3qXEaZ992r1N38VDcyS6P7I6HBYN9BsNHM362zZnY27GpTw+Kwd751" + "CLoXFPoaMOe57dbBpXoro6Pd3BTbf/Tzr88K06yEOTDKPNj3+inbMaVigtK4PLyP" + "q+Topyzvx9USFgRvyuoxn0Hgb+R0A3j6SLRuyOdAi4gv7Y5oliynrSIEIAYGBgYG" + "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGrgMEAQevAwQBBL4DBAEF"; + +// kBadSessionVersion is a custom serialized SSL_SESSION generated by replacing +// the version of |kCustomSession| with 2. +static const char kBadSessionVersion[] = + "MIIBdgIBAgICAwMEAsAvBCAG5Q1ndq4Yfmbeo1zwLkNRKmCXGdNgWvGT3cskV0yQ" + "kAQwJlrlzkAWBOWiLj/jJ76D7l+UXoizP2KI2C7I2FccqMmIfFmmkUy32nIJ0mZH" + "IWoJoQYCBFRDO46iBAICASykAwQBAqUDAgEUphAEDnd3dy5nb29nbGUuY29tqAcE" + "BXdvcmxkqQUCAwGJwKqBpwSBpBwUQvoeOk0Kg36SYTcLEkXqKwOBfF9vE4KX0Nxe" + "LwjcDTpsuh3qXEaZ992r1N38VDcyS6P7I6HBYN9BsNHM362zZnY27GpTw+Kwd751" + "CLoXFPoaMOe57dbBpXoro6Pd3BTbf/Tzr88K06yEOTDKPNj3+inbMaVigtK4PLyP" + "q+Topyzvx9USFgRvyuoxn0Hgb+R0A3j6SLRuyOdAi4gv7Y5oliynrSIEIAYGBgYG" + "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGrgMEAQevAwQBBLADBAEF"; + +// kBadSessionTrailingData is a custom serialized SSL_SESSION with trailing data +// appended. +static const char kBadSessionTrailingData[] = + "MIIBdgIBAQICAwMEAsAvBCAG5Q1ndq4Yfmbeo1zwLkNRKmCXGdNgWvGT3cskV0yQ" + "kAQwJlrlzkAWBOWiLj/jJ76D7l+UXoizP2KI2C7I2FccqMmIfFmmkUy32nIJ0mZH" + "IWoJoQYCBFRDO46iBAICASykAwQBAqUDAgEUphAEDnd3dy5nb29nbGUuY29tqAcE" + "BXdvcmxkqQUCAwGJwKqBpwSBpBwUQvoeOk0Kg36SYTcLEkXqKwOBfF9vE4KX0Nxe" + "LwjcDTpsuh3qXEaZ992r1N38VDcyS6P7I6HBYN9BsNHM362zZnY27GpTw+Kwd751" + "CLoXFPoaMOe57dbBpXoro6Pd3BTbf/Tzr88K06yEOTDKPNj3+inbMaVigtK4PLyP" + "q+Topyzvx9USFgRvyuoxn0Hgb+R0A3j6SLRuyOdAi4gv7Y5oliynrSIEIAYGBgYG" + "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGrgMEAQevAwQBBLADBAEFAAAA"; + static bool DecodeBase64(std::vector<uint8_t> *out, const char *in) { size_t len; if (!EVP_DecodedLength(&len, strlen(in))) { @@ -621,7 +619,7 @@ static bool TestSSL_SESSIONEncoding(const char *input_b64) { // Verify the SSL_SESSION encoding round-trips. size_t encoded_len; - ScopedBytes encoded; + ScopedOpenSSLBytes encoded; uint8_t *encoded_raw; if (!SSL_SESSION_to_bytes(session.get(), &encoded_raw, &encoded_len)) { fprintf(stderr, "SSL_SESSION_to_bytes failed\n"); @@ -710,7 +708,7 @@ static bool CipherGetRFCName(std::string *out, uint16_t value) { if (cipher == NULL) { return false; } - ScopedString rfc_name(SSL_CIPHER_get_rfc_name(cipher)); + ScopedOpenSSLString rfc_name(SSL_CIPHER_get_rfc_name(cipher)); if (!rfc_name) { return false; } @@ -1355,39 +1353,33 @@ static bool TestSetFD() { return true; } -} // namespace bssl - int main() { CRYPTO_library_init(); - if (!bssl::TestCipherRules() || - !bssl::TestSSL_SESSIONEncoding(kOpenSSLSession) || - !bssl::TestSSL_SESSIONEncoding(kCustomSession) || - !bssl::TestSSL_SESSIONEncoding(kBoringSSLSession) || - !bssl::TestBadSSL_SESSIONEncoding(kBadSessionExtraField) || - !bssl::TestBadSSL_SESSIONEncoding(kBadSessionVersion) || - !bssl::TestBadSSL_SESSIONEncoding(kBadSessionTrailingData) || + if (!TestCipherRules() || + !TestSSL_SESSIONEncoding(kOpenSSLSession) || + !TestSSL_SESSIONEncoding(kCustomSession) || + !TestSSL_SESSIONEncoding(kBoringSSLSession) || + !TestBadSSL_SESSIONEncoding(kBadSessionExtraField) || + !TestBadSSL_SESSIONEncoding(kBadSessionVersion) || + !TestBadSSL_SESSIONEncoding(kBadSessionTrailingData) || // TODO(svaldez): Update this when TLS 1.3 is enabled by default. - !bssl::TestDefaultVersion(SSL3_VERSION, TLS1_2_VERSION, &TLS_method) || - !bssl::TestDefaultVersion(SSL3_VERSION, SSL3_VERSION, &SSLv3_method) || - !bssl::TestDefaultVersion(TLS1_VERSION, TLS1_VERSION, &TLSv1_method) || - !bssl::TestDefaultVersion(TLS1_1_VERSION, TLS1_1_VERSION, - &TLSv1_1_method) || - !bssl::TestDefaultVersion(TLS1_2_VERSION, TLS1_2_VERSION, - &TLSv1_2_method) || - !bssl::TestDefaultVersion(TLS1_1_VERSION, TLS1_2_VERSION, &DTLS_method) || - !bssl::TestDefaultVersion(TLS1_1_VERSION, TLS1_1_VERSION, - &DTLSv1_method) || - !bssl::TestDefaultVersion(TLS1_2_VERSION, TLS1_2_VERSION, - &DTLSv1_2_method) || - !bssl::TestCipherGetRFCName() || - !bssl::TestPaddingExtension() || - !bssl::TestClientCAList() || - !bssl::TestInternalSessionCache() || - !bssl::TestSequenceNumber(false /* TLS */) || - !bssl::TestSequenceNumber(true /* DTLS */) || - !bssl::TestOneSidedShutdown() || - !bssl::TestSetFD()) { + !TestDefaultVersion(SSL3_VERSION, TLS1_2_VERSION, &TLS_method) || + !TestDefaultVersion(SSL3_VERSION, SSL3_VERSION, &SSLv3_method) || + !TestDefaultVersion(TLS1_VERSION, TLS1_VERSION, &TLSv1_method) || + !TestDefaultVersion(TLS1_1_VERSION, TLS1_1_VERSION, &TLSv1_1_method) || + !TestDefaultVersion(TLS1_2_VERSION, TLS1_2_VERSION, &TLSv1_2_method) || + !TestDefaultVersion(TLS1_1_VERSION, TLS1_2_VERSION, &DTLS_method) || + !TestDefaultVersion(TLS1_1_VERSION, TLS1_1_VERSION, &DTLSv1_method) || + !TestDefaultVersion(TLS1_2_VERSION, TLS1_2_VERSION, &DTLSv1_2_method) || + !TestCipherGetRFCName() || + !TestPaddingExtension() || + !TestClientCAList() || + !TestInternalSessionCache() || + !TestSequenceNumber(false /* TLS */) || + !TestSequenceNumber(true /* DTLS */) || + !TestOneSidedShutdown() || + !TestSetFD()) { ERR_print_errors_fp(stderr); return 1; } diff --git a/ssl/test/async_bio.cc b/ssl/test/async_bio.cc index b7582190..7a5737bb 100644 --- a/ssl/test/async_bio.cc +++ b/ssl/test/async_bio.cc @@ -20,8 +20,6 @@ #include <openssl/mem.h> -namespace bssl { - namespace { extern const BIO_METHOD g_async_bio_method; @@ -188,5 +186,3 @@ void AsyncBioEnforceWriteQuota(BIO *bio, bool enforce) { } a->enforce_write_quota = enforce; } - -} // namespace bssl diff --git a/ssl/test/async_bio.h b/ssl/test/async_bio.h index 1799347b..fbc40163 100644 --- a/ssl/test/async_bio.h +++ b/ssl/test/async_bio.h @@ -20,8 +20,6 @@ #include "../../crypto/test/scoped_types.h" -namespace bssl { - // AsyncBioCreate creates a filter BIO for testing asynchronous state // machines which consume a stream socket. Reads and writes will fail // and return EAGAIN unless explicitly allowed. Each async BIO has a @@ -43,7 +41,5 @@ void AsyncBioAllowWrite(BIO *bio, size_t count); // AsyncBioEnforceWriteQuota configures where |bio| enforces its write quota. void AsyncBioEnforceWriteQuota(BIO *bio, bool enforce); -} // namespace bssl - #endif // HEADER_ASYNC_BIO diff --git a/ssl/test/bssl_shim.cc b/ssl/test/bssl_shim.cc index 9ce8b5f2..54157ee1 100644 --- a/ssl/test/bssl_shim.cc +++ b/ssl/test/bssl_shim.cc @@ -62,8 +62,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #include "test_config.h" -namespace bssl { - #if !defined(OPENSSL_WINDOWS) static int closesocket(int sock) { return close(sock); @@ -286,7 +284,7 @@ static const SSL_PRIVATE_KEY_METHOD g_async_private_key_method = { }; template<typename T> -struct SystemFree { +struct Free { void operator()(T *buf) { free(buf); } @@ -297,7 +295,7 @@ static bool GetCertificate(SSL *ssl, ScopedX509 *out_x509, const TestConfig *config = GetTestConfig(ssl); if (!config->digest_prefs.empty()) { - std::unique_ptr<char, SystemFree<char>> digest_prefs( + std::unique_ptr<char, Free<char>> digest_prefs( strdup(config->digest_prefs.c_str())); std::vector<int> digest_list; @@ -1557,7 +1555,7 @@ class StderrDelimiter { ~StderrDelimiter() { fprintf(stderr, "--- DONE ---\n"); } }; -static int Main(int argc, char **argv) { +int main(int argc, char **argv) { // To distinguish ASan's output from ours, add a trailing message to stderr. // Anything following this line will be considered an error. StderrDelimiter delimiter; @@ -1613,9 +1611,3 @@ static int Main(int argc, char **argv) { return 0; } - -} // namespace bssl - -int main(int argc, char **argv) { - return bssl::Main(argc, argv); -} diff --git a/ssl/test/packeted_bio.cc b/ssl/test/packeted_bio.cc index 131cd924..b0982b07 100644 --- a/ssl/test/packeted_bio.cc +++ b/ssl/test/packeted_bio.cc @@ -22,8 +22,6 @@ #include <openssl/mem.h> -namespace bssl { - namespace { extern const BIO_METHOD g_packeted_bio_method; @@ -304,5 +302,3 @@ bool PacketedBioAdvanceClock(BIO *bio) { memset(&data->timeout, 0, sizeof(data->timeout)); return true; } - -} // namespace bssl diff --git a/ssl/test/packeted_bio.h b/ssl/test/packeted_bio.h index e6dcfe4c..9bab635a 100644 --- a/ssl/test/packeted_bio.h +++ b/ssl/test/packeted_bio.h @@ -29,8 +29,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #endif -namespace bssl { - // PacketedBioCreate creates a filter BIO which implements a reliable in-order // blocking datagram socket. It internally maintains a clock and honors // |BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT| based on it. @@ -49,7 +47,5 @@ timeval PacketedBioGetClock(const BIO *bio); // there is a pending timeout. Otherwise, it returns false. bool PacketedBioAdvanceClock(BIO *bio); -} // namespace bssl - #endif // HEADER_PACKETED_BIO diff --git a/ssl/test/scoped_types.h b/ssl/test/scoped_types.h index 0b3b5629..7e92ceed 100644 --- a/ssl/test/scoped_types.h +++ b/ssl/test/scoped_types.h @@ -20,13 +20,9 @@ #include "../../crypto/test/scoped_types.h" -namespace bssl { - -using ScopedSSL = ScopedType<SSL, SSL_free>; -using ScopedSSL_CTX = ScopedType<SSL_CTX, SSL_CTX_free>; -using ScopedSSL_SESSION = ScopedType<SSL_SESSION, SSL_SESSION_free>; - -} // namespace bssl +using ScopedSSL = ScopedOpenSSLType<SSL, SSL_free>; +using ScopedSSL_CTX = ScopedOpenSSLType<SSL_CTX, SSL_CTX_free>; +using ScopedSSL_SESSION = ScopedOpenSSLType<SSL_SESSION, SSL_SESSION_free>; #endif // OPENSSL_HEADER_SSL_TEST_SCOPED_TYPES_H diff --git a/ssl/test/test_config.cc b/ssl/test/test_config.cc index 3fe25be2..32b91e9e 100644 --- a/ssl/test/test_config.cc +++ b/ssl/test/test_config.cc @@ -22,8 +22,6 @@ #include <openssl/base64.h> -namespace bssl { - namespace { template <typename T> @@ -215,5 +213,3 @@ bool ParseConfig(int argc, char **argv, TestConfig *out_config) { return true; } - -} // namespace bssl diff --git a/ssl/test/test_config.h b/ssl/test/test_config.h index bf2e8157..a3e9ad15 100644 --- a/ssl/test/test_config.h +++ b/ssl/test/test_config.h @@ -18,8 +18,6 @@ #include <string> -namespace bssl { - struct TestConfig { int port = 0; bool is_server = false; @@ -113,7 +111,5 @@ struct TestConfig { bool ParseConfig(int argc, char **argv, TestConfig *out_config); -} // namespace bssl - #endif // HEADER_TEST_CONFIG diff --git a/tool/args.cc b/tool/args.cc index 952584d6..9ec18a3f 100644 --- a/tool/args.cc +++ b/tool/args.cc @@ -23,8 +23,6 @@ #include "internal.h" -namespace bssl { - bool ParseKeyValueArguments(std::map<std::string, std::string> *out_args, const std::vector<std::string> &args, const struct argument *templates) { @@ -104,5 +102,3 @@ bool GetUnsigned(unsigned *out, const std::string &arg_name, *out = num; return true; } - -} // namespace bssl diff --git a/tool/ciphers.cc b/tool/ciphers.cc index fa060aba..d7cc36b8 100644 --- a/tool/ciphers.cc +++ b/tool/ciphers.cc @@ -25,8 +25,6 @@ #include "internal.h" -namespace bssl { - bool Ciphers(const std::vector<std::string> &args) { if (args.size() != 1) { fprintf(stderr, "Usage: bssl ciphers <cipher suite string>\n"); @@ -66,5 +64,3 @@ bool Ciphers(const std::vector<std::string> &args) { return true; } - -} // namespace bssl diff --git a/tool/client.cc b/tool/client.cc index 593e3c61..7310ebf3 100644 --- a/tool/client.cc +++ b/tool/client.cc @@ -26,8 +26,6 @@ #include "transport_common.h" -namespace bssl { - static const struct argument kArguments[] = { { "-connect", kRequiredArgument, @@ -328,5 +326,3 @@ bool Client(const std::vector<std::string> &args) { return ok; } - -} // namespace bssl diff --git a/tool/const.cc b/tool/const.cc index 553e2d9f..7b7001e5 100644 --- a/tool/const.cc +++ b/tool/const.cc @@ -18,8 +18,6 @@ #include "internal.h" -namespace bssl { - const uint8_t kDERRSAPrivate2048[] = { 0x30, 0x82, 0x04, 0xa3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd0, 0x02, 0xde, 0x5d, 0x19, 0x33, 0x48, 0x15, 0xc7, 0x86, 0xde, 0xa3, @@ -434,5 +432,3 @@ const uint8_t kDERRSAPrivate3Prime2048[] = { }; const size_t kDERRSAPrivate3Prime2048Len = sizeof(kDERRSAPrivate3Prime2048); - -} // namespace bssl diff --git a/tool/digest.cc b/tool/digest.cc index e6a97bba..2e3e6085 100644 --- a/tool/digest.cc +++ b/tool/digest.cc @@ -44,8 +44,6 @@ typedef int ssize_t; #include "internal.h" -namespace bssl { - struct close_delete { void operator()(int *fd) { BORINGSSL_CLOSE(*fd); @@ -478,5 +476,3 @@ bool SHA384Sum(const std::vector<std::string> &args) { bool SHA512Sum(const std::vector<std::string> &args) { return DigestSum(EVP_sha512(), args); } - -} // namespace bssl diff --git a/tool/generate_ed25519.cc b/tool/generate_ed25519.cc index 9672b78c..15d36924 100644 --- a/tool/generate_ed25519.cc +++ b/tool/generate_ed25519.cc @@ -22,8 +22,6 @@ #include "internal.h" -namespace bssl { - static const struct argument kArguments[] = { { "-out-public", kRequiredArgument, "The file to write the public key to", @@ -67,5 +65,3 @@ bool GenerateEd25519Key(const std::vector<std::string> &args) { WriteToFile(args_map["-out-private"], private_key, sizeof(private_key)); } - -} // namespace bssl diff --git a/tool/genrsa.cc b/tool/genrsa.cc index 576bd7c9..4b394015 100644 --- a/tool/genrsa.cc +++ b/tool/genrsa.cc @@ -22,8 +22,6 @@ #include "internal.h" -namespace bssl { - static const struct argument kArguments[] = { { "-nprimes", kOptionalArgument, @@ -69,5 +67,3 @@ bool GenerateRSAKey(const std::vector<std::string> &args) { return true; } - -} // namespace bssl diff --git a/tool/internal.h b/tool/internal.h index 769bcab7..fd66e00f 100644 --- a/tool/internal.h +++ b/tool/internal.h @@ -44,8 +44,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #define BORINGSSL_WRITE write #endif -namespace bssl { - enum ArgumentType { kRequiredArgument, kOptionalArgument, @@ -90,7 +88,5 @@ extern const size_t kDERRSAPrivate4096Len; extern const uint8_t kDERRSAPrivate3Prime2048[]; extern const size_t kDERRSAPrivate3Prime2048Len; -} // namespace bssl - #endif /* !OPENSSL_HEADER_TOOL_INTERNAL_H */ diff --git a/tool/pkcs12.cc b/tool/pkcs12.cc index 2423f19f..15e32d3d 100644 --- a/tool/pkcs12.cc +++ b/tool/pkcs12.cc @@ -39,8 +39,6 @@ #include "internal.h" -namespace bssl { - #if defined(OPENSSL_WINDOWS) typedef int read_result_t; #else @@ -142,5 +140,3 @@ bool DoPKCS12(const std::vector<std::string> &args) { return true; } - -} // namespace bssl diff --git a/tool/rand.cc b/tool/rand.cc index a76dc849..3701748c 100644 --- a/tool/rand.cc +++ b/tool/rand.cc @@ -23,8 +23,6 @@ #include "internal.h" -namespace bssl { - static const struct argument kArguments[] = { { "-hex", kBooleanArgument, @@ -95,5 +93,3 @@ bool Rand(const std::vector<std::string> &args) { return true; } - -} // namespace bssl diff --git a/tool/server.cc b/tool/server.cc index 04bb7efb..14f37a44 100644 --- a/tool/server.cc +++ b/tool/server.cc @@ -21,8 +21,6 @@ #include "transport_common.h" -namespace bssl { - static const struct argument kArguments[] = { { "-accept", kRequiredArgument, @@ -152,5 +150,3 @@ bool Server(const std::vector<std::string> &args) { SSL_CTX_free(ctx); return ok; } - -} // namespace bssl diff --git a/tool/speed.cc b/tool/speed.cc index 8efd1f40..a8eb8bfa 100644 --- a/tool/speed.cc +++ b/tool/speed.cc @@ -41,8 +41,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #include "internal.h" -namespace bssl { - // TimeResults represents the results of benchmarking a function. struct TimeResults { // num_calls is the number of function calls done in the time period. @@ -632,5 +630,3 @@ bool Speed(const std::vector<std::string> &args) { return true; } - -} // namespace bssl diff --git a/tool/tool.cc b/tool/tool.cc index 8519108e..34851b47 100644 --- a/tool/tool.cc +++ b/tool/tool.cc @@ -29,8 +29,6 @@ #include "internal.h" -namespace bssl { - typedef bool (*tool_func_t)(const std::vector<std::string> &args); struct Tool { @@ -81,8 +79,7 @@ static tool_func_t FindTool(const std::string &name) { } } - -static int Main(int argc, char **argv) { +int main(int argc, char **argv) { #if defined(OPENSSL_WINDOWS) // Read and write in binary mode. This makes bssl on Windows consistent with // bssl on other platforms, and also makes it consistent with MSYS's commands @@ -127,9 +124,3 @@ static int Main(int argc, char **argv) { return !tool(args); } - -} // namespace bssl - -int main(int argc, char **argv) { - return bssl::Main(argc, argv); -} diff --git a/tool/transport_common.cc b/tool/transport_common.cc index 7ccda213..01bba009 100644 --- a/tool/transport_common.cc +++ b/tool/transport_common.cc @@ -51,8 +51,6 @@ typedef int ssize_t; #include "transport_common.h" -namespace bssl { - #if !defined(OPENSSL_WINDOWS) static int closesocket(int sock) { return close(sock); @@ -539,5 +537,3 @@ bool DoSMTPStartTLS(int sock) { return true; } - -} // namespace bssl diff --git a/tool/transport_common.h b/tool/transport_common.h index 86181298..a57a9169 100644 --- a/tool/transport_common.h +++ b/tool/transport_common.h @@ -18,9 +18,6 @@ #include <openssl/ssl.h> #include <string.h> - -namespace bssl { - // InitSocketLibrary calls the Windows socket init functions, if needed. bool InitSocketLibrary(); @@ -46,7 +43,4 @@ bool TransferData(SSL *ssl, int sock); // returns true on success and false otherwise. bool DoSMTPStartTLS(int sock); -} // namespace bssl - - #endif /* !OPENSSL_HEADER_TOOL_TRANSPORT_COMMON_H */ diff --git a/util/doc.go b/util/doc.go index c03f7428..681b8349 100644 --- a/util/doc.go +++ b/util/doc.go @@ -72,7 +72,6 @@ type HeaderDecl struct { const ( cppGuard = "#if defined(__cplusplus)" - endif = "#endif" commentStart = "/* " commentEnd = " */" ) @@ -293,14 +292,8 @@ func (config *Config) parseHeader(path string) (*HeaderFile, error) { if len(lines) == 0 || lines[0] != "extern \"C\" {" { return nil, errors.New("no extern \"C\" found after C++ guard") } - - for i, line := range lines { - if line == endif { - lines = lines[i+1:] - lineNo += i + 1 - break - } - } + lineNo += 2 + lines = lines[2:] header := &HeaderFile{ Name: filepath.Base(path), |