QUICHE team | fe1aca6 | 2019-03-14 13:39:01 -0700 | [diff] [blame] | 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 "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 | |
| 10 | namespace quic { |
| 11 | |
| 12 | std::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 | |
| 26 | std::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 |