proxygen
OpenSSLKeyExchange.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #pragma once
10 
15 
16 namespace fizz {
17 
24 template <class T>
26  public:
27  ~OpenSSLKeyExchange() override = default;
28 
29  void generateKeyPair() override {
30  keyExchange_.generateKeyPair();
31  }
32 
33  std::unique_ptr<folly::IOBuf> getKeyShare() const override {
34  const auto& key = keyExchange_.getKey();
35  if (!key) {
36  throw std::runtime_error("Key not initialized");
37  }
39  }
40 
41  std::unique_ptr<folly::IOBuf> generateSharedSecret(
42  folly::ByteRange keyShare) const override {
43  auto key = detail::OpenSSLECKeyDecoder<T>::decode(keyShare);
44  return keyExchange_.generateSharedSecret(key);
45  }
46 
47  private:
49 };
50 } // namespace fizz
void generateKeyPair() override
~OpenSSLKeyExchange() override=default
static folly::ssl::EvpPkeyUniquePtr decode(folly::ByteRange range)
Definition: Actions.h:16
static std::unique_ptr< folly::IOBuf > encode(const folly::ssl::EvpPkeyUniquePtr &key)
std::unique_ptr< folly::IOBuf > generateSharedSecret(folly::ByteRange keyShare) const override
std::unique_ptr< folly::IOBuf > getKeyShare() const override
detail::OpenSSLECKeyExchange< T > keyExchange_