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

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

Issue 15074007: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for windows Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/crypto/crypto_server_config.cc ('k') | net/quic/crypto/crypto_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // Some helpers for quic crypto 5 // Some helpers for quic crypto
6 6
7 #ifndef NET_QUIC_CRYPTO_CRYPTO_UTILS_H_ 7 #ifndef NET_QUIC_CRYPTO_CRYPTO_UTILS_H_
8 #define NET_QUIC_CRYPTO_CRYPTO_UTILS_H_ 8 #define NET_QUIC_CRYPTO_CRYPTO_UTILS_H_
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
14 #include "net/quic/crypto/crypto_handshake.h" 14 #include "net/quic/crypto/crypto_handshake.h"
15 #include "net/quic/crypto/crypto_protocol.h" 15 #include "net/quic/crypto/crypto_protocol.h"
16 #include "net/quic/quic_time.h" 16 #include "net/quic/quic_time.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 class QuicTime; 20 class QuicTime;
21 class QuicRandom; 21 class QuicRandom;
22 struct QuicCryptoNegotiatedParameters; 22 struct QuicCryptoNegotiatedParameters;
23 23
24 class NET_EXPORT_PRIVATE CryptoUtils { 24 class NET_EXPORT_PRIVATE CryptoUtils {
25 public: 25 public:
26 enum Priority {
27 LOCAL_PRIORITY,
28 PEER_PRIORITY,
29 };
30
31 enum Perspective { 26 enum Perspective {
32 SERVER, 27 SERVER,
33 CLIENT, 28 CLIENT,
34 }; 29 };
35 30
36 // FindMutualTag sets |out_result| to the first tag in the priority list that
37 // is also in the other list and returns true. If there is no intersection it
38 // returns false.
39 //
40 // Which list has priority is determined by |priority|.
41 //
42 // If |out_index| is non-NULL and a match is found then the index of that
43 // match in |their_tags| is written to |out_index|.
44 static bool FindMutualTag(const QuicTagVector& our_tags,
45 const QuicTag* their_tags,
46 size_t num_their_tags,
47 Priority priority,
48 QuicTag* out_result,
49 size_t* out_index);
50
51 // Generates the connection nonce. The nonce is formed as: 31 // Generates the connection nonce. The nonce is formed as:
52 // <4 bytes> current time 32 // <4 bytes> current time
53 // <8 bytes> |orbit| (or random if |orbit| is empty) 33 // <8 bytes> |orbit| (or random if |orbit| is empty)
54 // <20 bytes> random 34 // <20 bytes> random
55 static void GenerateNonce(QuicWallTime now, 35 static void GenerateNonce(QuicWallTime now,
56 QuicRandom* random_generator, 36 QuicRandom* random_generator,
57 base::StringPiece orbit, 37 base::StringPiece orbit,
58 std::string* nonce); 38 std::string* nonce);
59 39
60 // DeriveKeys populates |out->encrypter| and |out->decrypter| given the 40 // DeriveKeys populates |out->encrypter| and |out->decrypter| given the
61 // contents of |premaster_secret|, |client_nonce|, |server_nonce| and 41 // contents of |premaster_secret|, |client_nonce|, |server_nonce| and
62 // |hkdf_input|. |aead| determines which cipher will be used. |perspective| 42 // |hkdf_input|. |aead| determines which cipher will be used. |perspective|
63 // controls whether the server's keys are assigned to |encrypter| or 43 // controls whether the server's keys are assigned to |encrypter| or
64 // |decrypter|. |server_nonce| is optional and, if non-empty, is mixed into 44 // |decrypter|. |server_nonce| is optional and, if non-empty, is mixed into
65 // the key derivation. 45 // the key derivation.
66 static void DeriveKeys(base::StringPiece premaster_secret, 46 static void DeriveKeys(base::StringPiece premaster_secret,
67 QuicTag aead, 47 QuicTag aead,
68 base::StringPiece client_nonce, 48 base::StringPiece client_nonce,
69 base::StringPiece server_nonce, 49 base::StringPiece server_nonce,
70 const std::string& hkdf_input, 50 const std::string& hkdf_input,
71 Perspective perspective, 51 Perspective perspective,
72 CrypterPair* out); 52 CrypterPair* out);
73 }; 53 };
74 54
75 } // namespace net 55 } // namespace net
76 56
77 #endif // NET_QUIC_CRYPTO_CRYPTO_UTILS_H_ 57 #endif // NET_QUIC_CRYPTO_CRYPTO_UTILS_H_
OLDNEW
« no previous file with comments | « net/quic/crypto/crypto_server_config.cc ('k') | net/quic/crypto/crypto_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698