10 #include <botan/ecdh.h>
11 #include <botan/internal/pk_ops_impl.h>
13 #if defined(BOTAN_HAS_OPENSSL)
14 #include <botan/internal/openssl.h>
24 class ECDH_KA_Operation :
public PK_Ops::Key_Agreement_with_KDF
28 ECDH_KA_Operation(
const ECDH_PrivateKey& key,
const std::string& kdf, RandomNumberGenerator& rng) :
29 PK_Ops::Key_Agreement_with_KDF(kdf),
30 m_curve(key.domain().get_curve()),
32 m_order(key.domain().get_order()),
38 secure_vector<uint8_t> raw_agree(
const uint8_t w[],
size_t w_len)
override
42 Blinded_Point_Multiply blinder(S,
m_order);
44 BOTAN_ASSERT(S.on_the_curve(),
"ECDH agreed value was on the curve");
58 std::unique_ptr<PK_Ops::Key_Agreement>
60 const std::string& params,
61 const std::string& provider)
const
63 #if defined(BOTAN_HAS_OPENSSL)
64 if(provider ==
"openssl" || provider.empty())
68 return make_openssl_ecdh_ka_op(*
this, params);
72 if(provider ==
"openssl")
78 if(provider ==
"base" || provider.empty())
79 return std::unique_ptr<PK_Ops::Key_Agreement>(
new ECDH_KA_Operation(*
this, params, rng));
const BigInt & m_cofactor
#define BOTAN_ASSERT(expr, assertion_made)
std::unique_ptr< PK_Ops::Key_Agreement > create_key_agreement_op(RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const override
PointGFp OS2ECP(const uint8_t data[], size_t data_len, const CurveGFp &curve)
std::string algo_name() const override
RandomNumberGenerator & m_rng
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
static secure_vector< uint8_t > encode_1363(const BigInt &n, size_t bytes)