Botan: Botan::DH_KA_Operation Class Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

`#include <dh.h>`

Inheritance diagram for Botan::DH_KA_Operation:

## Public Member Functions
SecureVector< byte > | agree (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 }
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:253
Botan::Global_State_Management::global_state
Library_State & global_state()
Definition: global_state.cpp:32
Botan::inverse_mod
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(), 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 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::Blinder::unblind
BigInt unblind(const BigInt &x) const
Definition: blinding.cpp:42
Botan::Blinder::blind
BigInt blind(const BigInt &x) const
Definition: blinding.cpp:29
Botan::BigInt::decode
static BigInt decode(const byte buf[], size_t length, Base base=Binary)
Definition: big_code.cpp:102
Botan::BigInt::encode_1363
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
Definition: big_code.cpp:78
Botan::BigInt::bytes
size_t bytes() const
Definition: bigint.cpp:245

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

- src/pubkey/dh/dh.h
- src/pubkey/dh/dh.cpp