diff options
author | lloyd <[email protected]> | 2010-03-08 14:28:14 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-08 14:28:14 +0000 |
commit | ea38a42c2cfbc3a6235b11637b382589676c6286 (patch) | |
tree | 918b28ec50e98612e2c055e28368f7397b96f79c /src/cert | |
parent | 3900bd1e5a9974eea4faee4a8159380ea67c6251 (diff) |
Remove the now no-op classes PK_Encrypting_Key,
PK_Decrypting_Key, PK_Signing_Key, PK_Verifying_with_MR_Key, and
PK_Verifying_wo_MR_Key.
Diffstat (limited to 'src/cert')
-rw-r--r-- | src/cert/cvc/signed_obj.cpp | 6 | ||||
-rw-r--r-- | src/cert/x509/x509_ca.cpp | 8 | ||||
-rw-r--r-- | src/cert/x509/x509_obj.cpp | 18 | ||||
-rw-r--r-- | src/cert/x509/x509self.cpp | 4 | ||||
-rw-r--r-- | src/cert/x509/x509stor.cpp | 18 |
5 files changed, 7 insertions, 47 deletions
diff --git a/src/cert/cvc/signed_obj.cpp b/src/cert/cvc/signed_obj.cpp index 31a158dd4..ddb714621 100644 --- a/src/cert/cvc/signed_obj.cpp +++ b/src/cert/cvc/signed_obj.cpp @@ -62,13 +62,9 @@ bool EAC_Signed_Object::check_signature(Public_Key& pub_key, Signature_Format format = (pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363; - if(!dynamic_cast<PK_Verifying_wo_MR_Key*>(&pub_key)) - return false; - SecureVector<byte> to_sign = tbs_data(); - PK_Verifying_wo_MR_Key& sig_key = dynamic_cast<PK_Verifying_wo_MR_Key&>(pub_key); - std::auto_ptr<PK_Verifier> verifier(get_pk_verifier(sig_key, padding, format)); + std::auto_ptr<PK_Verifier> verifier(get_pk_verifier(pub_key, padding, format)); return verifier->verify_message(to_sign, sig); } catch(...) diff --git a/src/cert/x509/x509_ca.cpp b/src/cert/x509/x509_ca.cpp index 9af5aa449..00a105d1d 100644 --- a/src/cert/x509/x509_ca.cpp +++ b/src/cert/x509/x509_ca.cpp @@ -30,10 +30,6 @@ X509_CA::X509_CA(const X509_Certificate& c, const Private_Key& key, const std::string& hash_fn) : cert(c) { - // Use pointer dynamic_cast to avoid exception if cast fails - if(!dynamic_cast<const PK_Signing_Key*>(&key)) - throw Invalid_Argument("X509_CA: " + key.algo_name() + " cannot sign"); - if(!cert.is_CA_cert()) throw Invalid_Argument("X509_CA: This certificate is not for a CA"); @@ -276,9 +272,7 @@ PK_Signer* choose_sig_format(const Private_Key& key, sig_algo.oid = OIDS::lookup(algo_name + "/" + padding); sig_algo.parameters = key.algorithm_identifier().parameters; - const PK_Signing_Key& sig_key = dynamic_cast<const PK_Signing_Key&>(key); - - return get_pk_signer(sig_key, padding, format); + return get_pk_signer(key, padding, format); } } diff --git a/src/cert/x509/x509_obj.cpp b/src/cert/x509/x509_obj.cpp index 31b4a309f..fb92a9cb0 100644 --- a/src/cert/x509/x509_obj.cpp +++ b/src/cert/x509/x509_obj.cpp @@ -168,22 +168,8 @@ bool X509_Object::check_signature(Public_Key& pub_key) const Signature_Format format = (pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363; - std::auto_ptr<PK_Verifier> verifier; - - if(dynamic_cast<PK_Verifying_with_MR_Key*>(&pub_key)) - { - PK_Verifying_with_MR_Key& sig_key = - dynamic_cast<PK_Verifying_with_MR_Key&>(pub_key); - verifier.reset(get_pk_verifier(sig_key, padding, format)); - } - else if(dynamic_cast<PK_Verifying_wo_MR_Key*>(&pub_key)) - { - PK_Verifying_wo_MR_Key& sig_key = - dynamic_cast<PK_Verifying_wo_MR_Key&>(pub_key); - verifier.reset(get_pk_verifier(sig_key, padding, format)); - } - else - return false; + std::auto_ptr<PK_Verifier> verifier( + get_pk_verifier(pub_key, padding, format)); return verifier->verify_message(tbs_data(), signature()); } diff --git a/src/cert/x509/x509self.cpp b/src/cert/x509/x509self.cpp index f915c6ff5..e85317462 100644 --- a/src/cert/x509/x509self.cpp +++ b/src/cert/x509/x509self.cpp @@ -24,10 +24,6 @@ namespace { MemoryVector<byte> shared_setup(const X509_Cert_Options& opts, const Private_Key& key) { - const Private_Key* key_pointer = &key; - if(!dynamic_cast<const PK_Signing_Key*>(key_pointer)) - throw Invalid_Argument("Key type " + key.algo_name() + " cannot sign"); - opts.sanity_check(); Pipe key_encoder; diff --git a/src/cert/x509/x509stor.cpp b/src/cert/x509/x509stor.cpp index e9e8f4575..b134817e4 100644 --- a/src/cert/x509/x509stor.cpp +++ b/src/cert/x509/x509stor.cpp @@ -381,7 +381,6 @@ X509_Code X509_Store::check_sig(const Cert_Info& cert_info, X509_Code X509_Store::check_sig(const X509_Object& object, Public_Key* key) { std::auto_ptr<Public_Key> pub_key(key); - std::auto_ptr<PK_Verifier> verifier; try { std::vector<std::string> sig_info = @@ -395,20 +394,8 @@ X509_Code X509_Store::check_sig(const X509_Object& object, Public_Key* key) if(key->message_parts() >= 2) format = DER_SEQUENCE; else format = IEEE_1363; - if(dynamic_cast<PK_Verifying_with_MR_Key*>(pub_key.get())) - { - PK_Verifying_with_MR_Key* sig_key = - dynamic_cast<PK_Verifying_with_MR_Key*>(pub_key.get()); - verifier.reset(get_pk_verifier(*sig_key, padding, format)); - } - else if(dynamic_cast<PK_Verifying_wo_MR_Key*>(pub_key.get())) - { - PK_Verifying_wo_MR_Key* sig_key = - dynamic_cast<PK_Verifying_wo_MR_Key*>(pub_key.get()); - verifier.reset(get_pk_verifier(*sig_key, padding, format)); - } - else - return CA_CERT_CANNOT_SIGN; + std::auto_ptr<PK_Verifier> verifier( + get_pk_verifier(*pub_key.get(), padding, format)); bool valid = verifier->verify_message(object.tbs_data(), object.signature()); @@ -418,6 +405,7 @@ X509_Code X509_Store::check_sig(const X509_Object& object, Public_Key* key) else return SIGNATURE_ERROR; } + catch(Lookup_Error) { return CA_CERT_CANNOT_SIGN; } catch(Decoding_Error) { return CERT_FORMAT_ERROR; } catch(Exception) {} |