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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 TEST(CipherSuiteNamesTest, Basic) { | 14 TEST(CipherSuiteNamesTest, Basic) { |
15 const char *key_exchange, *cipher, *mac; | 15 const char* key_exchange, *cipher, *mac; |
16 bool is_aead; | 16 bool is_aead; |
17 | 17 |
18 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0xc001); | 18 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0xc001); |
19 EXPECT_STREQ("ECDH_ECDSA", key_exchange); | 19 EXPECT_STREQ("ECDH_ECDSA", key_exchange); |
20 EXPECT_STREQ("NULL", cipher); | 20 EXPECT_STREQ("NULL", cipher); |
21 EXPECT_STREQ("SHA1", mac); | 21 EXPECT_STREQ("SHA1", mac); |
22 EXPECT_FALSE(is_aead); | 22 EXPECT_FALSE(is_aead); |
23 | 23 |
24 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0x009f); | 24 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0x009f); |
25 EXPECT_STREQ("DHE_RSA", key_exchange); | 25 EXPECT_STREQ("DHE_RSA", key_exchange); |
(...skipping 12 matching lines...) Expand all Loading... |
38 uint16 cipher_suite = 0; | 38 uint16 cipher_suite = 0; |
39 EXPECT_TRUE(ParseSSLCipherString("0x0004", &cipher_suite)); | 39 EXPECT_TRUE(ParseSSLCipherString("0x0004", &cipher_suite)); |
40 EXPECT_EQ(0x00004u, cipher_suite); | 40 EXPECT_EQ(0x00004u, cipher_suite); |
41 | 41 |
42 EXPECT_TRUE(ParseSSLCipherString("0xBEEF", &cipher_suite)); | 42 EXPECT_TRUE(ParseSSLCipherString("0xBEEF", &cipher_suite)); |
43 EXPECT_EQ(0xBEEFu, cipher_suite); | 43 EXPECT_EQ(0xBEEFu, cipher_suite); |
44 } | 44 } |
45 | 45 |
46 TEST(CipherSuiteNamesTest, ParseSSLCipherStringFails) { | 46 TEST(CipherSuiteNamesTest, ParseSSLCipherStringFails) { |
47 const char* const cipher_strings[] = { | 47 const char* const cipher_strings[] = { |
48 "0004", | 48 "0004", "0x004", "0xBEEFY", |
49 "0x004", | |
50 "0xBEEFY", | |
51 }; | 49 }; |
52 | 50 |
53 for (size_t i = 0; i < arraysize(cipher_strings); ++i) { | 51 for (size_t i = 0; i < arraysize(cipher_strings); ++i) { |
54 uint16 cipher_suite = 0; | 52 uint16 cipher_suite = 0; |
55 EXPECT_FALSE(ParseSSLCipherString(cipher_strings[i], &cipher_suite)); | 53 EXPECT_FALSE(ParseSSLCipherString(cipher_strings[i], &cipher_suite)); |
56 } | 54 } |
57 } | 55 } |
58 | 56 |
59 } // anonymous namespace | 57 } // anonymous namespace |
60 | 58 |
61 } // namespace net | 59 } // namespace net |
OLD | NEW |