Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: net/ssl/ssl_cipher_suite_names_unittest.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/ssl/ssl_cipher_suite_names.cc ('k') | net/ssl/ssl_client_auth_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/ssl/ssl_cipher_suite_names.h"
6
7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace net {
11
12 namespace {
13
14 TEST(CipherSuiteNamesTest, Basic) {
15 const char *key_exchange, *cipher, *mac;
16 bool is_aead;
17
18 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0xc001);
19 EXPECT_STREQ("ECDH_ECDSA", key_exchange);
20 EXPECT_STREQ("NULL", cipher);
21 EXPECT_STREQ("SHA1", mac);
22 EXPECT_FALSE(is_aead);
23
24 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0x009f);
25 EXPECT_STREQ("DHE_RSA", key_exchange);
26 EXPECT_STREQ("AES_256_GCM", cipher);
27 EXPECT_TRUE(is_aead);
28 EXPECT_EQ(NULL, mac);
29
30 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0xcc15);
31 EXPECT_STREQ("DHE_RSA", key_exchange);
32 EXPECT_STREQ("CHACHA20_POLY1305", cipher);
33 EXPECT_TRUE(is_aead);
34 EXPECT_EQ(NULL, mac);
35
36 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 0xff31);
37 EXPECT_STREQ("???", key_exchange);
38 EXPECT_STREQ("???", cipher);
39 EXPECT_STREQ("???", mac);
40 EXPECT_FALSE(is_aead);
41 }
42
43 TEST(CipherSuiteNamesTest, ParseSSLCipherString) {
44 uint16 cipher_suite = 0;
45 EXPECT_TRUE(ParseSSLCipherString("0x0004", &cipher_suite));
46 EXPECT_EQ(0x00004u, cipher_suite);
47
48 EXPECT_TRUE(ParseSSLCipherString("0xBEEF", &cipher_suite));
49 EXPECT_EQ(0xBEEFu, cipher_suite);
50 }
51
52 TEST(CipherSuiteNamesTest, ParseSSLCipherStringFails) {
53 const char* const cipher_strings[] = {
54 "0004",
55 "0x004",
56 "0xBEEFY",
57 };
58
59 for (size_t i = 0; i < arraysize(cipher_strings); ++i) {
60 uint16 cipher_suite = 0;
61 EXPECT_FALSE(ParseSSLCipherString(cipher_strings[i], &cipher_suite));
62 }
63 }
64
65 TEST(CipherSuiteNamesTest, SecureCipherSuites) {
66 // Picked some random cipher suites.
67 EXPECT_FALSE(IsSecureTLSCipherSuite(0x0));
68 EXPECT_FALSE(IsSecureTLSCipherSuite(0x39));
69 EXPECT_FALSE(IsSecureTLSCipherSuite(0xc5));
70 EXPECT_FALSE(IsSecureTLSCipherSuite(0xc00f));
71 EXPECT_FALSE(IsSecureTLSCipherSuite(0xc083));
72
73 // Non-existent cipher suite.
74 EXPECT_FALSE(IsSecureTLSCipherSuite(0xffff)) << "Doesn't exist!";
75
76 // Secure ones.
77 EXPECT_TRUE(IsSecureTLSCipherSuite(0xcc13));
78 EXPECT_TRUE(IsSecureTLSCipherSuite(0xcc14));
79 EXPECT_TRUE(IsSecureTLSCipherSuite(0xcc15));
80 }
81
82 } // anonymous namespace
83
84 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/ssl_cipher_suite_names.cc ('k') | net/ssl/ssl_client_auth_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698