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
3 // found in the LICENSE file.
5 #ifndef NET_QUIC_CRYPTO_CRYPTO_HANDSHAKE_H_
6 #define NET_QUIC_CRYPTO_CRYPTO_HANDSHAKE_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/net_export.h"
13 #include "net/quic/quic_protocol.h"
22 // A CrypterPair contains the encrypter and decrypter for an encryption level.
23 struct NET_EXPORT_PRIVATE CrypterPair
{
26 scoped_ptr
<QuicEncrypter
> encrypter
;
27 scoped_ptr
<QuicDecrypter
> decrypter
;
30 // Parameters negotiated by the crypto handshake.
31 struct NET_EXPORT_PRIVATE QuicCryptoNegotiatedParameters
{
32 // Initializes the members to 0 or empty values.
33 QuicCryptoNegotiatedParameters();
34 ~QuicCryptoNegotiatedParameters();
38 std::string initial_premaster_secret
;
39 std::string forward_secure_premaster_secret
;
40 CrypterPair initial_crypters
;
41 CrypterPair forward_secure_crypters
;
42 // Normalized SNI: converted to lower case and trailing '.' removed.
44 std::string client_nonce
;
45 std::string server_nonce
;
46 // hkdf_input_suffix contains the HKDF input following the label: the
47 // ConnectionId, client hello and server config. This is only populated in the
48 // client because only the client needs to derive the forward secure keys at a
49 // later time from the initial keys.
50 std::string hkdf_input_suffix
;
51 // cached_certs contains the cached certificates that a client used when
52 // sending a client hello.
53 std::vector
<std::string
> cached_certs
;
54 // client_key_exchange is used by clients to store the ephemeral KeyExchange
55 // for the connection.
56 scoped_ptr
<KeyExchange
> client_key_exchange
;
57 // channel_id is set by servers to a ChannelID key when the client correctly
58 // proves possession of the corresponding private key. It consists of 32
59 // bytes of x coordinate, followed by 32 bytes of y coordinate. Both values
60 // are big-endian and the pair is a P-256 public key.
61 std::string channel_id
;
64 // QuicCryptoConfig contains common configuration between clients and servers.
65 class NET_EXPORT_PRIVATE QuicCryptoConfig
{
67 // kInitialLabel is a constant that is used when deriving the initial
68 // (non-forward secure) keys for the connection in order to tie the resulting
69 // key to this protocol.
70 static const char kInitialLabel
[];
72 // kCETVLabel is a constant that is used when deriving the keys for the
73 // encrypted tag/value block in the client hello.
74 static const char kCETVLabel
[];
76 // kForwardSecureLabel is a constant that is used when deriving the forward
77 // secure keys for the connection in order to tie the resulting key to this
79 static const char kForwardSecureLabel
[];
84 // Key exchange methods. The following two members' values correspond by
87 // Authenticated encryption with associated data (AEAD) algorithms.
90 const CommonCertSets
* common_cert_sets
;
93 DISALLOW_COPY_AND_ASSIGN(QuicCryptoConfig
);
98 #endif // NET_QUIC_CRYPTO_CRYPTO_HANDSHAKE_H_