| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(CommonCertSets, 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 const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC()); | 79 const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC()); |
| 80 | 80 |
| 81 const uint64 in_hash = GG_UINT64_C(0xde8086f914a3af54); | 81 const uint64 in_hash = GG_UINT64_C(0xc9fef74053f99f39); |
| 82 uint64 hash; | 82 uint64 hash; |
| 83 uint32 index; | 83 uint32 index; |
| 84 ASSERT_TRUE(sets->MatchCert( | 84 ASSERT_TRUE(sets->MatchCert( |
| 85 gia, | 85 gia, |
| 86 StringPiece(reinterpret_cast<const char*>(&in_hash), 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 = sets->GetCert(hash, index); | 90 StringPiece gia_copy = sets->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(CommonCertSets, NonMatch) { | 96 TEST(CommonCertSets, NonMatch) { |
| 97 const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC()); | 97 const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC()); |
| 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(0xc9fef74053f99f39); |
| 100 uint64 hash; | 100 uint64 hash; |
| 101 uint32 index; | 101 uint32 index; |
| 102 EXPECT_FALSE(sets->MatchCert( | 102 EXPECT_FALSE(sets->MatchCert( |
| 103 not_a_cert, | 103 not_a_cert, |
| 104 StringPiece(reinterpret_cast<const char*>(&in_hash), 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 |