Botan 1.10.17
Botan::ECDH_KA_Operation Class Reference

#include <ecdh.h>

Inheritance diagram for Botan::ECDH_KA_Operation:
Botan::PK_Ops::Key_Agreement

Public Member Functions

SecureVector< byteagree (const byte w[], size_t w_len)
 ECDH_KA_Operation (const ECDH_PrivateKey &key)

Detailed Description

ECDH operation

Definition at line 93 of file ecdh.h.

Constructor & Destructor Documentation

◆ ECDH_KA_Operation()

Botan::ECDH_KA_Operation::ECDH_KA_Operation ( const ECDH_PrivateKey & key)

Definition at line 15 of file ecdh.cpp.

15 :
16 curve(key.domain().get_curve()),
17 cofactor(key.domain().get_cofactor())
18 {
19 l_times_priv = inverse_mod(cofactor, key.domain().get_order()) *
20 key.private_value();
21 }
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition numthry.cpp:314

References Botan::EC_PublicKey::domain(), Botan::EC_Group::get_order(), Botan::inverse_mod(), and Botan::EC_PrivateKey::private_value().

Referenced by Botan::Core_Engine::get_key_agreement_op().

Member Function Documentation

◆ agree()

SecureVector< byte > Botan::ECDH_KA_Operation::agree ( const byte w[],
size_t w_len )
virtual

Implements Botan::PK_Ops::Key_Agreement.

Definition at line 23 of file ecdh.cpp.

24 {
25 PointGFp point = OS2ECP(w, w_len, curve);
26
27 PointGFp S = (cofactor * point) * l_times_priv;
28
29 BOTAN_ASSERT(S.on_the_curve(),
30 "ECDH agreed value not on the curve");
31
32 return BigInt::encode_1363(S.get_affine_x(),
33 curve.get_p().bytes());
34 }
#define BOTAN_ASSERT(expr, msg)
Definition assert.h:19
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
Definition big_code.cpp:78
PointGFp OS2ECP(const byte data[], size_t data_len, const CurveGFp &curve)

References BOTAN_ASSERT, Botan::BigInt::bytes(), Botan::BigInt::encode_1363(), Botan::PointGFp::get_affine_x(), Botan::PointGFp::on_the_curve(), and Botan::OS2ECP().


The documentation for this class was generated from the following files: