diff options
author | Jack Lloyd <[email protected]> | 2018-04-07 13:34:52 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-04-07 13:34:52 -0400 |
commit | 3657639abf776e78b35a961d646dd410a7fce492 (patch) | |
tree | cf969470c7299941f420ac1fc3cde1ba39ab7eb7 /src/tests | |
parent | 7df69ab04ba5f2944ac3135b444c3b103aaa3f80 (diff) |
Add RAII versions of get_cipher_mode and get_aead
See also #1526
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test_aead.cpp | 8 | ||||
-rw-r--r-- | src/tests/test_dlies.cpp | 4 | ||||
-rw-r--r-- | src/tests/test_filters.cpp | 4 | ||||
-rw-r--r-- | src/tests/test_modes.cpp | 16 |
4 files changed, 16 insertions, 16 deletions
diff --git a/src/tests/test_aead.cpp b/src/tests/test_aead.cpp index 13d6ee320..afd169396 100644 --- a/src/tests/test_aead.cpp +++ b/src/tests/test_aead.cpp @@ -28,7 +28,7 @@ class AEAD_Tests final : public Text_Based_Test { Test::Result result(algo); - std::unique_ptr<Botan::AEAD_Mode> enc(Botan::get_aead(algo, Botan::ENCRYPTION)); + std::unique_ptr<Botan::AEAD_Mode> enc(Botan::AEAD_Mode::create(algo, Botan::ENCRYPTION)); result.test_eq("AEAD encrypt output_length is correct", enc->output_length(input.size()), expected.size()); @@ -142,7 +142,7 @@ class AEAD_Tests final : public Text_Based_Test { Test::Result result(algo); - std::unique_ptr<Botan::AEAD_Mode> dec(Botan::get_aead(algo, Botan::DECRYPTION)); + std::unique_ptr<Botan::AEAD_Mode> dec(Botan::AEAD_Mode::create(algo, Botan::DECRYPTION)); result.test_eq("AEAD decrypt output_length is correct", dec->output_length(input.size()), expected.size()); @@ -327,8 +327,8 @@ class AEAD_Tests final : public Text_Based_Test Test::Result result(algo); - std::unique_ptr<Botan::AEAD_Mode> enc(Botan::get_aead(algo, Botan::ENCRYPTION)); - std::unique_ptr<Botan::AEAD_Mode> dec(Botan::get_aead(algo, Botan::DECRYPTION)); + std::unique_ptr<Botan::AEAD_Mode> enc(Botan::AEAD_Mode::create(algo, Botan::ENCRYPTION)); + std::unique_ptr<Botan::AEAD_Mode> dec(Botan::AEAD_Mode::create(algo, Botan::DECRYPTION)); if(!enc || !dec) { diff --git a/src/tests/test_dlies.cpp b/src/tests/test_dlies.cpp index 4c9708052..d3fb76498 100644 --- a/src/tests/test_dlies.cpp +++ b/src/tests/test_dlies.cpp @@ -64,8 +64,8 @@ class DLIES_KAT_Tests final : public Text_Based_Test if(cipher_algo != "XOR") { - enc.reset(Botan::get_cipher_mode(cipher_algo, Botan::ENCRYPTION)); - dec.reset(Botan::get_cipher_mode(cipher_algo, Botan::DECRYPTION)); + enc = Botan::Cipher_Mode::create(cipher_algo, Botan::ENCRYPTION); + dec = Botan::Cipher_Mode::create(cipher_algo, Botan::DECRYPTION); if(!enc || !dec) { diff --git a/src/tests/test_filters.cpp b/src/tests/test_filters.cpp index c1bcf3603..71bcae14a 100644 --- a/src/tests/test_filters.cpp +++ b/src/tests/test_filters.cpp @@ -423,7 +423,7 @@ class Filter_Tests final : public Test #if defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_MODE_CBC) && defined(BOTAN_HAS_CIPHER_MODE_PADDING) Botan::Cipher_Mode_Filter* cipher = - new Botan::Cipher_Mode_Filter(Botan::get_cipher_mode("AES-128/CBC/PKCS7", Botan::ENCRYPTION)); + new Botan::Cipher_Mode_Filter(Botan::Cipher_Mode::create("AES-128/CBC/PKCS7", Botan::ENCRYPTION)); result.test_eq("Cipher filter name", cipher->name(), "AES-128/CBC/PKCS7"); @@ -458,7 +458,7 @@ class Filter_Tests final : public Test result.test_eq("Ciphertext3", ciphertext3, "1241B9976F73051BCF809525D6E86C25"); Botan::Cipher_Mode_Filter* dec_cipher = - new Botan::Cipher_Mode_Filter(Botan::get_cipher_mode("AES-128/CBC/PKCS7", Botan::DECRYPTION)); + new Botan::Cipher_Mode_Filter(Botan::Cipher_Mode::create("AES-128/CBC/PKCS7", Botan::DECRYPTION)); pipe.append(dec_cipher); dec_cipher->set_key(Botan::SymmetricKey("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); dec_cipher->set_iv(Botan::InitializationVector("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB")); diff --git a/src/tests/test_modes.cpp b/src/tests/test_modes.cpp index 89b201873..6cdcd73b0 100644 --- a/src/tests/test_modes.cpp +++ b/src/tests/test_modes.cpp @@ -45,9 +45,9 @@ class Cipher_Mode_Tests final : public Text_Based_Test for(auto&& provider_ask : providers) { - std::unique_ptr<Botan::Cipher_Mode> enc(Botan::get_cipher_mode( + std::unique_ptr<Botan::Cipher_Mode> enc(Botan::Cipher_Mode::create( algo, Botan::ENCRYPTION, provider_ask)); - std::unique_ptr<Botan::Cipher_Mode> dec(Botan::get_cipher_mode( + std::unique_ptr<Botan::Cipher_Mode> dec(Botan::Cipher_Mode::create( algo, Botan::DECRYPTION, provider_ask)); if(!enc || !dec) @@ -198,9 +198,9 @@ class Cipher_Mode_IV_Carry_Tests final : public Test #if defined(BOTAN_HAS_MODE_CBC) && defined(BOTAN_HAS_AES) std::unique_ptr<Botan::Cipher_Mode> enc( - Botan::get_cipher_mode("AES-128/CBC/PKCS7", Botan::ENCRYPTION)); + Botan::Cipher_Mode::create("AES-128/CBC/PKCS7", Botan::ENCRYPTION)); std::unique_ptr<Botan::Cipher_Mode> dec( - Botan::get_cipher_mode("AES-128/CBC/PKCS7", Botan::DECRYPTION)); + Botan::Cipher_Mode::create("AES-128/CBC/PKCS7", Botan::DECRYPTION)); const std::vector<uint8_t> key(16, 0xAA); const std::vector<uint8_t> iv(16, 0xAA); @@ -251,9 +251,9 @@ class Cipher_Mode_IV_Carry_Tests final : public Test Test::Result result("CFB IV carry"); #if defined(BOTAN_HAS_MODE_CFB) && defined(BOTAN_HAS_AES) std::unique_ptr<Botan::Cipher_Mode> enc( - Botan::get_cipher_mode("AES-128/CFB(8)", Botan::ENCRYPTION)); + Botan::Cipher_Mode::create("AES-128/CFB(8)", Botan::ENCRYPTION)); std::unique_ptr<Botan::Cipher_Mode> dec( - Botan::get_cipher_mode("AES-128/CFB(8)", Botan::DECRYPTION)); + Botan::Cipher_Mode::create("AES-128/CFB(8)", Botan::DECRYPTION)); const std::vector<uint8_t> key(16, 0xAA); const std::vector<uint8_t> iv(16, 0xAB); @@ -300,9 +300,9 @@ class Cipher_Mode_IV_Carry_Tests final : public Test #if defined(BOTAN_HAS_CTR_BE) && defined(BOTAN_HAS_AES) std::unique_ptr<Botan::Cipher_Mode> enc( - Botan::get_cipher_mode("AES-128/CTR-BE", Botan::ENCRYPTION)); + Botan::Cipher_Mode::create("AES-128/CTR-BE", Botan::ENCRYPTION)); std::unique_ptr<Botan::Cipher_Mode> dec( - Botan::get_cipher_mode("AES-128/CTR-BE", Botan::DECRYPTION)); + Botan::Cipher_Mode::create("AES-128/CTR-BE", Botan::DECRYPTION)); const std::vector<uint8_t> key = Botan::hex_decode("2B7E151628AED2A6ABF7158809CF4F3C"); |