| 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 <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "net/quic/quic_utils.h" | 12 #include "net/quic/quic_utils.h" |
| 13 | 13 |
| 14 using base::StringPiece; | 14 using base::StringPiece; |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 namespace common_cert_set_1 { | |
| 19 #include "net/quic/crypto/common_cert_set_1.c" | |
| 20 } | |
| 21 | |
| 22 namespace common_cert_set_2 { | 18 namespace common_cert_set_2 { |
| 23 #include "net/quic/crypto/common_cert_set_2.c" | 19 #include "net/quic/crypto/common_cert_set_2.c" |
| 24 } | 20 } |
| 25 | 21 |
| 26 namespace common_cert_set_3 { | 22 namespace common_cert_set_3 { |
| 27 #include "net/quic/crypto/common_cert_set_3.c" | 23 #include "net/quic/crypto/common_cert_set_3.c" |
| 28 } | 24 } |
| 29 | 25 |
| 30 namespace { | 26 namespace { |
| 31 | 27 |
| 32 struct CertSet { | 28 struct CertSet { |
| 33 // num_certs contains the number of certificates in this set. | 29 // num_certs contains the number of certificates in this set. |
| 34 size_t num_certs; | 30 size_t num_certs; |
| 35 // certs is an array of |num_certs| pointers to the DER encoded certificates. | 31 // certs is an array of |num_certs| pointers to the DER encoded certificates. |
| 36 const unsigned char* const* certs; | 32 const unsigned char* const* certs; |
| 37 // lens is an array of |num_certs| integers describing the length, in bytes, | 33 // lens is an array of |num_certs| integers describing the length, in bytes, |
| 38 // of each certificate. | 34 // of each certificate. |
| 39 const size_t* lens; | 35 const size_t* lens; |
| 40 // hash contains the 64-bit, FNV-1a hash of this set. | 36 // hash contains the 64-bit, FNV-1a hash of this set. |
| 41 uint64_t hash; | 37 uint64_t hash; |
| 42 }; | 38 }; |
| 43 | 39 |
| 44 const CertSet kSets[] = { | 40 const CertSet kSets[] = { |
| 45 { | 41 { |
| 46 common_cert_set_1::kNumCerts, common_cert_set_1::kCerts, | |
| 47 common_cert_set_1::kLens, common_cert_set_1::kHash, | |
| 48 }, | |
| 49 { | |
| 50 common_cert_set_2::kNumCerts, common_cert_set_2::kCerts, | 42 common_cert_set_2::kNumCerts, common_cert_set_2::kCerts, |
| 51 common_cert_set_2::kLens, common_cert_set_2::kHash, | 43 common_cert_set_2::kLens, common_cert_set_2::kHash, |
| 52 }, | 44 }, |
| 53 { | 45 { |
| 54 common_cert_set_3::kNumCerts, common_cert_set_3::kCerts, | 46 common_cert_set_3::kNumCerts, common_cert_set_3::kCerts, |
| 55 common_cert_set_3::kLens, common_cert_set_3::kHash, | 47 common_cert_set_3::kLens, common_cert_set_3::kHash, |
| 56 }, | 48 }, |
| 57 }; | 49 }; |
| 58 | 50 |
| 59 const uint64_t kSetHashes[] = { | 51 const uint64_t kSetHashes[] = { |
| 60 common_cert_set_1::kHash, common_cert_set_2::kHash, | 52 common_cert_set_2::kHash, common_cert_set_3::kHash, |
| 61 common_cert_set_3::kHash, | |
| 62 }; | 53 }; |
| 63 | 54 |
| 64 // Compare returns a value less than, equal to or greater than zero if |a| is | 55 // Compare returns a value less than, equal to or greater than zero if |a| is |
| 65 // lexicographically less than, equal to or greater than |b|, respectively. | 56 // lexicographically less than, equal to or greater than |b|, respectively. |
| 66 int Compare(StringPiece a, const unsigned char* b, size_t b_len) { | 57 int Compare(StringPiece a, const unsigned char* b, size_t b_len) { |
| 67 size_t len = a.size(); | 58 size_t len = a.size(); |
| 68 if (len > b_len) { | 59 if (len > b_len) { |
| 69 len = b_len; | 60 len = b_len; |
| 70 } | 61 } |
| 71 int n = memcmp(a.data(), b, len); | 62 int n = memcmp(a.data(), b, len); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } // anonymous namespace | 159 } // anonymous namespace |
| 169 | 160 |
| 170 CommonCertSets::~CommonCertSets() {} | 161 CommonCertSets::~CommonCertSets() {} |
| 171 | 162 |
| 172 // static | 163 // static |
| 173 const CommonCertSets* CommonCertSets::GetInstanceQUIC() { | 164 const CommonCertSets* CommonCertSets::GetInstanceQUIC() { |
| 174 return CommonCertSetsQUIC::GetInstance(); | 165 return CommonCertSetsQUIC::GetInstance(); |
| 175 } | 166 } |
| 176 | 167 |
| 177 } // namespace net | 168 } // namespace net |
| OLD | NEW |