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