Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / net / quic / p2p / quic_p2p_crypto_config.cc
blobd30d3c86b39e757451d0382ff711cd731e854967
1 // Copyright 2015 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 #include "net/quic/p2p/quic_p2p_crypto_config.h"
7 #include "net/quic/crypto/crypto_handshake.h"
8 #include "net/quic/crypto/crypto_utils.h"
10 namespace net {
12 QuicP2PCryptoConfig::QuicP2PCryptoConfig(const std::string& shared_key)
13 : shared_key_(shared_key) {}
15 QuicP2PCryptoConfig::~QuicP2PCryptoConfig() {}
17 bool QuicP2PCryptoConfig::GetNegotiatedParameters(
18 Perspective perspective,
19 QuicCryptoNegotiatedParameters* out_params) {
20 out_params->forward_secure_premaster_secret = shared_key_;
21 out_params->aead = aead_;
22 out_params->hkdf_input_suffix = hkdf_input_suffix_;
24 std::string hkdf_input;
25 const size_t label_len = strlen(QuicCryptoConfig::kForwardSecureLabel) + 1;
26 hkdf_input.reserve(label_len + out_params->hkdf_input_suffix.size());
27 hkdf_input.append(QuicCryptoConfig::kForwardSecureLabel, label_len);
28 hkdf_input.append(out_params->hkdf_input_suffix);
30 if (!CryptoUtils::DeriveKeys(
31 out_params->forward_secure_premaster_secret, out_params->aead,
32 out_params->client_nonce, out_params->server_nonce, hkdf_input,
33 perspective, &out_params->forward_secure_crypters,
34 &out_params->subkey_secret)) {
35 return false;
38 return true;
41 } // namespace net