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

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

Definition at line 79 of file dh.cpp.

References Botan::BigInt::bits(), Botan::Global_State_Management::global_state(), and Botan::inverse_mod().

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  }
size_t bits() const
Definition: bigint.cpp:253
Library_State & global_state()
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition: numthry.cpp:202

Member Function Documentation

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.

References Botan::Blinder::blind(), Botan::BigInt::bytes(), Botan::BigInt::decode(), Botan::BigInt::encode_1363(), r, and Botan::Blinder::unblind().

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  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
BigInt unblind(const BigInt &x) const
Definition: blinding.cpp:42
BigInt blind(const BigInt &x) const
Definition: blinding.cpp:29
static BigInt decode(const byte buf[], size_t length, Base base=Binary)
Definition: big_code.cpp:102
BigInt r
Definition: numthry.cpp:26
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: