Botan  2.6.0
Crypto and TLS for C++11
key_filt.cpp
Go to the documentation of this file.
1 /*
2 * (C) 2015 Jack Lloyd
3 *
4 * Botan is released under the Simplified BSD License (see license.txt)
5 */
6 
7 #include <botan/key_filt.h>
8 #include <botan/cipher_filter.h>
9 
10 namespace Botan {
11 
12 Keyed_Filter* get_cipher(const std::string& algo_spec,
13  Cipher_Dir direction)
14  {
15  std::unique_ptr<Cipher_Mode> c(Cipher_Mode::create_or_throw(algo_spec, direction));
16  return new Cipher_Mode_Filter(c.release());
17  }
18 
19 Keyed_Filter* get_cipher(const std::string& algo_spec,
20  const SymmetricKey& key,
21  const InitializationVector& iv,
22  Cipher_Dir direction)
23  {
24  Keyed_Filter* cipher = get_cipher(algo_spec, key, direction);
25  if(iv.length())
26  cipher->set_iv(iv);
27  return cipher;
28  }
29 
30 Keyed_Filter* get_cipher(const std::string& algo_spec,
31  const SymmetricKey& key,
32  Cipher_Dir direction)
33  {
34  Keyed_Filter* cipher = get_cipher(algo_spec, direction);
35  cipher->set_key(key);
36  return cipher;
37  }
38 
39 }
virtual void set_iv(const InitializationVector &iv)
Definition: basefilt.cpp:13
virtual void set_key(const SymmetricKey &key)=0
Definition: alg_id.cpp:13
size_t length() const
Definition: symkey.h:25
Keyed_Filter * get_cipher(const std::string &algo_spec, Cipher_Dir direction)
Definition: key_filt.cpp:12
Cipher_Dir
Definition: cipher_mode.h:24
static std::unique_ptr< Cipher_Mode > create_or_throw(const std::string &algo, Cipher_Dir direction, const std::string &provider="")
Definition: cipher_mode.cpp:40