aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/ecdh
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-09 02:39:31 +0000
committerlloyd <[email protected]>2010-03-09 02:39:31 +0000
commit4a9afbb99bb73e43bcb3a30379d6a2dd59dae76a (patch)
tree4f7a362be278ed63828afeae56444afcbf0b2dac /src/pubkey/ecdh
parenta4df64935b788e541206547d5d85665c191e2f5f (diff)
Deconstify PK_Ops. It's quite reasonable that some op will want to
precompute only as needed, or will want to access some other expensive resource or etc. Change how the secret for generating blinding is done in cases where a PRNG isn't available. Use the operations public op to hide the secret, for instance the seed for a DH blinding variable is 2^x mod p. Make use of being able to mutate internal structures in the RW signer, since that does have access to a PRNG, so use it to initialize the blinder on first call to sign().
Diffstat (limited to 'src/pubkey/ecdh')
-rw-r--r--src/pubkey/ecdh/ecdh.cpp37
-rw-r--r--src/pubkey/ecdh/ecdh.h21
2 files changed, 2 insertions, 56 deletions
diff --git a/src/pubkey/ecdh/ecdh.cpp b/src/pubkey/ecdh/ecdh.cpp
index d3688fa5c..bf8a57b3b 100644
--- a/src/pubkey/ecdh/ecdh.cpp
+++ b/src/pubkey/ecdh/ecdh.cpp
@@ -19,7 +19,7 @@ ECDH_KA_Operation::ECDH_KA_Operation(const ECDH_PrivateKey& key) :
key.private_value();
}
-SecureVector<byte> ECDH_KA_Operation::agree(const byte w[], u32bit w_len) const
+SecureVector<byte> ECDH_KA_Operation::agree(const byte w[], u32bit w_len)
{
PointGFp point = OS2ECP(w, w_len, curve);
@@ -30,39 +30,4 @@ SecureVector<byte> ECDH_KA_Operation::agree(const byte w[], u32bit w_len) const
curve.get_p().bytes());
}
-/**
-* Derive a key
-*/
-SecureVector<byte> ECDH_PrivateKey::derive_key(const byte key[],
- u32bit key_len) const
- {
- PointGFp point = OS2ECP(key, key_len, public_point().get_curve());
- return derive_key(point);
- }
-
-/**
-* Derive a key
-*/
-SecureVector<byte> ECDH_PrivateKey::derive_key(const ECDH_PublicKey& key) const
- {
- return derive_key(key.public_point());
- }
-
-/**
-* Derive a key
-*/
-SecureVector<byte> ECDH_PrivateKey::derive_key(const PointGFp& point) const
- {
- const BigInt& cofactor = domain().get_cofactor();
- const BigInt& n = domain().get_order();
-
- BigInt l = inverse_mod(cofactor, n); // can precompute this
-
- PointGFp S = (cofactor * point) * (private_value() * l);
- S.check_invariants();
-
- return BigInt::encode_1363(S.get_affine_x(),
- point.get_curve().get_p().bytes());
- }
-
}
diff --git a/src/pubkey/ecdh/ecdh.h b/src/pubkey/ecdh/ecdh.h
index ef589d982..d670361f6 100644
--- a/src/pubkey/ecdh/ecdh.h
+++ b/src/pubkey/ecdh/ecdh.h
@@ -76,25 +76,6 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey,
MemoryVector<byte> public_value() const
{ return EC2OSP(public_point(), PointGFp::UNCOMPRESSED); }
- private:
- /**
- * Derive a shared key with the other parties public key.
- * @param key the other partys public key
- * @param key_len the other partys public key
- */
- SecureVector<byte> derive_key(const byte key[], u32bit key_len) const;
-
- /**
- * Derive a shared key with the other parties public key.
- * @param other the other partys public key
- */
- SecureVector<byte> derive_key(const ECDH_PublicKey& other) const;
-
- /**
- * Derive a shared key with the other parties public key.
- * @param point the public point of the other parties key
- */
- SecureVector<byte> derive_key(const PointGFp& point) const;
};
/**
@@ -105,7 +86,7 @@ class BOTAN_DLL ECDH_KA_Operation : public PK_Ops::Key_Agreement
public:
ECDH_KA_Operation(const ECDH_PrivateKey& key);
- SecureVector<byte> agree(const byte w[], u32bit w_len) const;
+ SecureVector<byte> agree(const byte w[], u32bit w_len);
private:
const CurveGFp& curve;
const BigInt& cofactor;