Botan 1.10.17
Botan::DH_KA_Operation Class Reference

#include <dh.h>

Inheritance diagram for Botan::DH_KA_Operation:
Botan::PK_Ops::Key_Agreement

Public Member Functions

SecureVector< byteagree (const byte w[], size_t w_len)
 DH_KA_Operation (const DH_PrivateKey &key)

Detailed Description

DH operation

Definition at line 78 of file dh.h.

Constructor & Destructor Documentation

◆ DH_KA_Operation()

Botan::DH_KA_Operation::DH_KA_Operation ( const DH_PrivateKey & key)

Definition at line 79 of file dh.cpp.

79 :
80 p(dh.group_p()), powermod_x_p(dh.get_x(), p)
81 {
82 BigInt k(global_state().global_rng(), p.bits() - 1);
83 blinder = Blinder(k, powermod_x_p(inverse_mod(k, p)), p);
84 }
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition numthry.cpp:314
Library_State & global_state()

References Botan::Blinder::Blinder(), Botan::global_state(), and Botan::inverse_mod().

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

Member Function Documentation

◆ agree()

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

Implements Botan::PK_Ops::Key_Agreement.

Definition at line 86 of file dh.cpp.

87 {
88 BigInt input = BigInt::decode(w, w_len);
89
90 if(input <= 1 || input >= p - 1)
91 throw Invalid_Argument("DH agreement - invalid key provided");
92
93 BigInt r = blinder.unblind(powermod_x_p(blinder.blind(input)));
94
95 return BigInt::encode_1363(r, p.bytes());
96 }
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
Definition big_code.cpp:78
static BigInt decode(const byte buf[], size_t length, Base base=Binary)
Definition big_code.cpp:102
std::invalid_argument Invalid_Argument
Definition exceptn.h:20

References Botan::BigInt::bytes(), Botan::BigInt::decode(), and Botan::BigInt::encode_1363().


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