OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/ssl/ssl_cipher_suite_names.h" | 5 #include "net/ssl/ssl_cipher_suite_names.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/stringprintf.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 namespace net { | 11 namespace net { |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 TEST(CipherSuiteNamesTest, Basic) { | 15 TEST(CipherSuiteNamesTest, Basic) { |
15 const char *key_exchange, *cipher, *mac; | 16 const char *key_exchange, *cipher, *mac; |
16 bool is_aead; | 17 bool is_aead; |
17 | 18 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 EXPECT_TRUE(IsTLSCipherSuiteAllowedByHTTP2( | 132 EXPECT_TRUE(IsTLSCipherSuiteAllowedByHTTP2( |
132 0xcc13 /* ECDHE_RSA_WITH_CHACHA20_POLY1305 (non-standard) */)); | 133 0xcc13 /* ECDHE_RSA_WITH_CHACHA20_POLY1305 (non-standard) */)); |
133 EXPECT_TRUE(IsTLSCipherSuiteAllowedByHTTP2( | 134 EXPECT_TRUE(IsTLSCipherSuiteAllowedByHTTP2( |
134 0xcc14 /* ECDHE_ECDSA_WITH_CHACHA20_POLY1305 (non-standard) */)); | 135 0xcc14 /* ECDHE_ECDSA_WITH_CHACHA20_POLY1305 (non-standard) */)); |
135 EXPECT_TRUE(IsTLSCipherSuiteAllowedByHTTP2( | 136 EXPECT_TRUE(IsTLSCipherSuiteAllowedByHTTP2( |
136 0xcca8 /* ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 */)); | 137 0xcca8 /* ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 */)); |
137 EXPECT_TRUE(IsTLSCipherSuiteAllowedByHTTP2( | 138 EXPECT_TRUE(IsTLSCipherSuiteAllowedByHTTP2( |
138 0xcca9 /* ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 */)); | 139 0xcca9 /* ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 */)); |
139 } | 140 } |
140 | 141 |
142 TEST(CipherSuiteNamesTest, CECPQ1) { | |
143 const std::vector<uint16_t> kCECPQ1CipherSuites = {0x16b7, 0x16b8, 0x16b9, | |
144 0x16ba}; | |
mab
2016/05/26 21:14:57
Using a loop seems inconsistent with the prevailin
agl
2016/05/26 23:26:08
Indeed, but I don't like the duplication here :)
| |
145 const char *key_exchange, *cipher, *mac; | |
146 bool is_aead; | |
147 | |
148 for (const uint16_t cipher_suite_id : kCECPQ1CipherSuites) { | |
149 SCOPED_TRACE(base::StringPrintf("cipher suite %x", cipher_suite_id)); | |
150 EXPECT_TRUE(IsTLSCipherSuiteAllowedByHTTP2(cipher_suite_id)); | |
mab
2016/05/26 21:14:58
In the preceding stanza there is a "(non-standard)
agl
2016/05/26 23:26:08
Done.
| |
151 EXPECT_TRUE(IsSecureTLSCipherSuite(cipher_suite_id)); | |
152 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, | |
153 cipher_suite_id); | |
154 EXPECT_TRUE(is_aead); | |
155 EXPECT_EQ(nullptr, mac); | |
156 } | |
157 | |
158 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0x16b7); | |
159 EXPECT_STREQ("CECPQ1_RSA", key_exchange); | |
160 EXPECT_STREQ("CHACHA20_POLY1305", cipher); | |
161 | |
162 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0x16b8); | |
163 EXPECT_STREQ("CECPQ1_ECDSA", key_exchange); | |
164 EXPECT_STREQ("CHACHA20_POLY1305", cipher); | |
165 | |
166 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0x16b9); | |
167 EXPECT_STREQ("CECPQ1_RSA", key_exchange); | |
168 EXPECT_STREQ("AES_256_GCM", cipher); | |
169 | |
170 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0x16ba); | |
171 EXPECT_STREQ("CECPQ1_ECDSA", key_exchange); | |
172 EXPECT_STREQ("AES_256_GCM", cipher); | |
173 } | |
174 | |
141 } // anonymous namespace | 175 } // anonymous namespace |
142 | 176 |
143 } // namespace net | 177 } // namespace net |
OLD | NEW |