aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-04 23:07:20 +0000
committerlloyd <[email protected]>2010-03-04 23:07:20 +0000
commit78b5b103291ee668185dc71d138a50e8e7e54808 (patch)
treef428d177bd4a8af00f9473c62053a1b39b68e73d /src/pubkey
parenta4df991ee1c371cbd931122c7f0da1559f015e16 (diff)
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.
Diffstat (limited to 'src/pubkey')
-rw-r--r--src/pubkey/ecdh/ecdh.cpp8
-rw-r--r--src/pubkey/ecdh/ecdh.h5
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<byte> 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;
};
}