| 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" | |
| 13 #include "net/quic/core/quic_types.h" | 12 #include "net/quic/core/quic_types.h" |
| 14 #include "net/quic/platform/api/quic_export.h" | 13 #include "net/quic/platform/api/quic_export.h" |
| 14 #include "net/quic/platform/api/quic_string_piece.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 QUIC_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(QuicStringPiece 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: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 78 // Verify returns true iff |signature| is a valid signature of |signed_data| | 78 // Verify returns true iff |signature| is a valid signature of |signed_data| |
| 79 // by |key|. | 79 // by |key|. |
| 80 static bool Verify(base::StringPiece key, | 80 static bool Verify(QuicStringPiece key, |
| 81 base::StringPiece signed_data, | 81 QuicStringPiece signed_data, |
| 82 base::StringPiece signature); | 82 QuicStringPiece signature); |
| 83 | 83 |
| 84 // FOR TESTING ONLY: VerifyRaw returns true iff |signature| is a valid | 84 // FOR TESTING ONLY: VerifyRaw returns true iff |signature| is a valid |
| 85 // signature of |signed_data| by |key|. |is_channel_id_signature| indicates | 85 // signature of |signed_data| by |key|. |is_channel_id_signature| indicates |
| 86 // whether |signature| is a ChannelID signature (with kContextStr prepended | 86 // whether |signature| is a ChannelID signature (with kContextStr prepended |
| 87 // to the data to be signed). | 87 // to the data to be signed). |
| 88 static bool VerifyRaw(base::StringPiece key, | 88 static bool VerifyRaw(QuicStringPiece key, |
| 89 base::StringPiece signed_data, | 89 QuicStringPiece signed_data, |
| 90 base::StringPiece signature, | 90 QuicStringPiece 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 |