aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/ecies
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-12-21 19:48:04 -0500
committerJack Lloyd <[email protected]>2016-12-21 19:48:04 -0500
commit8f5089b2bb9c571e0c9620ad43465af1e8af2b11 (patch)
treeb8237f37f23e5c986db55499060cf549a8942532 /src/lib/pubkey/ecies
parent46bf28e0b6d9627a57862a180142fbf158f33ce7 (diff)
parent75e6d9aa7da63cf7dbf81359e350da682c8e4979 (diff)
Merge GH #779 Add ECDH/ECIES blinding and DH small subgroup checking
Diffstat (limited to 'src/lib/pubkey/ecies')
-rw-r--r--src/lib/pubkey/ecies/ecies.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/pubkey/ecies/ecies.cpp b/src/lib/pubkey/ecies/ecies.cpp
index 84c1a8f3f..df676cfb3 100644
--- a/src/lib/pubkey/ecies/ecies.cpp
+++ b/src/lib/pubkey/ecies/ecies.cpp
@@ -55,9 +55,10 @@ class ECIES_PrivateKey : public EC_PrivateKey, public PK_Key_Agreement_Key
class ECIES_ECDH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
{
public:
- ECIES_ECDH_KA_Operation(const ECIES_PrivateKey& private_key) :
+ ECIES_ECDH_KA_Operation(const ECIES_PrivateKey& private_key, RandomNumberGenerator& rng) :
PK_Ops::Key_Agreement_with_KDF("Raw"),
- m_key(private_key)
+ m_key(private_key),
+ m_rng(rng)
{
}
@@ -65,21 +66,23 @@ class ECIES_ECDH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
{
const CurveGFp& curve = m_key.domain().get_curve();
PointGFp point = OS2ECP(w, w_len, curve);
- PointGFp S = point * m_key.private_value();
+ Blinded_Point_Multiply blinder(point, m_key.domain().get_order());
+ PointGFp S = blinder.blinded_multiply(m_key.private_value(), m_rng);
BOTAN_ASSERT(S.on_the_curve(), "ECDH agreed value was on the curve");
return BigInt::encode_1363(S.get_affine_x(), curve.get_p().bytes());
}
private:
ECIES_PrivateKey m_key;
+ RandomNumberGenerator& m_rng;
};
std::unique_ptr<PK_Ops::Key_Agreement>
-ECIES_PrivateKey::create_key_agreement_op(RandomNumberGenerator& /*rng*/,
+ECIES_PrivateKey::create_key_agreement_op(RandomNumberGenerator& rng,
const std::string& /*params*/,
const std::string& /*provider*/) const
{
- return std::unique_ptr<PK_Ops::Key_Agreement>(new ECIES_ECDH_KA_Operation(*this));
+ return std::unique_ptr<PK_Ops::Key_Agreement>(new ECIES_ECDH_KA_Operation(*this, rng));
}
/**