1 // 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 "quiche/quic/core/crypto/key_exchange.h" 6 7 #include "absl/strings/string_view.h" 8 #include "quiche/quic/core/crypto/curve25519_key_exchange.h" 9 #include "quiche/quic/core/crypto/p256_key_exchange.h" 10 #include "quiche/quic/platform/api/quic_bug_tracker.h" 11 12 namespace quic { 13 CreateLocalSynchronousKeyExchange(QuicTag type,absl::string_view private_key)14std::unique_ptr<SynchronousKeyExchange> CreateLocalSynchronousKeyExchange( 15 QuicTag type, absl::string_view private_key) { 16 switch (type) { 17 case kC255: 18 return Curve25519KeyExchange::New(private_key); 19 case kP256: 20 return P256KeyExchange::New(private_key); 21 default: 22 QUIC_BUG(quic_bug_10712_1) 23 << "Unknown key exchange method: " << QuicTagToString(type); 24 return nullptr; 25 } 26 } 27 CreateLocalSynchronousKeyExchange(QuicTag type,QuicRandom * rand)28std::unique_ptr<SynchronousKeyExchange> CreateLocalSynchronousKeyExchange( 29 QuicTag type, QuicRandom* rand) { 30 switch (type) { 31 case kC255: 32 return Curve25519KeyExchange::New(rand); 33 case kP256: 34 return P256KeyExchange::New(); 35 default: 36 QUIC_BUG(quic_bug_10712_2) 37 << "Unknown key exchange method: " << QuicTagToString(type); 38 return nullptr; 39 } 40 } 41 42 } // namespace quic 43