diff --git a/crypto/bytestring/bytestring_test.cc b/crypto/bytestring/bytestring_test.cc index 9ab2c0c2..0ec7d541 100644 --- a/crypto/bytestring/bytestring_test.cc +++ b/crypto/bytestring/bytestring_test.cc @@ -22,12 +22,13 @@ #include +#include #include -#include #include "internal.h" #include "../test/scoped_types.h" +namespace bssl { static bool TestSkip() { static const uint8_t kData[] = {1, 2, 3}; @@ -873,7 +874,7 @@ static bool TestStickyError() { return true; } -int main(void) { +static int Main() { CRYPTO_library_init(); if (!TestSkip() || @@ -901,3 +902,9 @@ int main(void) { printf("PASS\n"); return 0; } + +} // namespace bssl + +int main() { + return bssl::Main(); +} diff --git a/crypto/cipher/cipher_test.cc b/crypto/cipher/cipher_test.cc index fa384c69..08c8bd59 100644 --- a/crypto/cipher/cipher_test.cc +++ b/crypto/cipher/cipher_test.cc @@ -57,13 +57,13 @@ #include #include -#include +#include #include #include #include "../test/file_test.h" -#include "../test/scoped_types.h" +namespace bssl { static const EVP_CIPHER *GetCipher(const std::string &name) { if (name == "DES-CBC") { @@ -284,7 +284,7 @@ static bool TestCipher(FileTest *t, void *arg) { return true; } -int main(int argc, char **argv) { +static int Main(int argc, char **argv) { CRYPTO_library_init(); if (argc != 2) { @@ -294,3 +294,9 @@ int main(int argc, char **argv) { return FileTestMain(TestCipher, nullptr, argv[1]); } + +} // namespace bssl + +int main(int argc, char **argv) { + return bssl::Main(argc, argv); +} diff --git a/crypto/dh/dh_test.cc b/crypto/dh/dh_test.cc index 60e433bf..16df9a2a 100644 --- a/crypto/dh/dh_test.cc +++ b/crypto/dh/dh_test.cc @@ -62,7 +62,7 @@ #include #include -#include +#include #include #include #include @@ -70,6 +70,7 @@ #include "internal.h" #include "../test/scoped_types.h" +namespace bssl { static bool RunBasicTests(); static bool RunRFC5114Tests(); @@ -77,7 +78,7 @@ static bool TestBadY(); static bool TestASN1(); static bool TestRFC3526(); -int main(int argc, char *argv[]) { +static int Main() { CRYPTO_library_init(); if (!RunBasicTests() || @@ -662,3 +663,9 @@ static bool TestRFC3526() { return true; } + +} // namespace bssl + +int main() { + return bssl::Main(); +} diff --git a/crypto/digest/digest_test.cc b/crypto/digest/digest_test.cc index fbe22975..c94096b8 100644 --- a/crypto/digest/digest_test.cc +++ b/crypto/digest/digest_test.cc @@ -16,15 +16,16 @@ #include #include +#include + +#include #include -#include #include #include #include #include -#include "../test/scoped_types.h" - +namespace bssl { struct MD { // name is the name of the digest. @@ -243,7 +244,7 @@ static int TestGetters() { return true; } -int main(void) { +static int Main() { CRYPTO_library_init(); for (size_t i = 0; i < sizeof(kTestVectors) / sizeof(kTestVectors[0]); i++) { @@ -260,3 +261,9 @@ int main(void) { 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 23befeb2..ca0e1401 100644 --- a/crypto/ec/ec_test.cc +++ b/crypto/ec/ec_test.cc @@ -17,7 +17,7 @@ #include -#include +#include #include #include #include @@ -25,6 +25,7 @@ #include "../test/scoped_types.h" +namespace bssl { // kECKeyWithoutPublic is an ECPrivateKey with the optional publicKey field // omitted. @@ -471,7 +472,7 @@ static bool ForEachCurve(bool (*test_func)(int nid)) { return true; } -int main(void) { +static int Main() { CRYPTO_library_init(); if (!Testd2i_ECPrivateKey() || @@ -487,3 +488,9 @@ int main(void) { printf("PASS\n"); return 0; } + +} // namespace bssl + +int main() { + return bssl::Main(); +} diff --git a/crypto/evp/evp_extra_test.cc b/crypto/evp/evp_extra_test.cc index 9bc36ad8..b2c519eb 100644 --- a/crypto/evp/evp_extra_test.cc +++ b/crypto/evp/evp_extra_test.cc @@ -20,15 +20,15 @@ #include #include -#include +#include +#include #include -#include #include -#include #include #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. @@ -671,7 +671,7 @@ static bool Testd2i_PrivateKey(void) { return true; } -int main(void) { +static int Main(void) { CRYPTO_library_init(); if (!TestEVP_DigestSignInit()) { @@ -719,3 +719,9 @@ int main(void) { 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 b01d1e47..9c8735b4 100644 --- a/crypto/evp/evp_test.cc +++ b/crypto/evp/evp_test.cc @@ -68,7 +68,7 @@ OPENSSL_MSVC_PRAGMA(warning(disable: 4702)) OPENSSL_MSVC_PRAGMA(warning(pop)) -#include +#include #include #include #include @@ -76,6 +76,7 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #include "../test/file_test.h" #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 @@ -253,7 +254,7 @@ static bool TestEVP(FileTest *t, void *arg) { return true; } -int main(int argc, char **argv) { +static int Main(int argc, char *argv[]) { CRYPTO_library_init(); if (argc != 2) { fprintf(stderr, "%s \n", argv[0]); @@ -263,3 +264,9 @@ int main(int argc, char **argv) { KeyMap map; return FileTestMain(TestEVP, &map, argv[1]); } + +} // namespace bssl + +int main(int argc, char *argv[]) { + return bssl::Main(argc, argv); +} diff --git a/crypto/hmac/hmac_test.cc b/crypto/hmac/hmac_test.cc index 2bcb1623..3d49d9e9 100644 --- a/crypto/hmac/hmac_test.cc +++ b/crypto/hmac/hmac_test.cc @@ -57,16 +57,17 @@ #include #include +#include #include #include +#include #include #include -#include #include "../test/file_test.h" -#include "../test/scoped_types.h" +namespace bssl { static const EVP_MD *GetDigest(const std::string &name) { if (name == "MD5") { @@ -157,7 +158,7 @@ static bool TestHMAC(FileTest *t, void *arg) { return true; } -int main(int argc, char *argv[]) { +static int Main(int argc, char *argv[]) { CRYPTO_library_init(); if (argc != 2) { @@ -167,3 +168,9 @@ int main(int argc, char *argv[]) { return FileTestMain(TestHMAC, nullptr, argv[1]); } + +} // namespace bssl + +int main(int argc, char **argv) { + return bssl::Main(argc, argv); +} diff --git a/crypto/test/scoped_types.h b/crypto/test/scoped_types.h index 76e38af8..c124235d 100644 --- a/crypto/test/scoped_types.h +++ b/crypto/test/scoped_types.h @@ -125,15 +125,6 @@ using ScopedX509_STORE_CTX = ScopedOpenSSLType; -using ScopedCBB = ScopedOpenSSLContext; -using ScopedEVP_CIPHER_CTX = ScopedOpenSSLContext; -using ScopedEVP_MD_CTX = ScopedOpenSSLContext; -using ScopedHMAC_CTX = ScopedOpenSSLContext; - using ScopedOpenSSLBytes = std::unique_ptr>; using ScopedOpenSSLString = std::unique_ptr>; diff --git a/crypto/x509/x509_test.cc b/crypto/x509/x509_test.cc index 650163a8..d1eed2a3 100644 --- a/crypto/x509/x509_test.cc +++ b/crypto/x509/x509_test.cc @@ -17,15 +17,15 @@ #include #include +#include #include -#include #include -#include #include #include #include "../test/scoped_types.h" +namespace bssl { static const char kCrossSigningRootPEM[] = "-----BEGIN CERTIFICATE-----\n" @@ -457,7 +457,7 @@ static bool TestSignCtx() { return true; } -int main(int argc, char **argv) { +static int Main() { CRYPTO_library_init(); if (!TestVerify() || @@ -470,3 +470,9 @@ int main(int argc, char **argv) { printf("PASS\n"); return 0; } + +} // namespace bssl + +int main() { + return bssl::Main(); +} diff --git a/include/openssl/c++/bytestring.h b/include/openssl/c++/bytestring.h new file mode 100644 index 00000000..87325a9d --- /dev/null +++ b/include/openssl/c++/bytestring.h @@ -0,0 +1,27 @@ +/* Copyright (c) 2016, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_CXX_BYTESTRING_H +#define OPENSSL_HEADER_CXX_BYTESTRING_H + +#include +#include + +namespace bssl { + +using ScopedCBB = ScopedContext; + +} // namespace bssl + +#endif /* OPENSSL_HEADER_CXX_BYTESTRING_H */ diff --git a/include/openssl/c++/cipher.h b/include/openssl/c++/cipher.h new file mode 100644 index 00000000..997a6061 --- /dev/null +++ b/include/openssl/c++/cipher.h @@ -0,0 +1,29 @@ +/* Copyright (c) 2016, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_CXX_CIPHER_H +#define OPENSSL_HEADER_CXX_CIPHER_H + +#include +#include + +namespace bssl { + +using ScopedEVP_CIPHER_CTX = + ScopedContext; + +} // namespace bssl + +#endif /* OPENSSL_HEADER_CXX_CIPHER_H */ diff --git a/include/openssl/c++/digest.h b/include/openssl/c++/digest.h new file mode 100644 index 00000000..f557921d --- /dev/null +++ b/include/openssl/c++/digest.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2016, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_CXX_DIGEST_H +#define OPENSSL_HEADER_CXX_DIGEST_H + +#include +#include + +namespace bssl { + +using ScopedEVP_MD_CTX = + ScopedContext; + +} // namespace bssl + +#endif /* OPENSSL_HEADER_CXX_DIGEST_H */ diff --git a/include/openssl/c++/hmac.h b/include/openssl/c++/hmac.h new file mode 100644 index 00000000..0e8d2e13 --- /dev/null +++ b/include/openssl/c++/hmac.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2016, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_CXX_HMAC_H +#define OPENSSL_HEADER_CXX_HMAC_H + +#include +#include + +namespace bssl { + +using ScopedHMAC_CTX = + ScopedContext; + +} // namespace bssl + +#endif /* OPENSSL_HEADER_CXX_HMAC_H */ diff --git a/ssl/test/bssl_shim.cc b/ssl/test/bssl_shim.cc index 61bdd7bf..aa7f3982 100644 --- a/ssl/test/bssl_shim.cc +++ b/ssl/test/bssl_shim.cc @@ -43,6 +43,7 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #include #include #include +#include #include #include #include @@ -61,6 +62,7 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #include "scoped_types.h" #include "test_config.h" +namespace bssl { #if !defined(OPENSSL_WINDOWS) static int closesocket(int sock) { @@ -1634,7 +1636,7 @@ class StderrDelimiter { ~StderrDelimiter() { fprintf(stderr, "--- DONE ---\n"); } }; -int main(int argc, char **argv) { +static 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; @@ -1690,3 +1692,9 @@ int main(int argc, char **argv) { return 0; } + +} // namespace bssl + +int main(int argc, char **argv) { + return bssl::Main(argc, argv); +}