Botan  1.10.9
Public Member Functions | List of all members
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

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

Definition at line 15 of file ecdh.cpp.

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

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:202

Member Function Documentation

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.

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

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  }
PointGFp OS2ECP(const byte data[], size_t data_len, const CurveGFp &curve)
Definition: point_gfp.cpp:554
#define BOTAN_ASSERT(expr, msg)
Definition: assert.h:19
const BigInt & get_p() const
Definition: curve_gfp.h:64
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
Definition: big_code.cpp:78
size_t bytes() const
Definition: bigint.cpp:245

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