Botan: Botan::ECDH_KA_Operation Class Reference

Botan 1.10.17

Public Member Functions | List of all members
Botan::ECDH_KA_Operation Class Reference

`#include <ecdh.h>`

Inheritance diagram for Botan::ECDH_KA_Operation:

## Public Member Functions
SecureVector< byte > | agree (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.

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 }
Botan::inverse_mod
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition: numthry.cpp:314

## 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.

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

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

- src/pubkey/ecdh/ecdh.h
- src/pubkey/ecdh/ecdh.cpp