Change-Id: I7d1fa964f0d9817db885cd43057a23ec46f21702 Reviewed-on: https://boringssl-review.googlesource.com/10240 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>kris/onging/CECPQ3_patch15
@@ -22,12 +22,13 @@ | |||
#include <vector> | |||
#include <openssl/c++/bytestring.h> | |||
#include <openssl/crypto.h> | |||
#include <openssl/bytestring.h> | |||
#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(); | |||
} |
@@ -57,13 +57,13 @@ | |||
#include <string> | |||
#include <vector> | |||
#include <openssl/cipher.h> | |||
#include <openssl/c++/cipher.h> | |||
#include <openssl/crypto.h> | |||
#include <openssl/err.h> | |||
#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); | |||
} |
@@ -62,7 +62,7 @@ | |||
#include <vector> | |||
#include <openssl/bn.h> | |||
#include <openssl/bytestring.h> | |||
#include <openssl/c++/bytestring.h> | |||
#include <openssl/crypto.h> | |||
#include <openssl/err.h> | |||
#include <openssl/mem.h> | |||
@@ -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(); | |||
} |
@@ -16,15 +16,16 @@ | |||
#include <stdio.h> | |||
#include <string.h> | |||
#include <memory> | |||
#include <openssl/c++/digest.h> | |||
#include <openssl/crypto.h> | |||
#include <openssl/digest.h> | |||
#include <openssl/err.h> | |||
#include <openssl/md4.h> | |||
#include <openssl/md5.h> | |||
#include <openssl/sha.h> | |||
#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(); | |||
} |
@@ -17,7 +17,7 @@ | |||
#include <vector> | |||
#include <openssl/bytestring.h> | |||
#include <openssl/c++/bytestring.h> | |||
#include <openssl/crypto.h> | |||
#include <openssl/ec_key.h> | |||
#include <openssl/err.h> | |||
@@ -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(); | |||
} |
@@ -20,15 +20,15 @@ | |||
#include <utility> | |||
#include <vector> | |||
#include <openssl/bytestring.h> | |||
#include <openssl/c++/bytestring.h> | |||
#include <openssl/c++/digest.h> | |||
#include <openssl/crypto.h> | |||
#include <openssl/digest.h> | |||
#include <openssl/err.h> | |||
#include <openssl/evp.h> | |||
#include <openssl/rsa.h> | |||
#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(); | |||
} |
@@ -68,7 +68,7 @@ OPENSSL_MSVC_PRAGMA(warning(disable: 4702)) | |||
OPENSSL_MSVC_PRAGMA(warning(pop)) | |||
#include <openssl/bytestring.h> | |||
#include <openssl/c++/bytestring.h> | |||
#include <openssl/crypto.h> | |||
#include <openssl/digest.h> | |||
#include <openssl/err.h> | |||
@@ -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 <test file.txt>\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); | |||
} |
@@ -57,16 +57,17 @@ | |||
#include <stdio.h> | |||
#include <string.h> | |||
#include <memory> | |||
#include <string> | |||
#include <vector> | |||
#include <openssl/c++/hmac.h> | |||
#include <openssl/crypto.h> | |||
#include <openssl/digest.h> | |||
#include <openssl/hmac.h> | |||
#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); | |||
} |
@@ -125,15 +125,6 @@ using ScopedX509_STORE_CTX = ScopedOpenSSLType<X509_STORE_CTX, X509_STORE_CTX_fr | |||
using ScopedX509Stack = ScopedOpenSSLStack<STACK_OF(X509), X509, X509_free>; | |||
using ScopedCBB = ScopedOpenSSLContext<CBB, void, CBB_zero, CBB_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>>; | |||
@@ -17,15 +17,15 @@ | |||
#include <assert.h> | |||
#include <string.h> | |||
#include <openssl/c++/digest.h> | |||
#include <openssl/crypto.h> | |||
#include <openssl/digest.h> | |||
#include <openssl/err.h> | |||
#include <openssl/evp.h> | |||
#include <openssl/pem.h> | |||
#include <openssl/x509.h> | |||
#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(); | |||
} |
@@ -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 <openssl/bytestring.h> | |||
#include <openssl/c++/scoped_helpers.h> | |||
namespace bssl { | |||
using ScopedCBB = ScopedContext<CBB, void, CBB_zero, CBB_cleanup>; | |||
} // namespace bssl | |||
#endif /* OPENSSL_HEADER_CXX_BYTESTRING_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 <openssl/cipher.h> | |||
#include <openssl/c++/scoped_helpers.h> | |||
namespace bssl { | |||
using ScopedEVP_CIPHER_CTX = | |||
ScopedContext<EVP_CIPHER_CTX, int, EVP_CIPHER_CTX_init, | |||
EVP_CIPHER_CTX_cleanup>; | |||
} // namespace bssl | |||
#endif /* OPENSSL_HEADER_CXX_CIPHER_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 <openssl/c++/scoped_helpers.h> | |||
#include <openssl/evp.h> | |||
namespace bssl { | |||
using ScopedEVP_MD_CTX = | |||
ScopedContext<EVP_MD_CTX, int, EVP_MD_CTX_init, EVP_MD_CTX_cleanup>; | |||
} // namespace bssl | |||
#endif /* OPENSSL_HEADER_CXX_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_HMAC_H | |||
#define OPENSSL_HEADER_CXX_HMAC_H | |||
#include <openssl/c++/scoped_helpers.h> | |||
#include <openssl/hmac.h> | |||
namespace bssl { | |||
using ScopedHMAC_CTX = | |||
ScopedContext<HMAC_CTX, void, HMAC_CTX_init, HMAC_CTX_cleanup>; | |||
} // namespace bssl | |||
#endif /* OPENSSL_HEADER_CXX_HMAC_H */ |
@@ -43,6 +43,7 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) | |||
#include <openssl/bio.h> | |||
#include <openssl/buf.h> | |||
#include <openssl/bytestring.h> | |||
#include <openssl/c++/digest.h> | |||
#include <openssl/cipher.h> | |||
#include <openssl/crypto.h> | |||
#include <openssl/err.h> | |||
@@ -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); | |||
} |