Botan 1.10.17
ecdh.cpp
Go to the documentation of this file.
1/*
2* ECDH implemenation
3* (C) 2007 Manuel Hartl, FlexSecure GmbH
4* 2007 Falko Strenzke, FlexSecure GmbH
5* 2008-2010 Jack Lloyd
6*
7* Distributed under the terms of the Botan license
8*/
9
10#include <botan/ecdh.h>
11#include <botan/internal/assert.h>
12
13namespace Botan {
14
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 }
22
23SecureVector<byte> ECDH_KA_Operation::agree(const byte w[], size_t w_len)
24 {
25 PointGFp point = OS2ECP(w, w_len, curve);
26
27 PointGFp S = (cofactor * point) * l_times_priv;
28
30 "ECDH agreed value not on the curve");
31
33 curve.get_p().bytes());
34 }
35
36}
#define BOTAN_ASSERT(expr, msg)
Definition assert.h:19
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
Definition big_code.cpp:78
size_t bytes() const
Definition bigint.cpp:246
SecureVector< byte > agree(const byte w[], size_t w_len)
Definition ecdh.cpp:23
ECDH_KA_Operation(const ECDH_PrivateKey &key)
Definition ecdh.cpp:15
const BigInt & get_order() const
Definition ec_group.h:101
const BigInt & private_value() const
Definition ecc_key.cpp:70
const EC_Group & domain() const
Definition ecc_key.h:60
bool on_the_curve() const
BigInt get_affine_x() const
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition numthry.cpp:314
PointGFp OS2ECP(const byte data[], size_t data_len, const CurveGFp &curve)