OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_CORE_CRYPTO_CHANNEL_ID_H_ | 5 #ifndef NET_QUIC_CORE_CRYPTO_CHANNEL_ID_H_ |
6 #define NET_QUIC_CORE_CRYPTO_CHANNEL_ID_H_ | 6 #define NET_QUIC_CORE_CRYPTO_CHANNEL_ID_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
13 #include "net/base/net_export.h" | |
14 #include "net/quic/core/quic_types.h" | 13 #include "net/quic/core/quic_types.h" |
| 14 #include "net/quic/platform/api/quic_export.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 // ChannelIDKey is an interface that supports signing with and serializing a | 18 // ChannelIDKey is an interface that supports signing with and serializing a |
19 // ChannelID key. | 19 // ChannelID key. |
20 class NET_EXPORT_PRIVATE ChannelIDKey { | 20 class QUIC_EXPORT_PRIVATE ChannelIDKey { |
21 public: | 21 public: |
22 virtual ~ChannelIDKey() {} | 22 virtual ~ChannelIDKey() {} |
23 | 23 |
24 // Sign signs |signed_data| using the ChannelID private key and puts the | 24 // Sign signs |signed_data| using the ChannelID private key and puts the |
25 // signature into |out_signature|. It returns true on success. | 25 // signature into |out_signature|. It returns true on success. |
26 virtual bool Sign(base::StringPiece signed_data, | 26 virtual bool Sign(base::StringPiece signed_data, |
27 std::string* out_signature) const = 0; | 27 std::string* out_signature) const = 0; |
28 | 28 |
29 // SerializeKey returns the serialized ChannelID public key. | 29 // SerializeKey returns the serialized ChannelID public key. |
30 virtual std::string SerializeKey() const = 0; | 30 virtual std::string SerializeKey() const = 0; |
31 }; | 31 }; |
32 | 32 |
33 // ChannelIDSourceCallback provides a generic mechanism for a ChannelIDSource | 33 // ChannelIDSourceCallback provides a generic mechanism for a ChannelIDSource |
34 // to call back after an asynchronous GetChannelIDKey operation. | 34 // to call back after an asynchronous GetChannelIDKey operation. |
35 class ChannelIDSourceCallback { | 35 class ChannelIDSourceCallback { |
36 public: | 36 public: |
37 virtual ~ChannelIDSourceCallback() {} | 37 virtual ~ChannelIDSourceCallback() {} |
38 | 38 |
39 // Run is called on the original thread to mark the completion of an | 39 // Run is called on the original thread to mark the completion of an |
40 // asynchonous GetChannelIDKey operation. If |*channel_id_key| is not nullptr | 40 // asynchonous GetChannelIDKey operation. If |*channel_id_key| is not nullptr |
41 // then the channel ID lookup is successful. |Run| may take ownership of | 41 // then the channel ID lookup is successful. |Run| may take ownership of |
42 // |*channel_id_key| by calling |release| on it. | 42 // |*channel_id_key| by calling |release| on it. |
43 virtual void Run(std::unique_ptr<ChannelIDKey>* channel_id_key) = 0; | 43 virtual void Run(std::unique_ptr<ChannelIDKey>* channel_id_key) = 0; |
44 }; | 44 }; |
45 | 45 |
46 // ChannelIDSource is an abstract interface by which a QUIC client can obtain | 46 // ChannelIDSource is an abstract interface by which a QUIC client can obtain |
47 // a ChannelIDKey for a given hostname. | 47 // a ChannelIDKey for a given hostname. |
48 class NET_EXPORT_PRIVATE ChannelIDSource { | 48 class QUIC_EXPORT_PRIVATE ChannelIDSource { |
49 public: | 49 public: |
50 virtual ~ChannelIDSource() {} | 50 virtual ~ChannelIDSource() {} |
51 | 51 |
52 // GetChannelIDKey looks up the ChannelIDKey for |hostname|. On success it | 52 // GetChannelIDKey looks up the ChannelIDKey for |hostname|. On success it |
53 // returns QUIC_SUCCESS and stores the ChannelIDKey in |*channel_id_key|, | 53 // returns QUIC_SUCCESS and stores the ChannelIDKey in |*channel_id_key|, |
54 // which the caller takes ownership of. On failure, it returns QUIC_FAILURE. | 54 // which the caller takes ownership of. On failure, it returns QUIC_FAILURE. |
55 // | 55 // |
56 // This function may also return QUIC_PENDING, in which case the | 56 // This function may also return QUIC_PENDING, in which case the |
57 // ChannelIDSource will call back, on the original thread, via |callback| | 57 // ChannelIDSource will call back, on the original thread, via |callback| |
58 // when complete. In this case, the ChannelIDSource will take ownership of | 58 // when complete. In this case, the ChannelIDSource will take ownership of |
59 // |callback|. | 59 // |callback|. |
60 virtual QuicAsyncStatus GetChannelIDKey( | 60 virtual QuicAsyncStatus GetChannelIDKey( |
61 const std::string& hostname, | 61 const std::string& hostname, |
62 std::unique_ptr<ChannelIDKey>* channel_id_key, | 62 std::unique_ptr<ChannelIDKey>* channel_id_key, |
63 ChannelIDSourceCallback* callback) = 0; | 63 ChannelIDSourceCallback* callback) = 0; |
64 }; | 64 }; |
65 | 65 |
66 // ChannelIDVerifier verifies ChannelID signatures. | 66 // ChannelIDVerifier verifies ChannelID signatures. |
67 class NET_EXPORT_PRIVATE ChannelIDVerifier { | 67 class QUIC_EXPORT_PRIVATE ChannelIDVerifier { |
68 public: | 68 public: |
69 // kContextStr is prepended to the data to be signed in order to ensure that | 69 // kContextStr is prepended to the data to be signed in order to ensure that |
70 // a ChannelID signature cannot be used in a different context. (The | 70 // a ChannelID signature cannot be used in a different context. (The |
71 // terminating NUL byte is inclued.) | 71 // terminating NUL byte is inclued.) |
72 static const char kContextStr[]; | 72 static const char kContextStr[]; |
73 // kClientToServerStr follows kContextStr to specify that the ChannelID is | 73 // kClientToServerStr follows kContextStr to specify that the ChannelID is |
74 // being used in the client to server direction. (The terminating NUL byte is | 74 // being used in the client to server direction. (The terminating NUL byte is |
75 // included.) | 75 // included.) |
76 static const char kClientToServerStr[]; | 76 static const char kClientToServerStr[]; |
77 | 77 |
(...skipping 12 matching lines...) Expand all Loading... |
90 base::StringPiece signature, | 90 base::StringPiece signature, |
91 bool is_channel_id_signature); | 91 bool is_channel_id_signature); |
92 | 92 |
93 private: | 93 private: |
94 DISALLOW_COPY_AND_ASSIGN(ChannelIDVerifier); | 94 DISALLOW_COPY_AND_ASSIGN(ChannelIDVerifier); |
95 }; | 95 }; |
96 | 96 |
97 } // namespace net | 97 } // namespace net |
98 | 98 |
99 #endif // NET_QUIC_CORE_CRYPTO_CHANNEL_ID_H_ | 99 #endif // NET_QUIC_CORE_CRYPTO_CHANNEL_ID_H_ |
OLD | NEW |