Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: net/quic/crypto/channel_id.h

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/crypto/chacha20_poly1305_encrypter_test.cc ('k') | net/quic/crypto/channel_id.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_QUIC_CRYPTO_CHANNEL_ID_H_
6 #define NET_QUIC_CRYPTO_CHANNEL_ID_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "base/strings/string_piece.h"
13 #include "net/base/net_export.h"
14 #include "net/quic/quic_types.h"
15
16 namespace net {
17
18 // ChannelIDKey is an interface that supports signing with and serializing a
19 // ChannelID key.
20 class NET_EXPORT_PRIVATE ChannelIDKey {
21 public:
22 virtual ~ChannelIDKey() {}
23
24 // Sign signs |signed_data| using the ChannelID private key and puts the
25 // signature into |out_signature|. It returns true on success.
26 virtual bool Sign(base::StringPiece signed_data,
27 std::string* out_signature) const = 0;
28
29 // SerializeKey returns the serialized ChannelID public key.
30 virtual std::string SerializeKey() const = 0;
31 };
32
33 // ChannelIDSourceCallback provides a generic mechanism for a ChannelIDSource
34 // to call back after an asynchronous GetChannelIDKey operation.
35 class ChannelIDSourceCallback {
36 public:
37 virtual ~ChannelIDSourceCallback() {}
38
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
41 // then the channel ID lookup is successful. |Run| may take ownership of
42 // |*channel_id_key| by calling |release| on it.
43 virtual void Run(std::unique_ptr<ChannelIDKey>* channel_id_key) = 0;
44 };
45
46 // ChannelIDSource is an abstract interface by which a QUIC client can obtain
47 // a ChannelIDKey for a given hostname.
48 class NET_EXPORT_PRIVATE ChannelIDSource {
49 public:
50 virtual ~ChannelIDSource() {}
51
52 // GetChannelIDKey looks up the ChannelIDKey for |hostname|. On success it
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.
55 //
56 // This function may also return QUIC_PENDING, in which case the
57 // ChannelIDSource will call back, on the original thread, via |callback|
58 // when complete. In this case, the ChannelIDSource will take ownership of
59 // |callback|.
60 virtual QuicAsyncStatus GetChannelIDKey(
61 const std::string& hostname,
62 std::unique_ptr<ChannelIDKey>* channel_id_key,
63 ChannelIDSourceCallback* callback) = 0;
64 };
65
66 // ChannelIDVerifier verifies ChannelID signatures.
67 class NET_EXPORT_PRIVATE ChannelIDVerifier {
68 public:
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
71 // terminating NUL byte is inclued.)
72 static const char kContextStr[];
73 // kClientToServerStr follows kContextStr to specify that the ChannelID is
74 // being used in the client to server direction. (The terminating NUL byte is
75 // included.)
76 static const char kClientToServerStr[];
77
78 // Verify returns true iff |signature| is a valid signature of |signed_data|
79 // by |key|.
80 static bool Verify(base::StringPiece key,
81 base::StringPiece signed_data,
82 base::StringPiece signature);
83
84 // FOR TESTING ONLY: VerifyRaw returns true iff |signature| is a valid
85 // signature of |signed_data| by |key|. |is_channel_id_signature| indicates
86 // whether |signature| is a ChannelID signature (with kContextStr prepended
87 // to the data to be signed).
88 static bool VerifyRaw(base::StringPiece key,
89 base::StringPiece signed_data,
90 base::StringPiece signature,
91 bool is_channel_id_signature);
92
93 private:
94 DISALLOW_COPY_AND_ASSIGN(ChannelIDVerifier);
95 };
96
97 } // namespace net
98
99 #endif // NET_QUIC_CRYPTO_CHANNEL_ID_H_
OLDNEW
« no previous file with comments | « net/quic/crypto/chacha20_poly1305_encrypter_test.cc ('k') | net/quic/crypto/channel_id.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698