9 #include <gtest/gtest.h> 15 using namespace folly;
28 class ECDSATest :
public ::testing::TestWithParam<Params> {
30 OpenSSL_add_all_algorithms();
43 EC_KEY_set_public_key_affine_coordinates(key.get(), numX.get(), numY.get());
49 BN_bin2bn((
uint8_t*)privKeyBin.c_str(), privKeyBin.size(),
nullptr));
51 EC_KEY_set_private_key(privateKey.get(), privateBn.get());
54 EVP_PKEY_set1_EC_KEY(pkeyPrivateKey.get(), privateKey.get());
55 return pkeyPrivateKey;
74 auto& msgPtr = msg[2];
83 auto key =
getKey(P256::curveNid, GetParam());
88 auto sig = ecdsa.
sign<SignatureScheme::ecdsa_secp256r1_sha256>(
90 ecdsa.
verify<SignatureScheme::ecdsa_secp256r1_sha256>(
95 auto sig = ecdsa.
sign<SignatureScheme::ecdsa_secp256r1_sha256>(
99 ecdsa.
verify<SignatureScheme::ecdsa_secp256r1_sha256>(
105 auto sig = ecdsa.
sign<SignatureScheme::ecdsa_secp256r1_sha256>(
109 ecdsa.
verify<SignatureScheme::ecdsa_secp256r1_sha256>(
116 auto key =
getKey(P384::curveNid, GetParam());
121 auto sig = ecdsa.
sign<SignatureScheme::ecdsa_secp384r1_sha384>(
123 ecdsa.
verify<SignatureScheme::ecdsa_secp384r1_sha384>(
128 auto sig = ecdsa.
sign<SignatureScheme::ecdsa_secp384r1_sha384>(
132 ecdsa.
verify<SignatureScheme::ecdsa_secp384r1_sha384>(
138 auto sig = ecdsa.
sign<SignatureScheme::ecdsa_secp384r1_sha384>(
142 ecdsa.
verify<SignatureScheme::ecdsa_secp384r1_sha384>(
149 auto key =
getKey(P521::curveNid, GetParam());
154 auto sig = ecdsa.
sign<SignatureScheme::ecdsa_secp521r1_sha512>(
156 ecdsa.
verify<SignatureScheme::ecdsa_secp521r1_sha512>(
161 auto sig = ecdsa.
sign<SignatureScheme::ecdsa_secp521r1_sha512>(
165 ecdsa.
verify<SignatureScheme::ecdsa_secp521r1_sha512>(
171 auto sig = ecdsa.
sign<SignatureScheme::ecdsa_secp521r1_sha512>(
175 ecdsa.
verify<SignatureScheme::ecdsa_secp521r1_sha512>(
189 "C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721",
190 "60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6",
191 "7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299"}));
197 "6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D8" 198 "96D5724E4C70A825F872C9EA60D2EDF5",
199 "EC3A4E415B4E19A4568618029F427FA5DA9A8BC4AE92E02E06AAE5286B300C64" 200 "DEF8F0EA9055866064A254515480BC13",
201 "8015D9B72D7D57244EA8EF9AC0C621896708A59367F9DFB9F54CA84B3F1C9DB1" 202 "288B231C3AE0D4FE7344FD2533264720"}));
209 "00FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75C" 210 "AA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83" 212 "01894550D0785932E00EAA23B694F213F8C3121F86DC97A04E5A7167DB4E5BCD3" 213 "71123D46E45DB6B5D5370A7F20FB633155D38FFA16D2BD761DCAC474B9A2F502" 215 "00493101C962CD4D2FDDF782285E64584139C2F91B47F87FF82354D6630F746A2" 216 "8A0DB25741B5B34A828008B22ACC23F924FAAFBD4D33F81EA66956DFEAA2BFDF"
bool unhexlify(const InputString &input, OutputString &output)
void setPoint(EcKeyUniquePtr &key, std::string x, std::string y)
#define EXPECT_THROW(statement, expected_exception)
constexpr detail::Map< Move > move
std::unique_ptr< folly::IOBuf > sign(folly::ByteRange data) const
std::unique_ptr< EVP_PKEY, EvpPkeyDeleter > EvpPkeyUniquePtr
—— Concurrent Priority Queue Implementation ——
std::unique_ptr< BIGNUM, BIGNUMDeleter > BIGNUMUniquePtr
std::unique_ptr< EC_KEY, EcKeyDeleter > EcKeyUniquePtr
void verify(folly::ByteRange data, folly::ByteRange signature) const
constexpr detail::Sig< Sig > const sig
INSTANTIATE_TEST_CASE_P(TestVectors, ECDSA521Test,::testing::Values(Params{"sample","00FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75C""AA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83""538","01894550D0785932E00EAA23B694F213F8C3121F86DC97A04E5A7167DB4E5BCD3""71123D46E45DB6B5D5370A7F20FB633155D38FFA16D2BD761DCAC474B9A2F502""3A4","00493101C962CD4D2FDDF782285E64584139C2F91B47F87FF82354D6630F746A2""8A0DB25741B5B34A828008B22ACC23F924FAAFBD4D33F81EA66956DFEAA2BFDF""CF5"}))
void modifySig(folly::IOBuf *sig)
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
void setKey(folly::ssl::EvpPkeyUniquePtr pkey)
TEST_P(ECDSA521Test, TestSignature)
void modifyData(folly::IOBuf *sig, std::string &msg)