| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdarg.h> | 5 #include <stdarg.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 bool BoringSSLPath(base::FilePath* result) { | 49 bool BoringSSLPath(base::FilePath* result) { |
| 50 if (!PathService::Get(base::DIR_SOURCE_ROOT, result)) | 50 if (!PathService::Get(base::DIR_SOURCE_ROOT, result)) |
| 51 return false; | 51 return false; |
| 52 | 52 |
| 53 *result = result->Append(FILE_PATH_LITERAL("third_party")); | 53 *result = result->Append(FILE_PATH_LITERAL("third_party")); |
| 54 *result = result->Append(FILE_PATH_LITERAL("boringssl")); | 54 *result = result->Append(FILE_PATH_LITERAL("boringssl")); |
| 55 *result = result->Append(FILE_PATH_LITERAL("src")); | 55 *result = result->Append(FILE_PATH_LITERAL("src")); |
| 56 return true; | 56 return true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool CryptoCipherPath(base::FilePath *result) { | 59 bool CryptoCipherTestPath(base::FilePath *result) { |
| 60 if (!BoringSSLPath(result)) | 60 if (!BoringSSLPath(result)) |
| 61 return false; | 61 return false; |
| 62 | 62 |
| 63 *result = result->Append(FILE_PATH_LITERAL("crypto")); | 63 *result = result->Append(FILE_PATH_LITERAL("crypto")); |
| 64 *result = result->Append(FILE_PATH_LITERAL("cipher")); | 64 *result = result->Append(FILE_PATH_LITERAL("cipher")); |
| 65 *result = result->Append(FILE_PATH_LITERAL("test")); |
| 65 return true; | 66 return true; |
| 66 } | 67 } |
| 67 | 68 |
| 68 } // anonymous namespace | 69 } // anonymous namespace |
| 69 | 70 |
| 70 TEST(BoringSSL, AES128GCM) { | 71 struct AEADTest { |
| 71 base::FilePath data_file; | 72 const base::CommandLine::CharType *name; |
| 72 ASSERT_TRUE(CryptoCipherPath(&data_file)); | 73 const base::FilePath::CharType *test_vector_filename; |
| 73 data_file = data_file.Append(FILE_PATH_LITERAL("aes_128_gcm_tests.txt")); | 74 }; |
| 74 | 75 |
| 75 std::vector<base::CommandLine::StringType> args; | 76 static const AEADTest kAEADTests[] = { |
| 76 args.push_back(FILE_PATH_LITERAL("aes-128-gcm")); | 77 {FILE_PATH_LITERAL("aes-128-gcm"), |
| 77 args.push_back(data_file.value()); | 78 FILE_PATH_LITERAL("aes_128_gcm_tests.txt")}, |
| 79 {FILE_PATH_LITERAL("aes-128-key-wrap"), |
| 80 FILE_PATH_LITERAL("aes_128_key_wrap_tests.txt")}, |
| 81 {FILE_PATH_LITERAL("aes-256-gcm"), |
| 82 FILE_PATH_LITERAL("aes_256_gcm_tests.txt")}, |
| 83 {FILE_PATH_LITERAL("aes-256-key-wrap"), |
| 84 FILE_PATH_LITERAL("aes_256_key_wrap_tests.txt")}, |
| 85 {FILE_PATH_LITERAL("chacha20-poly1305"), |
| 86 FILE_PATH_LITERAL("chacha20_poly1305_tests.txt")}, |
| 87 {FILE_PATH_LITERAL("rc4-md5-tls"), |
| 88 FILE_PATH_LITERAL("rc4_md5_tls_tests.txt")}, |
| 89 {FILE_PATH_LITERAL("rc4-sha1-tls"), |
| 90 FILE_PATH_LITERAL("rc4_sha1_tls_tests.txt")}, |
| 91 {FILE_PATH_LITERAL("aes-128-cbc-sha1-tls"), |
| 92 FILE_PATH_LITERAL("aes_128_cbc_sha1_tls_tests.txt")}, |
| 93 {FILE_PATH_LITERAL("aes-128-cbc-sha1-tls-implicit-iv"), |
| 94 FILE_PATH_LITERAL("aes_128_cbc_sha1_tls_implicit_iv_tests.txt")}, |
| 95 {FILE_PATH_LITERAL("aes-128-cbc-sha256-tls"), |
| 96 FILE_PATH_LITERAL("aes_128_cbc_sha256_tls_tests.txt")}, |
| 97 {FILE_PATH_LITERAL("aes-256-cbc-sha1-tls"), |
| 98 FILE_PATH_LITERAL("aes_256_cbc_sha1_tls_tests.txt")}, |
| 99 {FILE_PATH_LITERAL("aes-256-cbc-sha1-tls-implicit-iv"), |
| 100 FILE_PATH_LITERAL("aes_256_cbc_sha1_tls_implicit_iv_tests.txt")}, |
| 101 {FILE_PATH_LITERAL("aes-256-cbc-sha256-tls"), |
| 102 FILE_PATH_LITERAL("aes_256_cbc_sha256_tls_tests.txt")}, |
| 103 {FILE_PATH_LITERAL("aes-256-cbc-sha384-tls"), |
| 104 FILE_PATH_LITERAL("aes_256_cbc_sha384_tls_tests.txt")}, |
| 105 {FILE_PATH_LITERAL("des-ede3-cbc-sha1-tls"), |
| 106 FILE_PATH_LITERAL("des_ede3_cbc_sha1_tls_tests.txt")}, |
| 107 {FILE_PATH_LITERAL("des-ede3-cbc-sha1-tls-implicit-iv"), |
| 108 FILE_PATH_LITERAL("des_ede3_cbc_sha1_tls_implicit_iv_tests.txt")}, |
| 109 {FILE_PATH_LITERAL("rc4-md5-ssl3"), |
| 110 FILE_PATH_LITERAL("rc4_md5_ssl3_tests.txt")}, |
| 111 {FILE_PATH_LITERAL("rc4-sha1-ssl3"), |
| 112 FILE_PATH_LITERAL("rc4_sha1_ssl3_tests.txt")}, |
| 113 {FILE_PATH_LITERAL("aes-128-cbc-sha1-ssl3"), |
| 114 FILE_PATH_LITERAL("aes_128_cbc_sha1_ssl3_tests.txt")}, |
| 115 {FILE_PATH_LITERAL("aes-256-cbc-sha1-ssl3"), |
| 116 FILE_PATH_LITERAL("aes_256_cbc_sha1_ssl3_tests.txt")}, |
| 117 {FILE_PATH_LITERAL("des-ede3-cbc-sha1-ssl3"), |
| 118 FILE_PATH_LITERAL("des_ede3_cbc_sha1_ssl3_tests.txt")}, |
| 119 }; |
| 78 | 120 |
| 79 TestProcess("aead_test", args); | 121 TEST(BoringSSL, AEADs) { |
| 80 } | 122 base::FilePath test_vector_dir; |
| 123 ASSERT_TRUE(CryptoCipherTestPath(&test_vector_dir)); |
| 81 | 124 |
| 82 TEST(BoringSSL, AES256GCM) { | 125 for (size_t i = 0; i < arraysize(kAEADTests); i++) { |
| 83 base::FilePath data_file; | 126 const AEADTest& test = kAEADTests[i]; |
| 84 ASSERT_TRUE(CryptoCipherPath(&data_file)); | 127 SCOPED_TRACE(test.name); |
| 85 data_file = data_file.Append(FILE_PATH_LITERAL("aes_256_gcm_tests.txt")); | |
| 86 | 128 |
| 87 std::vector<base::CommandLine::StringType> args; | 129 base::FilePath test_vector_file = |
| 88 args.push_back(FILE_PATH_LITERAL("aes-256-gcm")); | 130 test_vector_dir.Append(test.test_vector_filename); |
| 89 args.push_back(data_file.value()); | |
| 90 | 131 |
| 91 TestProcess("aead_test", args); | 132 std::vector<base::CommandLine::StringType> args; |
| 92 } | 133 args.push_back(test.name); |
| 134 args.push_back(test_vector_file.value()); |
| 93 | 135 |
| 94 TEST(BoringSSL, ChaCha20Poly1305) { | 136 TestProcess("aead_test", args); |
| 95 base::FilePath data_file; | 137 } |
| 96 ASSERT_TRUE(CryptoCipherPath(&data_file)); | |
| 97 data_file = | |
| 98 data_file.Append(FILE_PATH_LITERAL("chacha20_poly1305_tests.txt")); | |
| 99 | |
| 100 std::vector<base::CommandLine::StringType> args; | |
| 101 args.push_back(FILE_PATH_LITERAL("chacha20-poly1305")); | |
| 102 args.push_back(data_file.value()); | |
| 103 | |
| 104 TestProcess("aead_test", args); | |
| 105 } | |
| 106 | |
| 107 TEST(BoringSSL, RC4MD5) { | |
| 108 base::FilePath data_file; | |
| 109 ASSERT_TRUE(CryptoCipherPath(&data_file)); | |
| 110 data_file = data_file.Append(FILE_PATH_LITERAL("rc4_md5_tests.txt")); | |
| 111 | |
| 112 std::vector<base::CommandLine::StringType> args; | |
| 113 args.push_back(FILE_PATH_LITERAL("rc4-md5")); | |
| 114 args.push_back(data_file.value()); | |
| 115 | |
| 116 TestProcess("aead_test", args); | |
| 117 } | |
| 118 | |
| 119 TEST(BoringSSL, AESKW128) { | |
| 120 base::FilePath data_file; | |
| 121 ASSERT_TRUE(CryptoCipherPath(&data_file)); | |
| 122 data_file = data_file.Append(FILE_PATH_LITERAL("aes_128_key_wrap_tests.txt")); | |
| 123 | |
| 124 std::vector<base::CommandLine::StringType> args; | |
| 125 args.push_back(FILE_PATH_LITERAL("aes-128-key-wrap")); | |
| 126 args.push_back(data_file.value()); | |
| 127 | |
| 128 TestProcess("aead_test", args); | |
| 129 } | |
| 130 | |
| 131 TEST(BoringSSL, AESKW256) { | |
| 132 base::FilePath data_file; | |
| 133 ASSERT_TRUE(CryptoCipherPath(&data_file)); | |
| 134 data_file = data_file.Append(FILE_PATH_LITERAL("aes_256_key_wrap_tests.txt")); | |
| 135 | |
| 136 std::vector<base::CommandLine::StringType> args; | |
| 137 args.push_back(FILE_PATH_LITERAL("aes-256-key-wrap")); | |
| 138 args.push_back(data_file.value()); | |
| 139 | |
| 140 TestProcess("aead_test", args); | |
| 141 } | 138 } |
| 142 | 139 |
| 143 TEST(BoringSSL, Base64) { | 140 TEST(BoringSSL, Base64) { |
| 144 TestSimple("base64_test"); | 141 TestSimple("base64_test"); |
| 145 } | 142 } |
| 146 | 143 |
| 147 TEST(BoringSSL, BIO) { | 144 TEST(BoringSSL, BIO) { |
| 148 TestSimple("bio_test"); | 145 TestSimple("bio_test"); |
| 149 } | 146 } |
| 150 | 147 |
| 151 TEST(BoringSSL, BN) { | 148 TEST(BoringSSL, BN) { |
| 152 TestSimple("bn_test"); | 149 TestSimple("bn_test"); |
| 153 } | 150 } |
| 154 | 151 |
| 155 TEST(BoringSSL, ByteString) { | 152 TEST(BoringSSL, ByteString) { |
| 156 TestSimple("bytestring_test"); | 153 TestSimple("bytestring_test"); |
| 157 } | 154 } |
| 158 | 155 |
| 159 TEST(BoringSSL, ConstantTime) { | 156 TEST(BoringSSL, ConstantTime) { |
| 160 TestSimple("constant_time_test"); | 157 TestSimple("constant_time_test"); |
| 161 } | 158 } |
| 162 | 159 |
| 163 TEST(BoringSSL, Cipher) { | 160 TEST(BoringSSL, Cipher) { |
| 164 base::FilePath data_file; | 161 base::FilePath data_file; |
| 165 ASSERT_TRUE(CryptoCipherPath(&data_file)); | 162 ASSERT_TRUE(CryptoCipherTestPath(&data_file)); |
| 166 data_file = data_file.Append(FILE_PATH_LITERAL("cipher_test.txt")); | 163 data_file = data_file.Append(FILE_PATH_LITERAL("cipher_test.txt")); |
| 167 | 164 |
| 168 std::vector<base::CommandLine::StringType> args; | 165 std::vector<base::CommandLine::StringType> args; |
| 169 args.push_back(data_file.value()); | 166 args.push_back(data_file.value()); |
| 170 | 167 |
| 171 TestProcess("cipher_test", args); | 168 TestProcess("cipher_test", args); |
| 172 } | 169 } |
| 173 | 170 |
| 174 TEST(BoringSSL, DH) { | 171 TEST(BoringSSL, DH) { |
| 175 TestSimple("dh_test"); | 172 TestSimple("dh_test"); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 TestSimple("ssl_test"); | 228 TestSimple("ssl_test"); |
| 232 } | 229 } |
| 233 | 230 |
| 234 TEST(BoringSSL, PQueue) { | 231 TEST(BoringSSL, PQueue) { |
| 235 TestSimple("pqueue_test"); | 232 TestSimple("pqueue_test"); |
| 236 } | 233 } |
| 237 | 234 |
| 238 TEST(BoringSSL, HKDF) { | 235 TEST(BoringSSL, HKDF) { |
| 239 TestSimple("hkdf_test"); | 236 TestSimple("hkdf_test"); |
| 240 } | 237 } |
| OLD | NEW |