52 const std::string& provider)
54#if defined(BOTAN_HAS_COMMONCRYPTO)
59 if(commoncrypto_cipher)
60 return commoncrypto_cipher;
63 return std::unique_ptr<Cipher_Mode>();
67#if defined(BOTAN_HAS_STREAM_CIPHER)
70 return std::unique_ptr<Cipher_Mode>(
new Stream_Cipher_Mode(sc.release()));
74#if defined(BOTAN_HAS_AEAD_MODES)
77 return std::unique_ptr<Cipher_Mode>(aead.release());
81 if(algo.find(
'/') != std::string::npos)
83 const std::vector<std::string> algo_parts =
split_on(algo,
'/');
84 const std::string cipher_name = algo_parts[0];
88 return std::unique_ptr<Cipher_Mode>();
90 std::ostringstream alg_args;
92 alg_args <<
'(' << cipher_name;
93 for(
size_t i = 1; i < mode_info.size(); ++i)
94 alg_args <<
',' << mode_info[i];
95 for(
size_t i = 2; i < algo_parts.size(); ++i)
96 alg_args <<
',' << algo_parts[i];
99 const std::string mode_name = mode_info[0] + alg_args.str();
103#if defined(BOTAN_HAS_BLOCK_CIPHER)
109 return std::unique_ptr<Cipher_Mode>();
116 return std::unique_ptr<Cipher_Mode>();
119#if defined(BOTAN_HAS_MODE_CBC)
122 const std::string padding = spec.
arg(1,
"PKCS7");
127 return std::unique_ptr<Cipher_Mode>(
new CTS_Encryption(bc.release()));
129 return std::unique_ptr<Cipher_Mode>(
new CTS_Decryption(bc.release()));
133 std::unique_ptr<BlockCipherModePaddingMethod> pad(
get_bc_pad(padding));
138 return std::unique_ptr<Cipher_Mode>(
new CBC_Encryption(bc.release(), pad.release()));
140 return std::unique_ptr<Cipher_Mode>(
new CBC_Decryption(bc.release(), pad.release()));
146#if defined(BOTAN_HAS_MODE_XTS)
150 return std::unique_ptr<Cipher_Mode>(
new XTS_Encryption(bc.release()));
152 return std::unique_ptr<Cipher_Mode>(
new XTS_Decryption(bc.release()));
156#if defined(BOTAN_HAS_MODE_CFB)
159 const size_t feedback_bits = spec.
arg_as_integer(1, 8*bc->block_size());
161 return std::unique_ptr<Cipher_Mode>(
new CFB_Encryption(bc.release(), feedback_bits));
163 return std::unique_ptr<Cipher_Mode>(
new CFB_Decryption(bc.release(), feedback_bits));
169 return std::unique_ptr<Cipher_Mode>();