proxygen
OpenSSLKeyUtilsTest.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 
13 
14 #include <folly/String.h>
15 
16 using namespace folly;
17 using namespace folly::ssl;
18 
19 namespace fizz {
20 namespace test {
21 
22 TEST(ValidateECKey, GoodPrivateKey) {
23  auto key = getPrivateKey(kP256Key);
24  detail::validateECKey(key, NID_X9_62_prime256v1);
25 }
26 
27 TEST(ValidateECKey, GoodPubicKey) {
28  auto key = getPublicKey(kP256PublicKey);
29  detail::validateECKey(key, NID_X9_62_prime256v1);
30 }
31 
32 TEST(ValidateECKey, WrongKeyType) {
33  auto key = getPrivateKey(kRSAKey);
35  detail::validateECKey(key, NID_X9_62_prime256v1), std::runtime_error);
36 }
37 
38 TEST(ValidateECKey, WrongCurve) {
39  auto key = getPrivateKey(kP256Key);
41  detail::validateECKey(key, NID_X9_62_prime239v3), std::runtime_error);
42 }
43 } // namespace test
44 } // namespace fizz
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
constexpr folly::StringPiece kP256Key
Definition: TestUtil.h:18
constexpr folly::StringPiece kP256PublicKey
Definition: TestUtil.h:26
EvpPkeyUniquePtr getPrivateKey(StringPiece key)
Definition: TestUtil.cpp:21
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
void validateECKey(const folly::ssl::EvpPkeyUniquePtr &key, int curveNid)
Definition: Actions.h:16
constexpr folly::StringPiece kRSAKey
Definition: TestUtil.h:129
EvpPkeyUniquePtr getPublicKey(StringPiece key)
Definition: TestUtil.cpp:31
TEST(SequencedExecutor, CPUThreadPoolExecutor)