10 #include <botan/ecdh.h>
11 #include <botan/numthry.h>
12 #include <botan/internal/pk_ops_impl.h>
14 #if defined(BOTAN_HAS_OPENSSL)
15 #include <botan/internal/openssl.h>
25 class ECDH_KA_Operation
final :
public PK_Ops::Key_Agreement_with_KDF
29 ECDH_KA_Operation(
const ECDH_PrivateKey& key,
const std::string& kdf, RandomNumberGenerator& rng) :
30 PK_Ops::Key_Agreement_with_KDF(kdf),
37 size_t agreed_value_size()
const override {
return m_group.get_p_bytes(); }
39 secure_vector<uint8_t> raw_agree(
const uint8_t w[],
size_t w_len)
override
41 PointGFp input_point =
m_group.get_cofactor() *
m_group.OS2ECP(w, w_len);
42 input_point.randomize_repr(
m_rng);
44 const PointGFp S =
m_group.blinded_var_point_multiply(
47 if(S.on_the_curve() ==
false)
60 std::unique_ptr<PK_Ops::Key_Agreement>
62 const std::string& params,
63 const std::string& provider)
const
65 #if defined(BOTAN_HAS_OPENSSL)
66 if(provider ==
"openssl" || provider.empty())
70 return make_openssl_ecdh_ka_op(*
this, params);
74 if(provider ==
"openssl")
80 if(provider ==
"base" || provider.empty())
81 return std::unique_ptr<PK_Ops::Key_Agreement>(
new ECDH_KA_Operation(*
this, params, rng));
int(* final)(unsigned char *, CTX *)
std::unique_ptr< PK_Ops::Key_Agreement > create_key_agreement_op(RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const override
std::vector< BigInt > m_ws
std::string algo_name() const override
RandomNumberGenerator & m_rng
static secure_vector< uint8_t > encode_1363(const BigInt &n, size_t bytes)