diff options
author | Never <[email protected]> | 2016-12-19 13:35:18 +0100 |
---|---|---|
committer | Never <[email protected]> | 2016-12-19 13:35:18 +0100 |
commit | 735282facf31b9ac688fd0724c1a68ca3dcc4107 (patch) | |
tree | c066f12ee049265a9182663baab8c728f529c459 /src/lib/pubkey/ecies | |
parent | 037f037a10ec12f77600307d7012dcc27d3aa291 (diff) |
Blind the ECDH/ECIES agree operation.
Diffstat (limited to 'src/lib/pubkey/ecies')
-rw-r--r-- | src/lib/pubkey/ecies/ecies.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/pubkey/ecies/ecies.cpp b/src/lib/pubkey/ecies/ecies.cpp index b40d21251..060f9995e 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)); } /** |