diff options
author | lloyd <[email protected]> | 2015-01-31 15:30:49 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-01-31 15:30:49 +0000 |
commit | 00c9b3f4834603946065c15b9b2e9fa5e973b979 (patch) | |
tree | b0f82333a1eeab624409db9515e511838f6fa2d6 /src/lib/constructs/rfc3394 | |
parent | 710229be83cdbc061949c61942896b5af9e134d8 (diff) |
Use registry for streams and MACs. Start updating callers.
Diffstat (limited to 'src/lib/constructs/rfc3394')
-rw-r--r-- | src/lib/constructs/rfc3394/rfc3394.cpp | 22 | ||||
-rw-r--r-- | src/lib/constructs/rfc3394/rfc3394.h | 9 |
2 files changed, 12 insertions, 19 deletions
diff --git a/src/lib/constructs/rfc3394/rfc3394.cpp b/src/lib/constructs/rfc3394/rfc3394.cpp index ee1cc1dd8..6c8b62219 100644 --- a/src/lib/constructs/rfc3394/rfc3394.cpp +++ b/src/lib/constructs/rfc3394/rfc3394.cpp @@ -6,7 +6,7 @@ */ #include <botan/rfc3394.h> -#include <botan/algo_factory.h> +#include <botan/algo_registry.h> #include <botan/block_cipher.h> #include <botan/loadstor.h> #include <botan/exceptn.h> @@ -16,15 +16,15 @@ namespace Botan { namespace { -BlockCipher* make_aes(size_t keylength, - Algorithm_Factory& af) +BlockCipher* make_aes(size_t keylength) { + auto& block_ciphers = Algo_Registry<BlockCipher>::global_registry(); if(keylength == 16) - return af.make_block_cipher("AES-128"); + return block_ciphers.make("AES-128"); else if(keylength == 24) - return af.make_block_cipher("AES-192"); + return block_ciphers.make("AES-192"); else if(keylength == 32) - return af.make_block_cipher("AES-256"); + return block_ciphers.make("AES-256"); else throw std::invalid_argument("Bad KEK length for NIST keywrap"); } @@ -32,13 +32,12 @@ BlockCipher* make_aes(size_t keylength, } secure_vector<byte> rfc3394_keywrap(const secure_vector<byte>& key, - const SymmetricKey& kek, - Algorithm_Factory& af) + const SymmetricKey& kek) { if(key.size() % 8 != 0) throw std::invalid_argument("Bad input key size for NIST key wrap"); - std::unique_ptr<BlockCipher> aes(make_aes(kek.length(), af)); + std::unique_ptr<BlockCipher> aes(make_aes(kek.length())); aes->set_key(kek); const size_t n = key.size() / 8; @@ -74,13 +73,12 @@ secure_vector<byte> rfc3394_keywrap(const secure_vector<byte>& key, } secure_vector<byte> rfc3394_keyunwrap(const secure_vector<byte>& key, - const SymmetricKey& kek, - Algorithm_Factory& af) + const SymmetricKey& kek) { if(key.size() < 16 || key.size() % 8 != 0) throw std::invalid_argument("Bad input key size for NIST key unwrap"); - std::unique_ptr<BlockCipher> aes(make_aes(kek.length(), af)); + std::unique_ptr<BlockCipher> aes(make_aes(kek.length())); aes->set_key(kek); const size_t n = (key.size() - 8) / 8; diff --git a/src/lib/constructs/rfc3394/rfc3394.h b/src/lib/constructs/rfc3394/rfc3394.h index 9800bbab1..fab6bc3cb 100644 --- a/src/lib/constructs/rfc3394/rfc3394.h +++ b/src/lib/constructs/rfc3394/rfc3394.h @@ -12,20 +12,16 @@ namespace Botan { -class Algorithm_Factory; - /** * Encrypt a key under a key encryption key using the algorithm * described in RFC 3394 * * @param key the plaintext key to encrypt * @param kek the key encryption key -* @param af an algorithm factory * @return key encrypted under kek */ secure_vector<byte> BOTAN_DLL rfc3394_keywrap(const secure_vector<byte>& key, - const SymmetricKey& kek, - Algorithm_Factory& af); + const SymmetricKey& kek); /** * Decrypt a key under a key encryption key using the algorithm @@ -37,8 +33,7 @@ secure_vector<byte> BOTAN_DLL rfc3394_keywrap(const secure_vector<byte>& key, * @return key decrypted under kek */ secure_vector<byte> BOTAN_DLL rfc3394_keyunwrap(const secure_vector<byte>& key, - const SymmetricKey& kek, - Algorithm_Factory& af); + const SymmetricKey& kek); } |