diff options
author | lloyd <[email protected]> | 2008-11-11 21:59:30 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-11 21:59:30 +0000 |
commit | d4ec4e06936d2a993a81ab33c46201352f77b387 (patch) | |
tree | f0af295a0978b068cb2f9381372ecaa6073b49a5 /src/cms/cms_algo.cpp | |
parent | 8b5b9aa24741622c2010f6a03238891025058382 (diff) |
Remove last uses of lookup.h in CMS code
Diffstat (limited to 'src/cms/cms_algo.cpp')
-rw-r--r-- | src/cms/cms_algo.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/cms/cms_algo.cpp b/src/cms/cms_algo.cpp index b065676a8..8db27c65f 100644 --- a/src/cms/cms_algo.cpp +++ b/src/cms/cms_algo.cpp @@ -5,8 +5,10 @@ #include <botan/cms_enc.h> #include <botan/der_enc.h> -#include <botan/lookup.h> +#include <botan/sha160.h> +#include <botan/cbc.h> #include <botan/filters.h> +#include <botan/libstate.h> #if defined(BOTAN_HAS_RC2) #include <botan/rc2.h> @@ -20,7 +22,7 @@ namespace { * Wrap a key as specified in RFC 3217 * *************************************************/ SecureVector<byte> do_rfc3217_wrap(RandomNumberGenerator& rng, - const std::string& cipher, + const std::string& cipher_name, const SymmetricKey& kek, const SecureVector<byte>& input) { @@ -42,18 +44,23 @@ SecureVector<byte> do_rfc3217_wrap(RandomNumberGenerator& rng, SecureVector<byte> buf; }; - if(block_size_of(cipher) != 8) - throw Encoding_Error("do_rfc3217_wrap: Bad cipher: " + cipher); + Algorithm_Factory& af = global_state().algorithm_factory(); - Pipe icv(new Hash_Filter("SHA-160", 8)); + const BlockCipher* cipher = af.prototype_block_cipher(cipher_name); + + if(!cipher || cipher->BLOCK_SIZE != 8) + throw Encoding_Error("do_rfc3217_wrap: Bad cipher: " + cipher_name); + + Pipe icv(new Hash_Filter(new SHA_160, 8)); icv.process_msg(input); InitializationVector iv(rng, 8); InitializationVector fixed("4ADDA22C79E82105"); - Pipe pipe(get_cipher(cipher + "/CBC/NoPadding", kek, iv, ENCRYPTION), + Pipe pipe(new CBC_Encryption(cipher->clone(), new Null_Padding, kek, iv), new Flip_Bytes(iv.bits_of()), - get_cipher(cipher + "/CBC/NoPadding", kek, fixed, ENCRYPTION)); + new CBC_Encryption(cipher->clone(), new Null_Padding, kek, iv)); + pipe.start_msg(); pipe.write(input); pipe.write(icv.read_all()); |