OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/quic/crypto/common_cert_set.h" | 5 #include "net/quic/crypto/common_cert_set.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 using base::StringPiece; | 9 using base::StringPiece; |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 0xf5, 0xef, 0x24, 0x4c, 0xfd, 0xe4, 0x4b, 0xca, 0x7f, 0x5e, 0x63, 0xab, | 65 0xf5, 0xef, 0x24, 0x4c, 0xfd, 0xe4, 0x4b, 0xca, 0x7f, 0x5e, 0x63, 0xab, |
66 0x99, 0x27, 0xcb, 0x9f, 0x36, 0x21, 0x2c, 0xb9, 0x10, 0x60, 0x67, 0xcd, | 66 0x99, 0x27, 0xcb, 0x9f, 0x36, 0x21, 0x2c, 0xb9, 0x10, 0x60, 0x67, 0xcd, |
67 0xd2, 0xb4, 0xf0, 0xf0, 0xab, 0x71, 0xe5, 0x8b, 0x5a, 0x89, 0x27, 0x11, | 67 0xd2, 0xb4, 0xf0, 0xf0, 0xab, 0x71, 0xe5, 0x8b, 0x5a, 0x89, 0x27, 0x11, |
68 0x84, 0xaa, 0x8e, 0xbf, 0x99, 0xf0, 0x9d, 0x09, 0x21, 0x0a, 0x52, 0x19, | 68 0x84, 0xaa, 0x8e, 0xbf, 0x99, 0xf0, 0x9d, 0x09, 0x21, 0x0a, 0x52, 0x19, |
69 0x9a, 0x5a, 0x09, 0xd2, 0x90, 0xb7, 0xfa, 0x0c, 0xf8, 0x7e, 0x78, 0xa2, | 69 0x9a, 0x5a, 0x09, 0xd2, 0x90, 0xb7, 0xfa, 0x0c, 0xf8, 0x7e, 0x78, 0xa2, |
70 0xb0, 0x85, 0xaf, 0x5c, 0x4c, 0x99, 0xd9, 0x5c, 0x55, 0x29, 0xf9, 0xa5, | 70 0xb0, 0x85, 0xaf, 0x5c, 0x4c, 0x99, 0xd9, 0x5c, 0x55, 0x29, 0xf9, 0xa5, |
71 0x51, 0x42, 0x2e, 0x3a, 0xcb, 0x38, 0x8c, 0x78, 0x3b, 0xcb, 0xf8, 0xfb, | 71 0x51, 0x42, 0x2e, 0x3a, 0xcb, 0x38, 0x8c, 0x78, 0x3b, 0xcb, 0xf8, 0xfb, |
72 0x95, 0x87, 0xbc, 0xbc, 0x90, 0xf9, 0x50, 0x32, | 72 0x95, 0x87, 0xbc, 0xbc, 0x90, 0xf9, 0x50, 0x32, |
73 }; | 73 }; |
74 | 74 |
75 TEST(CommonCertSet, FindGIA) { | 75 TEST(CommonCertSets, FindGIA) { |
76 StringPiece gia(reinterpret_cast<const char*>(kGIACertificate), | 76 StringPiece gia(reinterpret_cast<const char*>(kGIACertificate), |
77 sizeof(kGIACertificate)); | 77 sizeof(kGIACertificate)); |
78 | 78 |
79 CommonCertSetQUIC set; | 79 CommonCertSetsQUIC set; |
80 | 80 |
81 const uint64 in_hash = GG_UINT64_C(0xde8086f914a3af54); | 81 const uint64 in_hash = GG_UINT64_C(0xde8086f914a3af54); |
82 uint64 hash; | 82 uint64 hash; |
83 uint32 index; | 83 uint32 index; |
84 ASSERT_TRUE(set.MatchCert( | 84 ASSERT_TRUE(set.MatchCert( |
85 gia, StringPiece(reinterpret_cast<const char*>(&in_hash), | 85 gia, |
86 sizeof(in_hash)), | 86 StringPiece(reinterpret_cast<const char*>(&in_hash), sizeof(in_hash)), |
87 &hash, &index)); | 87 &hash, &index)); |
88 EXPECT_EQ(in_hash, hash); | 88 EXPECT_EQ(in_hash, hash); |
89 | 89 |
90 StringPiece gia_copy = set.GetCert(hash, index); | 90 StringPiece gia_copy = set.GetCert(hash, index); |
91 EXPECT_FALSE(gia_copy.empty()); | 91 EXPECT_FALSE(gia_copy.empty()); |
92 ASSERT_EQ(gia.size(), gia_copy.size()); | 92 ASSERT_EQ(gia.size(), gia_copy.size()); |
93 EXPECT_TRUE(0 == memcmp(gia.data(), gia_copy.data(), gia.size())); | 93 EXPECT_TRUE(0 == memcmp(gia.data(), gia_copy.data(), gia.size())); |
94 } | 94 } |
95 | 95 |
96 TEST(CommonCertSet, NonMatch) { | 96 TEST(CommonCertSets, NonMatch) { |
97 CommonCertSetQUIC set; | 97 CommonCertSetsQUIC set; |
98 StringPiece not_a_cert("hello"); | 98 StringPiece not_a_cert("hello"); |
99 const uint64 in_hash = GG_UINT64_C(0xde8086f914a3af54); | 99 const uint64 in_hash = GG_UINT64_C(0xde8086f914a3af54); |
100 uint64 hash; | 100 uint64 hash; |
101 uint32 index; | 101 uint32 index; |
102 EXPECT_FALSE(set.MatchCert( | 102 EXPECT_FALSE(set.MatchCert( |
103 not_a_cert, StringPiece(reinterpret_cast<const char*>(&in_hash), | 103 not_a_cert, |
104 sizeof(in_hash)), | 104 StringPiece(reinterpret_cast<const char*>(&in_hash), sizeof(in_hash)), |
105 &hash, &index)); | 105 &hash, &index)); |
106 } | 106 } |
107 | 107 |
108 } // namespace test | 108 } // namespace test |
109 } // namespace net | 109 } // namespace net |
OLD | NEW |