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 #ifndef NET_QUIC_CRYPTO_COMMON_CERT_SET_H_ | 5 #ifndef NET_QUIC_CRYPTO_COMMON_CERT_SET_H_ |
6 #define NET_QUIC_CRYPTO_COMMON_CERT_SET_H_ | 6 #define NET_QUIC_CRYPTO_COMMON_CERT_SET_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
12 #include "net/quic/crypto/crypto_protocol.h" | 12 #include "net/quic/crypto/crypto_protocol.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 // CommonCertSets is an interface to an object that contains a number of common | 16 // CommonCertSets is an interface to an object that contains a number of common |
17 // certificate sets and can match against them. | 17 // certificate sets and can match against them. |
18 class NET_EXPORT_PRIVATE CommonCertSets { | 18 class NET_EXPORT_PRIVATE CommonCertSets { |
19 public: | 19 public: |
20 virtual ~CommonCertSets(); | 20 virtual ~CommonCertSets(); |
21 | 21 |
22 // GetCommonHashes returns a StringPiece containing the hashes of common sets | 22 // GetCommonHashes returns a StringPiece containing the hashes of common sets |
23 // supported by this object. | 23 // supported by this object. The 64-bit hashes are concatenated in the |
| 24 // StringPiece. |
24 virtual base::StringPiece GetCommonHashes() const = 0; | 25 virtual base::StringPiece GetCommonHashes() const = 0; |
25 | 26 |
26 // GetCert returns a specific certificate in the common set identified by | 27 // GetCert returns a specific certificate (at index |index|) in the common |
27 // |hash|. If no such certificate is known, an empty StringPiece is returned. | 28 // set identified by |hash|. If no such certificate is known, an empty |
| 29 // StringPiece is returned. |
28 virtual base::StringPiece GetCert(uint64 hash, uint32 index) const = 0; | 30 virtual base::StringPiece GetCert(uint64 hash, uint32 index) const = 0; |
29 | 31 |
30 // MatchCert tries to find |cert| in one of the common certificate sets | 32 // MatchCert tries to find |cert| in one of the common certificate sets |
31 // identified by |common_set_hashes|. On success it puts the hash in | 33 // identified by |common_set_hashes|. On success it puts the hash of the |
32 // |out_hash|, the index in the set in |out_index| and returns true. Otherwise | 34 // set in |out_hash|, the index of |cert| in the set in |out_index| and |
33 // it returns false. | 35 // returns true. Otherwise it returns false. |
34 virtual bool MatchCert(base::StringPiece cert, | 36 virtual bool MatchCert(base::StringPiece cert, |
35 base::StringPiece common_set_hashes, | 37 base::StringPiece common_set_hashes, |
36 uint64* out_hash, | 38 uint64* out_hash, |
37 uint32* out_index) const = 0; | 39 uint32* out_index) const = 0; |
38 }; | 40 }; |
39 | 41 |
40 // CommonCertSetsQUIC implements the CommonCertSet interface using the default | 42 // CommonCertSetsQUIC implements the CommonCertSets interface using the default |
41 // certificate sets. | 43 // certificate sets. |
42 class NET_EXPORT_PRIVATE CommonCertSetsQUIC : public CommonCertSets { | 44 class NET_EXPORT_PRIVATE CommonCertSetsQUIC : public CommonCertSets { |
43 public: | 45 public: |
44 CommonCertSetsQUIC(); | 46 CommonCertSetsQUIC(); |
45 | 47 |
46 // CommonCertSets interface. | 48 // CommonCertSets interface. |
47 virtual base::StringPiece GetCommonHashes() const OVERRIDE; | 49 virtual base::StringPiece GetCommonHashes() const OVERRIDE; |
48 | 50 |
49 virtual base::StringPiece GetCert(uint64 hash, uint32 index) const OVERRIDE; | 51 virtual base::StringPiece GetCert(uint64 hash, uint32 index) const OVERRIDE; |
50 | 52 |
51 virtual bool MatchCert(base::StringPiece cert, | 53 virtual bool MatchCert(base::StringPiece cert, |
52 base::StringPiece common_set_hashes, | 54 base::StringPiece common_set_hashes, |
53 uint64* out_hash, | 55 uint64* out_hash, |
54 uint32* out_index) const OVERRIDE; | 56 uint32* out_index) const OVERRIDE; |
55 | 57 |
56 private: | 58 private: |
57 DISALLOW_COPY_AND_ASSIGN(CommonCertSetsQUIC); | 59 DISALLOW_COPY_AND_ASSIGN(CommonCertSetsQUIC); |
58 }; | 60 }; |
59 | 61 |
60 } // namespace net | 62 } // namespace net |
61 | 63 |
62 #endif // NET_QUIC_CRYPTO_COMMON_CERT_SET_H_ | 64 #endif // NET_QUIC_CRYPTO_COMMON_CERT_SET_H_ |
OLD | NEW |