From 78b5b103291ee668185dc71d138a50e8e7e54808 Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 4 Mar 2010 23:07:20 +0000 Subject: The operation can assume the key will continue to exist as long as it does, so keep the curve and cofactor in ECDH op by reference instead of value. --- src/pubkey/ecdh/ecdh.cpp | 8 +++----- src/pubkey/ecdh/ecdh.h | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pubkey/ecdh/ecdh.cpp b/src/pubkey/ecdh/ecdh.cpp index 37dc7c392..d3688fa5c 100644 --- a/src/pubkey/ecdh/ecdh.cpp +++ b/src/pubkey/ecdh/ecdh.cpp @@ -11,12 +11,10 @@ namespace Botan { -ECDH_KA_Operation::ECDH_KA_Operation(const ECDH_PrivateKey& key) +ECDH_KA_Operation::ECDH_KA_Operation(const ECDH_PrivateKey& key) : + curve(key.domain().get_curve()), + cofactor(key.domain().get_cofactor()) { - cofactor = key.domain().get_cofactor(); - - curve = key.domain().get_curve(); - l_times_priv = inverse_mod(cofactor, key.domain().get_order()) * key.private_value(); } diff --git a/src/pubkey/ecdh/ecdh.h b/src/pubkey/ecdh/ecdh.h index ad7efdc13..92796d961 100644 --- a/src/pubkey/ecdh/ecdh.h +++ b/src/pubkey/ecdh/ecdh.h @@ -107,8 +107,9 @@ class BOTAN_DLL ECDH_KA_Operation : public PK_Ops::KA_Operation SecureVector agree(const byte w[], u32bit w_len) const; private: - CurveGFp curve; - BigInt l_times_priv, cofactor; + const CurveGFp& curve; + const BigInt& cofactor; + BigInt l_times_priv; }; } -- cgit v1.2.3