blob: 1969e75a31ff1f37e4ad5f1136685225c6ca03f9 [file] [log] [blame]
QUICHE teamfe1aca62019-03-14 13:39:01 -07001// Copyright (c) 2019 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.
4
5#include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h"
6#include "net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h"
7#include "net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h"
8#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
9
10namespace quic {
11
12std::unique_ptr<SynchronousKeyExchange> CreateLocalSynchronousKeyExchange(
13 QuicTag type,
14 QuicStringPiece private_key) {
15 switch (type) {
16 case kC255:
17 return Curve25519KeyExchange::New(private_key);
18 case kP256:
19 return P256KeyExchange::New(private_key);
20 default:
21 QUIC_BUG << "Unknown key exchange method: " << QuicTagToString(type);
22 return nullptr;
23 }
24}
25
26std::unique_ptr<SynchronousKeyExchange> CreateLocalSynchronousKeyExchange(
27 QuicTag type,
28 QuicRandom* rand) {
29 switch (type) {
30 case kC255:
31 return Curve25519KeyExchange::New(rand);
32 break;
33 case kP256:
34 return P256KeyExchange::New();
35 break;
36 default:
37 QUIC_BUG << "Unknown key exchange method: " << QuicTagToString(type);
38 return nullptr;
39 }
40}
41
42} // namespace quic