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

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

Issue 423333002: Implement QUIC key extraction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass a size_t constant as a size_t argument. Created 6 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 | Annotate | Revision Log
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>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // (1) disallow IP addresses; 42 // (1) disallow IP addresses;
43 // (2) check that the hostname contains valid characters only; and 43 // (2) check that the hostname contains valid characters only; and
44 // (3) contains at least one dot. 44 // (3) contains at least one dot.
45 static bool IsValidSNI(base::StringPiece sni); 45 static bool IsValidSNI(base::StringPiece sni);
46 46
47 // Convert hostname to lowercase and remove the trailing '.'. 47 // Convert hostname to lowercase and remove the trailing '.'.
48 // Returns |hostname|. NormalizeHostname() doesn't support IP address 48 // Returns |hostname|. NormalizeHostname() doesn't support IP address
49 // literals. IsValidSNI() should be called before calling NormalizeHostname(). 49 // literals. IsValidSNI() should be called before calling NormalizeHostname().
50 static std::string NormalizeHostname(const char* hostname); 50 static std::string NormalizeHostname(const char* hostname);
51 51
52 // DeriveKeys populates |out->encrypter| and |out->decrypter| given the 52 // DeriveKeys populates |crypters->encrypter|, |crypters->decrypter|, and
53 // contents of |premaster_secret|, |client_nonce|, |server_nonce| and 53 // |subkey_secret| (optional -- may be null) given the contents of
54 // |hkdf_input|. |aead| determines which cipher will be used. |perspective| 54 // |premaster_secret|, |client_nonce|, |server_nonce| and |hkdf_input|. |aead|
55 // controls whether the server's keys are assigned to |encrypter| or 55 // determines which cipher will be used. |perspective| controls whether the
56 // |decrypter|. |server_nonce| is optional and, if non-empty, is mixed into 56 // server's keys are assigned to |encrypter| or |decrypter|. |server_nonce| is
57 // the key derivation. 57 // optional and, if non-empty, is mixed into the key derivation.
58 // |subkey_secret| will have the same length as |premaster_secret|.
58 static bool DeriveKeys(base::StringPiece premaster_secret, 59 static bool DeriveKeys(base::StringPiece premaster_secret,
59 QuicTag aead, 60 QuicTag aead,
60 base::StringPiece client_nonce, 61 base::StringPiece client_nonce,
61 base::StringPiece server_nonce, 62 base::StringPiece server_nonce,
62 const std::string& hkdf_input, 63 const std::string& hkdf_input,
63 Perspective perspective, 64 Perspective perspective,
64 CrypterPair* out); 65 CrypterPair* crypters,
66 std::string* subkey_secret);
67
68 // Performs key extraction to derive a new secret of |result_len| bytes
69 // dependent on |subkey_secret|, |label|, and |context|. Returns false if the
70 // parameters are invalid (e.g. |label| contains null bytes); returns true on
71 // success.
72 static bool ExportKeyingMaterial(base::StringPiece subkey_secret,
73 base::StringPiece label,
74 base::StringPiece context,
75 size_t result_len,
76 std::string* result);
65 77
66 private: 78 private:
67 DISALLOW_COPY_AND_ASSIGN(CryptoUtils); 79 DISALLOW_COPY_AND_ASSIGN(CryptoUtils);
68 }; 80 };
69 81
70 } // namespace net 82 } // namespace net
71 83
72 #endif // NET_QUIC_CRYPTO_CRYPTO_UTILS_H_ 84 #endif // NET_QUIC_CRYPTO_CRYPTO_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698