proxygen
X25519KeyExchangeTest.cpp
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 #include <gtest/gtest.h>
10 
12 #include <folly/Range.h>
13 #include <folly/String.h>
14 
15 using namespace folly;
16 
17 namespace fizz {
18 namespace test {
19 
21  static constexpr StringPiece keyShareHex =
22  "c81e57c7485ba417280bc2d48d864afd3966ff77b684bfaf85f418f9b4583347";
23  auto keyShare = unhexlify(keyShareHex);
25  kex.generateKeyPair();
26  auto out = kex.generateSharedSecret(folly::range(keyShare));
27 }
28 
29 TEST(X25519KeyExchange, SmallKeyExchange) {
30  static constexpr StringPiece keyShareHex = "c81e57c7485ba4";
31  auto keyShare = unhexlify(keyShareHex);
33  kex.generateKeyPair();
35  kex.generateSharedSecret(folly::range(keyShare)), std::runtime_error);
36 }
37 } // namespace test
38 } // namespace fizz
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
void generateKeyPair() override
Definition: X25519.cpp:20
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
constexpr Range< Iter > range(Iter first, Iter last)
Definition: Range.h:1114
Definition: Actions.h:16
std::unique_ptr< folly::IOBuf > generateSharedSecret(folly::ByteRange keyShare) const override
Definition: X25519.cpp:39
TEST(SequencedExecutor, CPUThreadPoolExecutor)