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_stream.h"
7 #include "crypto/hkdf.h"
8 #include "net/quic/crypto/crypto_handshake_message.h"
9 #include "net/quic/crypto/quic_decrypter.h"
10 #include "net/quic/crypto/quic_encrypter.h"
11 #include "net/quic/quic_session.h"
15 QuicP2PCryptoStream::QuicP2PCryptoStream(QuicSession
* session
,
16 const QuicP2PCryptoConfig
& config
)
17 : QuicCryptoStream(session
), config_(config
) {}
19 QuicP2PCryptoStream::~QuicP2PCryptoStream() {}
21 bool QuicP2PCryptoStream::Connect() {
22 QuicCryptoNegotiatedParameters crypto_params
;
23 if (!config_
.GetNegotiatedParameters(session()->connection()->perspective(),
28 CrypterPair
* crypters
= &crypto_params
.forward_secure_crypters
;
30 session()->connection()->SetEncrypter(ENCRYPTION_FORWARD_SECURE
,
31 crypters
->encrypter
.release());
32 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE
);
33 session()->connection()->SetAlternativeDecrypter(
34 ENCRYPTION_FORWARD_SECURE
, crypters
->decrypter
.release(),
35 false /* don't latch */);
36 encryption_established_
= true;
37 session()->OnCryptoHandshakeEvent(QuicSession::ENCRYPTION_FIRST_ESTABLISHED
);
38 session()->OnConfigNegotiated();
39 session()->connection()->OnHandshakeComplete();
40 handshake_confirmed_
= true;
41 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED
);