diff options
author | lloyd <[email protected]> | 2008-11-10 23:24:43 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-10 23:24:43 +0000 |
commit | e6abb0fd8289619d559ff430dff84f0de4f82808 (patch) | |
tree | 9a327b708ed6dcfb4932fd0e58417da0e51385b2 | |
parent | 33495befa5bdd549ff47295a45271942dc2fe081 (diff) |
Remove lookup dep from basic pubkey classes
-rw-r--r-- | src/libstate/get_enc.cpp | 3 | ||||
-rw-r--r-- | src/pubkey/pk_lookup/look_pk.cpp | 16 | ||||
-rw-r--r-- | src/pubkey/pubkey/pubkey.cpp | 34 | ||||
-rw-r--r-- | src/pubkey/pubkey/pubkey.h | 26 |
4 files changed, 32 insertions, 47 deletions
diff --git a/src/libstate/get_enc.cpp b/src/libstate/get_enc.cpp index 63da7518b..ea02dd092 100644 --- a/src/libstate/get_enc.cpp +++ b/src/libstate/get_enc.cpp @@ -161,6 +161,9 @@ EME* get_eme(const std::string& algo_spec) { SCAN_Name request(algo_spec); + if(request.algo_name() == "Raw") + return 0; // No padding + #if defined(BOTAN_HAS_EME_PKCS1v15) if(request.algo_name() == "PKCS1v15" && request.arg_count() == 0) return new EME_PKCS1v15; diff --git a/src/pubkey/pk_lookup/look_pk.cpp b/src/pubkey/pk_lookup/look_pk.cpp index a4062b57c..1a90eb82c 100644 --- a/src/pubkey/pk_lookup/look_pk.cpp +++ b/src/pubkey/pk_lookup/look_pk.cpp @@ -14,7 +14,7 @@ namespace Botan { PK_Encryptor* get_pk_encryptor(const PK_Encrypting_Key& key, const std::string& eme) { - return new PK_Encryptor_MR_with_EME(key, eme); + return new PK_Encryptor_MR_with_EME(key, get_eme(eme)); } /************************************************* @@ -23,17 +23,17 @@ PK_Encryptor* get_pk_encryptor(const PK_Encrypting_Key& key, PK_Decryptor* get_pk_decryptor(const PK_Decrypting_Key& key, const std::string& eme) { - return new PK_Decryptor_MR_with_EME(key, eme); + return new PK_Decryptor_MR_with_EME(key, get_eme(eme)); } /************************************************* * Get a PK_Signer object * *************************************************/ PK_Signer* get_pk_signer(const PK_Signing_Key& key, - const std::string& encoding, + const std::string& emsa, Signature_Format sig_format) { - PK_Signer* signer = new PK_Signer(key, encoding); + PK_Signer* signer = new PK_Signer(key, get_emsa(emsa)); signer->set_output_format(sig_format); return signer; } @@ -42,10 +42,10 @@ PK_Signer* get_pk_signer(const PK_Signing_Key& key, * Get a PK_Verifier object * *************************************************/ PK_Verifier* get_pk_verifier(const PK_Verifying_with_MR_Key& key, - const std::string& encoding, + const std::string& emsa, Signature_Format sig_format) { - PK_Verifier* verifier = new PK_Verifier_with_MR(key, encoding); + PK_Verifier* verifier = new PK_Verifier_with_MR(key, get_emsa(emsa)); verifier->set_input_format(sig_format); return verifier; } @@ -54,10 +54,10 @@ PK_Verifier* get_pk_verifier(const PK_Verifying_with_MR_Key& key, * Get a PK_Verifier object * *************************************************/ PK_Verifier* get_pk_verifier(const PK_Verifying_wo_MR_Key& key, - const std::string& encoding, + const std::string& emsa, Signature_Format sig_format) { - PK_Verifier* verifier = new PK_Verifier_wo_MR(key, encoding); + PK_Verifier* verifier = new PK_Verifier_wo_MR(key, get_emsa(emsa)); verifier->set_input_format(sig_format); return verifier; } diff --git a/src/pubkey/pubkey/pubkey.cpp b/src/pubkey/pubkey/pubkey.cpp index 06bb44bca..61b51d081 100644 --- a/src/pubkey/pubkey/pubkey.cpp +++ b/src/pubkey/pubkey/pubkey.cpp @@ -52,8 +52,8 @@ SecureVector<byte> PK_Decryptor::decrypt(const MemoryRegion<byte>& in) const * PK_Encryptor_MR_with_EME Constructor * *************************************************/ PK_Encryptor_MR_with_EME::PK_Encryptor_MR_with_EME(const PK_Encrypting_Key& k, - const std::string& eme) : - key(k), encoder((eme == "Raw") ? 0 : get_eme(eme)) + EME* eme_obj) : + key(k), encoder(eme_obj) { } @@ -92,8 +92,8 @@ u32bit PK_Encryptor_MR_with_EME::maximum_input_size() const * PK_Decryptor_MR_with_EME Constructor * *************************************************/ PK_Decryptor_MR_with_EME::PK_Decryptor_MR_with_EME(const PK_Decrypting_Key& k, - const std::string& eme) : - key(k), encoder((eme == "Raw") ? 0 : get_eme(eme)) + EME* eme_obj) : + key(k), encoder(eme_obj) { } @@ -123,8 +123,8 @@ SecureVector<byte> PK_Decryptor_MR_with_EME::dec(const byte msg[], /************************************************* * PK_Signer Constructor * *************************************************/ -PK_Signer::PK_Signer(const PK_Signing_Key& k, const std::string& emsa_name) : - key(k), emsa(get_emsa(emsa_name)) +PK_Signer::PK_Signer(const PK_Signing_Key& k, EMSA* emsa_obj) : + key(k), emsa(emsa_obj) { sig_format = IEEE_1363; } @@ -221,9 +221,9 @@ SecureVector<byte> PK_Signer::signature(RandomNumberGenerator& rng) /************************************************* * PK_Verifier Constructor * *************************************************/ -PK_Verifier::PK_Verifier(const std::string& emsa_name) +PK_Verifier::PK_Verifier(EMSA* emsa_obj) { - emsa = get_emsa(emsa_name); + emsa = emsa_obj; sig_format = IEEE_1363; } @@ -334,15 +334,6 @@ bool PK_Verifier::check_signature(const byte sig[], u32bit length) } /************************************************* -* PK_Verifier_with_MR Constructor * -*************************************************/ -PK_Verifier_with_MR::PK_Verifier_with_MR(const PK_Verifying_with_MR_Key& k, - const std::string& emsa_name) : - PK_Verifier(emsa_name), key(k) - { - } - -/************************************************* * Verify a signature * *************************************************/ bool PK_Verifier_with_MR::validate_signature(const MemoryRegion<byte>& msg, @@ -353,15 +344,6 @@ bool PK_Verifier_with_MR::validate_signature(const MemoryRegion<byte>& msg, } /************************************************* -* PK_Verifier_wo_MR Constructor * -*************************************************/ -PK_Verifier_wo_MR::PK_Verifier_wo_MR(const PK_Verifying_wo_MR_Key& k, - const std::string& emsa_name) : - PK_Verifier(emsa_name), key(k) - { - } - -/************************************************* * Verify a signature * *************************************************/ bool PK_Verifier_wo_MR::validate_signature(const MemoryRegion<byte>& msg, diff --git a/src/pubkey/pubkey/pubkey.h b/src/pubkey/pubkey/pubkey.h index fec56243f..7e8de9f4c 100644 --- a/src/pubkey/pubkey/pubkey.h +++ b/src/pubkey/pubkey/pubkey.h @@ -146,10 +146,10 @@ class BOTAN_DLL PK_Signer /** * Construct a PK Signer. * @param key the key to use inside this signer - * @param emsa_name the name of the emsa to use. + * @param emsa the EMSA to use * An example would be "EMSA1(SHA-224)". */ - PK_Signer(const PK_Signing_Key& key, const std::string& emsa_name); + PK_Signer(const PK_Signing_Key& key, EMSA* emsa); ~PK_Signer() { delete emsa; } private: @@ -235,10 +235,10 @@ class BOTAN_DLL PK_Verifier /** * Construct a PK Verifier. - * @param emsa_name the name of the emsa to use. - * An example would be "EMSA1(SHA-224)". + * @param emsa the EMSA to use + * An example would be new EMSA1(new SHA_224) */ - PK_Verifier(const std::string& emsa_name); + PK_Verifier(EMSA* emsa); virtual ~PK_Verifier(); protected: @@ -292,10 +292,10 @@ class BOTAN_DLL PK_Encryptor_MR_with_EME : public PK_Encryptor /** * Construct an instance. * @param key the key to use inside the decryptor - * @param eme the name of the eme to use + * @param eme the EME to use */ PK_Encryptor_MR_with_EME(const PK_Encrypting_Key& key, - const std::string& eme); + EME* eme); ~PK_Encryptor_MR_with_EME() { delete encoder; } private: @@ -318,10 +318,10 @@ class BOTAN_DLL PK_Decryptor_MR_with_EME : public PK_Decryptor /** * Construct an instance. * @param key the key to use inside the encryptor - * @param eme the name of the EME to use + * @param eme the EME to use */ PK_Decryptor_MR_with_EME(const PK_Decrypting_Key& key, - const std::string& eme); + EME* eme); ~PK_Decryptor_MR_with_EME() { delete encoder; } private: @@ -345,8 +345,8 @@ class BOTAN_DLL PK_Verifier_with_MR : public PK_Verifier * @param key the key to use inside the verifier * @param emsa_name the name of the EMSA to use */ - PK_Verifier_with_MR(const PK_Verifying_with_MR_Key& key, - const std::string& emsa_name); + PK_Verifier_with_MR(const PK_Verifying_with_MR_Key& k, + EMSA* emsa_obj) : PK_Verifier(emsa_obj), key(k) {} private: PK_Verifier_with_MR(const PK_Verifying_with_MR_Key&); @@ -370,8 +370,8 @@ class BOTAN_DLL PK_Verifier_wo_MR : public PK_Verifier * @param key the key to use inside the verifier * @param emsa_name the name of the EMSA to use */ - PK_Verifier_wo_MR(const PK_Verifying_wo_MR_Key& key, - const std::string& emsa_name); + PK_Verifier_wo_MR(const PK_Verifying_wo_MR_Key& k, + EMSA* emsa_obj) : PK_Verifier(emsa_obj), key(k) {} private: PK_Verifier_wo_MR(const PK_Verifying_wo_MR_Key&); |