Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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(get_cipher_mode(algo_spec, direction));
16 if(c)
17 return new Cipher_Mode_Filter(c.release());
18 throw Algorithm_Not_Found(algo_spec);
19 }
20
21 Keyed_Filter* get_cipher(const std::string& algo_spec,
22 const SymmetricKey& key,
23 const InitializationVector& iv,
24 Cipher_Dir direction)
25 {
26 Keyed_Filter* cipher = get_cipher(algo_spec, key, direction);
27 if(iv.length())
28 cipher->set_iv(iv);
29 return cipher;
30 }
31
32 Keyed_Filter* get_cipher(const std::string& algo_spec,
33 const SymmetricKey& key,
34 Cipher_Dir direction)
35 {
36 Keyed_Filter* cipher = get_cipher(algo_spec, direction);
37 cipher->set_key(key);
38 return cipher;
39 }
40
41 }
Botan::OctetString
Definition: symkey.h:19
Botan::Keyed_Filter
Definition: key_filt.h:21
Botan::Cipher_Mode_Filter
Definition: cipher_filter.h:20
Botan::get_cipher_mode
Cipher_Mode * get_cipher_mode(const std::string &algo, Cipher_Dir direction)
Definition: cipher_mode.cpp:39
Botan::Keyed_Filter::set_iv
virtual void set_iv(const InitializationVector &iv)
Definition: basefilt.cpp:13
Botan::OctetString::length
size_t length() const
Definition: symkey.h:25
Botan::Keyed_Filter::set_key
virtual void set_key(const SymmetricKey &key)=0
Botan
Definition: alg_id.cpp:13
Botan::Cipher_Dir
Cipher_Dir
Definition: cipher_mode.h:212
Botan::Algorithm_Not_Found
Definition: exceptn.h:140
Botan::get_cipher
Keyed_Filter * get_cipher(const std::string &algo_spec, Cipher_Dir direction)
Definition: key_filt.cpp:12