aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-06-16 03:21:19 +0000
committerlloyd <[email protected]>2010-06-16 03:21:19 +0000
commit46086387b45c713a11001d8d037ffd280f5c56c3 (patch)
tree4aa4902391a732d8687ded5303b6e2dfa2b83db4 /src
parent95d0a9033a979b0da9163bda4377c60049b432bd (diff)
Require all PK keys implement check_key. Add for ECC keys.
Diffstat (limited to 'src')
-rw-r--r--src/pubkey/ecc_key/ecc_key.cpp9
-rw-r--r--src/pubkey/ecc_key/ecc_key.h3
-rw-r--r--src/pubkey/pk_keys.h4
3 files changed, 11 insertions, 5 deletions
diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp
index 2c66dc97f..4f90fa321 100644
--- a/src/pubkey/ecc_key/ecc_key.cpp
+++ b/src/pubkey/ecc_key/ecc_key.cpp
@@ -24,9 +24,6 @@ EC_PublicKey::EC_PublicKey(const EC_Domain_Params& dom_par,
{
if(domain().get_curve() != public_point().get_curve())
throw Invalid_Argument("EC_PublicKey: curve mismatch in constructor");
-
- if(!public_point().on_the_curve())
- throw Invalid_State("Public key was not on the curve");
}
EC_PublicKey::EC_PublicKey(const AlgorithmIdentifier& alg_id,
@@ -38,6 +35,12 @@ EC_PublicKey::EC_PublicKey(const AlgorithmIdentifier& alg_id,
public_key = OS2ECP(key_bits, domain().get_curve());
}
+bool EC_PublicKey::check_key(RandomNumberGenerator&,
+ bool) const
+ {
+ return public_point().on_the_curve();
+ }
+
AlgorithmIdentifier EC_PublicKey::algorithm_identifier() const
{
return AlgorithmIdentifier(get_oid(), DER_domain());
diff --git a/src/pubkey/ecc_key/ecc_key.h b/src/pubkey/ecc_key/ecc_key.h
index 92f02613c..8155543da 100644
--- a/src/pubkey/ecc_key/ecc_key.h
+++ b/src/pubkey/ecc_key/ecc_key.h
@@ -49,6 +49,9 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key
MemoryVector<byte> x509_subject_public_key() const;
+ bool check_key(RandomNumberGenerator& rng,
+ bool strong) const;
+
/**
* Get the domain parameters of this key.
* @throw Invalid_State is thrown if the
diff --git a/src/pubkey/pk_keys.h b/src/pubkey/pk_keys.h
index e90fcf51a..b1036152d 100644
--- a/src/pubkey/pk_keys.h
+++ b/src/pubkey/pk_keys.h
@@ -40,8 +40,8 @@ class BOTAN_DLL Public_Key
* of the test
* @return true if the test is passed
*/
- virtual bool check_key(RandomNumberGenerator& rng, bool strong) const
- { return true; }
+ virtual bool check_key(RandomNumberGenerator& rng,
+ bool strong) const = 0;
/**
* Find out the number of message parts supported by this scheme.