diff options
author | lloyd <[email protected]> | 2010-03-04 22:50:27 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-04 22:50:27 +0000 |
commit | a4df991ee1c371cbd931122c7f0da1559f015e16 (patch) | |
tree | 7b38b294a33f927c2ef4f8d927ae1f46449c0430 /src/ssl/cert_ver.cpp | |
parent | 7c48bec6b86e64712e03726a767c070d0b1fb79d (diff) |
Remove some unnecessary usages of PK_Signing_Key
Diffstat (limited to 'src/ssl/cert_ver.cpp')
-rw-r--r-- | src/ssl/cert_ver.cpp | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/ssl/cert_ver.cpp b/src/ssl/cert_ver.cpp index 5ac28dd2e..22dae8350 100644 --- a/src/ssl/cert_ver.cpp +++ b/src/ssl/cert_ver.cpp @@ -22,32 +22,22 @@ Certificate_Verify::Certificate_Verify(RandomNumberGenerator& rng, HandshakeHash& hash, const Private_Key* priv_key) { - const PK_Signing_Key* sign_key = - dynamic_cast<const PK_Signing_Key*>(priv_key); + std::auto_ptr<PK_Signer> signer; - if(sign_key) + if(const RSA_PrivateKey* rsa = dynamic_cast<const RSA_PrivateKey*>(priv_key)) { - PK_Signer* signer = 0; - try - { - if(dynamic_cast<const RSA_PrivateKey*>(sign_key)) - signer = get_pk_signer(*sign_key, "EMSA3(TLS.Digest.0)"); - else if(dynamic_cast<const DSA_PrivateKey*>(sign_key)) - signer = get_pk_signer(*sign_key, "EMSA1(SHA-1)"); - else - throw Invalid_Argument("Unknown PK algo for TLS signature"); - - signature = signer->sign_message(hash.final(), rng); - delete signer; - } - catch(...) - { - delete signer; - throw; - } - - send(writer, hash); + signer.reset(get_pk_signer(*rsa, "EMSA3(TLS.Digest.0)")); } + else if(const DSA_PrivateKey* dsa = + dynamic_cast<const DSA_PrivateKey*>(priv_key)) + { + signer.reset(get_pk_signer(*dsa, "EMSA1(SHA-1)")); + } + else + throw Invalid_Argument("Unknown PK algo for TLS signature"); + + signature = signer->sign_message(hash.final(), rng); + send(writer, hash); } /** |