aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/ecdsa
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-21 21:54:47 +0000
committerlloyd <[email protected]>2010-03-21 21:54:47 +0000
commitc23ae85c0529071b3170e88d361342d6a792f417 (patch)
tree5f731b328266809df9fd82cd1e1e5d4dc6c8e88b /src/pubkey/ecdsa
parent8b0d3575e794073f6e6658544d8167e399762ce0 (diff)
KeyPair::check_key's behavior of throwing an exception upon failure was
not useful; in all cases, we immediately caught it and then returned false. Modify as follows: - Create the pubkey objects inside the checking code, so calling code doesn't need to do it. - Return true/false for pass/fail Also add consistency checking for ECDSA keys
Diffstat (limited to 'src/pubkey/ecdsa')
-rw-r--r--src/pubkey/ecdsa/ecdsa.cpp13
-rw-r--r--src/pubkey/ecdsa/ecdsa.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/src/pubkey/ecdsa/ecdsa.cpp b/src/pubkey/ecdsa/ecdsa.cpp
index 40ae7c3b9..8915a598e 100644
--- a/src/pubkey/ecdsa/ecdsa.cpp
+++ b/src/pubkey/ecdsa/ecdsa.cpp
@@ -8,9 +8,22 @@
*/
#include <botan/ecdsa.h>
+#include <botan/keypair.h>
namespace Botan {
+bool ECDSA_PrivateKey::check_key(RandomNumberGenerator& rng,
+ bool strong) const
+ {
+ if(!public_point().on_the_curve())
+ return false;
+
+ if(!strong)
+ return true;
+
+ return KeyPair::signature_consistency_check(rng, *this, "EMSA1(SHA-1)");
+ }
+
ECDSA_Signature_Operation::ECDSA_Signature_Operation(const ECDSA_PrivateKey& ecdsa) :
base_point(ecdsa.domain().get_base_point()),
order(ecdsa.domain().get_order()),
diff --git a/src/pubkey/ecdsa/ecdsa.h b/src/pubkey/ecdsa/ecdsa.h
index cb4893002..62bd007f9 100644
--- a/src/pubkey/ecdsa/ecdsa.h
+++ b/src/pubkey/ecdsa/ecdsa.h
@@ -85,6 +85,8 @@ class BOTAN_DLL ECDSA_PrivateKey : public ECDSA_PublicKey,
*/
ECDSA_PrivateKey(const EC_Domain_Params& domain, const BigInt& x) :
EC_PrivateKey(domain, x) {}
+
+ bool check_key(RandomNumberGenerator& rng, bool) const;
};
class BOTAN_DLL ECDSA_Signature_Operation : public PK_Ops::Signature