| 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/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 11 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 | 15 |
| 15 // ChannelIDSigner is an abstract interface that implements signing by | 16 // ChannelIDKey is an interface that supports signing with and serializing a |
| 16 // ChannelID keys. | 17 // ChannelID key. |
| 17 class NET_EXPORT_PRIVATE ChannelIDSigner { | 18 class NET_EXPORT_PRIVATE ChannelIDKey { |
| 18 public: | 19 public: |
| 19 virtual ~ChannelIDSigner() { } | 20 virtual ~ChannelIDKey() { } |
| 20 | 21 |
| 21 // Sign signs |signed_data| using the ChannelID key for |hostname| and puts | 22 // Sign signs |signed_data| using the ChannelID private key and puts the |
| 22 // the serialized public key into |out_key| and the signature into | 23 // signature into |out_signature|. It returns true on success. |
| 23 // |out_signature|. It returns true on success. | 24 virtual bool Sign(base::StringPiece signed_data, |
| 24 virtual bool Sign(const std::string& hostname, | |
| 25 base::StringPiece signed_data, | |
| 26 std::string* out_key, | |
| 27 std::string* out_signature) = 0; | 25 std::string* out_signature) = 0; |
| 28 | 26 |
| 29 // GetKeyForHostname returns the ChannelID key that |ChannelIDSigner| will use | 27 // SerializeKey returns the serialized ChannelID public key. |
| 30 // for the given hostname. | 28 virtual std::string SerializeKey() = 0; |
| 31 virtual std::string GetKeyForHostname(const std::string& hostname) = 0; | 29 }; |
| 30 |
| 31 // ChannelIDSource is an abstract interface by which a QUIC client can obtain |
| 32 // a ChannelIDKey for a given hostname. |
| 33 class NET_EXPORT_PRIVATE ChannelIDSource { |
| 34 public: |
| 35 virtual ~ChannelIDSource() {} |
| 36 |
| 37 // GetChannelIDKey looks up the ChannelIDKey for |hostname|. On success it |
| 38 // returns true and stores the ChannelIDKey in |*channel_id|. |
| 39 virtual bool GetChannelIDKey(const std::string& hostname, |
| 40 scoped_ptr<ChannelIDKey>* channel_id_key) = 0; |
| 32 }; | 41 }; |
| 33 | 42 |
| 34 // ChannelIDVerifier verifies ChannelID signatures. | 43 // ChannelIDVerifier verifies ChannelID signatures. |
| 35 class NET_EXPORT_PRIVATE ChannelIDVerifier { | 44 class NET_EXPORT_PRIVATE ChannelIDVerifier { |
| 36 public: | 45 public: |
| 37 // kContextStr is prepended to the data to be signed in order to ensure that | 46 // kContextStr is prepended to the data to be signed in order to ensure that |
| 38 // a ChannelID signature cannot be used in a different context. (The | 47 // a ChannelID signature cannot be used in a different context. (The |
| 39 // terminating NUL byte is inclued.) | 48 // terminating NUL byte is inclued.) |
| 40 static const char kContextStr[]; | 49 static const char kContextStr[]; |
| 41 // kClientToServerStr follows kContextStr to specify that the ChannelID is | 50 // kClientToServerStr follows kContextStr to specify that the ChannelID is |
| (...skipping 16 matching lines...) Expand all Loading... |
| 58 base::StringPiece signature, | 67 base::StringPiece signature, |
| 59 bool is_channel_id_signature); | 68 bool is_channel_id_signature); |
| 60 | 69 |
| 61 private: | 70 private: |
| 62 DISALLOW_COPY_AND_ASSIGN(ChannelIDVerifier); | 71 DISALLOW_COPY_AND_ASSIGN(ChannelIDVerifier); |
| 63 }; | 72 }; |
| 64 | 73 |
| 65 } // namespace net | 74 } // namespace net |
| 66 | 75 |
| 67 #endif // NET_QUIC_CRYPTO_CHANNEL_ID_H_ | 76 #endif // NET_QUIC_CRYPTO_CHANNEL_ID_H_ |
| OLD | NEW |