diff options
author | lloyd <[email protected]> | 2010-03-08 15:45:43 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-08 15:45:43 +0000 |
commit | 868c7f7d9c306e6e15d24f2b32e529aa1956516e (patch) | |
tree | 2d179e2ff08144c63ad5d7462cd5923524a92d33 /src/pubkey | |
parent | 8a47f6f2bbf169a2ea0853234f81b49070c770df (diff) |
Rename PK_Encryptor_MR_with_EME and PK_Decryptor_MR_with_EME to
PK_Encryptor_EME and PK_Decryptor_EME; the message recovery is somewhat
implicit in the recovery of the plaintext.
Diffstat (limited to 'src/pubkey')
-rw-r--r-- | src/pubkey/elgamal/elgamal.cpp | 4 | ||||
-rw-r--r-- | src/pubkey/pubkey.cpp | 32 | ||||
-rw-r--r-- | src/pubkey/pubkey.h | 42 |
3 files changed, 40 insertions, 38 deletions
diff --git a/src/pubkey/elgamal/elgamal.cpp b/src/pubkey/elgamal/elgamal.cpp index 6b919d916..fe83b3b2b 100644 --- a/src/pubkey/elgamal/elgamal.cpp +++ b/src/pubkey/elgamal/elgamal.cpp @@ -65,8 +65,8 @@ bool ElGamal_PrivateKey::check_key(RandomNumberGenerator& rng, try { - PK_Encryptor_MR_with_EME this_encryptor(*this, "EME1(SHA-1)"); - PK_Decryptor_MR_with_EME this_decryptor(*this, "EME1(SHA-1)"); + PK_Encryptor_EME this_encryptor(*this, "EME1(SHA-1)"); + PK_Decryptor_EME this_decryptor(*this, "EME1(SHA-1)"); KeyPair::check_key(rng, this_encryptor, diff --git a/src/pubkey/pubkey.cpp b/src/pubkey/pubkey.cpp index 7426292ce..5b6c7cd45 100644 --- a/src/pubkey/pubkey.cpp +++ b/src/pubkey/pubkey.cpp @@ -19,10 +19,10 @@ namespace Botan { /* -* PK_Encryptor_MR_with_EME Constructor +* PK_Encryptor_EME Constructor */ -PK_Encryptor_MR_with_EME::PK_Encryptor_MR_with_EME(const Public_Key& key, - const std::string& eme_name) +PK_Encryptor_EME::PK_Encryptor_EME(const Public_Key& key, + const std::string& eme_name) { Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); @@ -34,7 +34,7 @@ PK_Encryptor_MR_with_EME::PK_Encryptor_MR_with_EME(const Public_Key& key, } if(op == 0) - throw Lookup_Error("PK_Encryptor_MR_with_EME: No working engine for " + + throw Lookup_Error("PK_Encryptor_EME: No working engine for " + key.algo_name()); eme = get_eme(eme_name); @@ -44,9 +44,9 @@ PK_Encryptor_MR_with_EME::PK_Encryptor_MR_with_EME(const Public_Key& key, * Encrypt a message */ SecureVector<byte> -PK_Encryptor_MR_with_EME::enc(const byte msg[], - u32bit length, - RandomNumberGenerator& rng) const +PK_Encryptor_EME::enc(const byte msg[], + u32bit length, + RandomNumberGenerator& rng) const { SecureVector<byte> message; if(eme) @@ -55,7 +55,7 @@ PK_Encryptor_MR_with_EME::enc(const byte msg[], message.set(msg, length); if(8*(message.size() - 1) + high_bit(message[0]) > op->max_input_bits()) - throw Invalid_Argument("PK_Encryptor_MR_with_EME: Input is too large"); + throw Invalid_Argument("PK_Encryptor_EME: Input is too large"); return op->encrypt(message, message.size(), rng); } @@ -63,7 +63,7 @@ PK_Encryptor_MR_with_EME::enc(const byte msg[], /* * Return the max size, in bytes, of a message */ -u32bit PK_Encryptor_MR_with_EME::maximum_input_size() const +u32bit PK_Encryptor_EME::maximum_input_size() const { if(!eme) return (op->max_input_bits() / 8); @@ -72,10 +72,10 @@ u32bit PK_Encryptor_MR_with_EME::maximum_input_size() const } /* -* PK_Decryptor_MR_with_EME Constructor +* PK_Decryptor_EME Constructor */ -PK_Decryptor_MR_with_EME::PK_Decryptor_MR_with_EME(const Private_Key& key, - const std::string& eme_name) +PK_Decryptor_EME::PK_Decryptor_EME(const Private_Key& key, + const std::string& eme_name) { Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); @@ -87,7 +87,7 @@ PK_Decryptor_MR_with_EME::PK_Decryptor_MR_with_EME(const Private_Key& key, } if(op == 0) - throw Lookup_Error("PK_Decryptor_MR_with_EME: No working engine for " + + throw Lookup_Error("PK_Decryptor_EME: No working engine for " + key.algo_name()); eme = get_eme(eme_name); @@ -96,8 +96,8 @@ PK_Decryptor_MR_with_EME::PK_Decryptor_MR_with_EME(const Private_Key& key, /* * Decrypt a message */ -SecureVector<byte> PK_Decryptor_MR_with_EME::dec(const byte msg[], - u32bit length) const +SecureVector<byte> PK_Decryptor_EME::dec(const byte msg[], + u32bit length) const { try { SecureVector<byte> decrypted = op->decrypt(msg, length); @@ -108,7 +108,7 @@ SecureVector<byte> PK_Decryptor_MR_with_EME::dec(const byte msg[], } catch(Invalid_Argument) { - throw Decoding_Error("PK_Decryptor_MR_with_EME: Input is invalid"); + throw Decoding_Error("PK_Decryptor_EME: Input is invalid"); } } diff --git a/src/pubkey/pubkey.h b/src/pubkey/pubkey.h index c65ecd468..a262b51fe 100644 --- a/src/pubkey/pubkey.h +++ b/src/pubkey/pubkey.h @@ -61,8 +61,12 @@ class BOTAN_DLL PK_Encryptor */ virtual u32bit maximum_input_size() const = 0; + PK_Encryptor() {} virtual ~PK_Encryptor() {} private: + PK_Encryptor(const PK_Encryptor&) {} + PK_Encryptor& operator=(const PK_Encryptor&) { return *this; } + virtual SecureVector<byte> enc(const byte[], u32bit, RandomNumberGenerator&) const = 0; }; @@ -94,8 +98,12 @@ class BOTAN_DLL PK_Decryptor return dec(&in[0], in.size()); } + PK_Decryptor() {} virtual ~PK_Decryptor() {} private: + PK_Decryptor(const PK_Decryptor&) {} + PK_Decryptor& operator=(const PK_Decryptor&) { return *this; } + virtual SecureVector<byte> dec(const byte[], u32bit) const = 0; }; @@ -173,8 +181,8 @@ class BOTAN_DLL PK_Signer ~PK_Signer() { delete op; delete emsa; } private: - PK_Signer(const PK_Signer&); - PK_Signer& operator=(const PK_Signer&); + PK_Signer(const PK_Signer&) {} + PK_Signer& operator=(const PK_Signer&) { return *this; } PK_Ops::Signature* op; EMSA* emsa; @@ -272,8 +280,8 @@ class BOTAN_DLL PK_Verifier ~PK_Verifier() { delete op; delete emsa; } private: - PK_Verifier(const PK_Verifier&); - PK_Verifier& operator=(const PK_Verifier&); + PK_Verifier(const PK_Verifier&) {} + PK_Verifier& operator=(const PK_Verifier&) { return *this; } bool validate_signature(const MemoryRegion<byte>& msg, const byte sig[], u32bit sig_len); @@ -362,8 +370,8 @@ class BOTAN_DLL PK_Key_Agreement ~PK_Key_Agreement() { delete op; delete kdf; } private: - PK_Key_Agreement(const PK_Key_Agreement_Key&); - PK_Key_Agreement& operator=(const PK_Key_Agreement&); + PK_Key_Agreement(const PK_Key_Agreement_Key&) {} + PK_Key_Agreement& operator=(const PK_Key_Agreement&) { return *this; } PK_Ops::Key_Agreement* op; KDF* kdf; @@ -372,7 +380,7 @@ class BOTAN_DLL PK_Key_Agreement /** * Encryption with an MR algorithm and an EME. */ -class BOTAN_DLL PK_Encryptor_MR_with_EME : public PK_Encryptor +class BOTAN_DLL PK_Encryptor_EME : public PK_Encryptor { public: u32bit maximum_input_size() const; @@ -382,14 +390,11 @@ class BOTAN_DLL PK_Encryptor_MR_with_EME : public PK_Encryptor * @param key the key to use inside the decryptor * @param eme the EME to use */ - PK_Encryptor_MR_with_EME(const Public_Key& key, - const std::string& eme); + PK_Encryptor_EME(const Public_Key& key, + const std::string& eme); - ~PK_Encryptor_MR_with_EME() { delete op; delete eme; } + ~PK_Encryptor_EME() { delete op; delete eme; } private: - PK_Encryptor_MR_with_EME(const PK_Encryptor_MR_with_EME&); - PK_Encryptor_MR_with_EME& operator=(const PK_Encryptor_MR_with_EME&); - SecureVector<byte> enc(const byte[], u32bit, RandomNumberGenerator& rng) const; @@ -400,7 +405,7 @@ class BOTAN_DLL PK_Encryptor_MR_with_EME : public PK_Encryptor /** * Decryption with an MR algorithm and an EME. */ -class BOTAN_DLL PK_Decryptor_MR_with_EME : public PK_Decryptor +class BOTAN_DLL PK_Decryptor_EME : public PK_Decryptor { public: /** @@ -408,14 +413,11 @@ class BOTAN_DLL PK_Decryptor_MR_with_EME : public PK_Decryptor * @param key the key to use inside the encryptor * @param eme the EME to use */ - PK_Decryptor_MR_with_EME(const Private_Key& key, - const std::string& eme); + PK_Decryptor_EME(const Private_Key& key, + const std::string& eme); - ~PK_Decryptor_MR_with_EME() { delete op; delete eme; } + ~PK_Decryptor_EME() { delete op; delete eme; } private: - PK_Decryptor_MR_with_EME(const PK_Decryptor_MR_with_EME&); - PK_Decryptor_MR_with_EME& operator=(const PK_Decryptor_MR_with_EME&); - SecureVector<byte> dec(const byte[], u32bit) const; const PK_Ops::Decryption* op; |