Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

ctr.h
Go to the documentation of this file.
1 /*
2 * CTR-BE Mode
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_CTR_BE_H__
9 #define BOTAN_CTR_BE_H__
10
11 #include <botan/block_cipher.h>
12 #include <botan/stream_cipher.h>
13
14 namespace Botan {
15
16 /**
17 * CTR-BE (Counter mode, big-endian)
18 */
19 class BOTAN_DLL CTR_BE final : public StreamCipher
20 {
21 public:
22 void cipher(const uint8_t in[], uint8_t out[], size_t length) override;
23
24 void set_iv(const uint8_t iv[], size_t iv_len) override;
25
26 bool valid_iv_length(size_t iv_len) const override
27 { return (iv_len <= m_cipher->block_size()); }
28
29 Key_Length_Specification key_spec() const override
30 {
31 return m_cipher->key_spec();
32 }
33
34 std::string name() const override;
35
36 CTR_BE* clone() const override
37 { return new CTR_BE(m_cipher->clone()); }
38
39 void clear() override;
40
41 /**
42 * @param cipher the block cipher to use
43 */
44 explicit CTR_BE(BlockCipher* cipher);
45
46 CTR_BE(BlockCipher* cipher, size_t ctr_size);
47
48 void seek(uint64_t offset) override;
49 private:
50 void key_schedule(const uint8_t key[], size_t key_len) override;
51 void increment_counter();
52
53 std::unique_ptr<BlockCipher> m_cipher;
54 secure_vector<uint8_t> m_counter, m_pad;
55 size_t m_ctr_size;
56 size_t m_pad_pos;
57 };
58
59 }
60
61 #endif
Botan::Key_Length_Specification
Definition: key_spec.h:18
Botan::CTR_BE
Definition: ctr.h:19
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::StreamCipher
Definition: stream_cipher.h:19
Botan
Definition: alg_id.cpp:13
Botan::CTR_BE::key_spec
Key_Length_Specification key_spec() const override
Definition: ctr.h:29
Botan::CTR_BE::clone
CTR_BE * clone() const override
Definition: ctr.h:36
Botan::CTR_BE::valid_iv_length
bool valid_iv_length(size_t iv_len) const override
Definition: ctr.h:26
Botan::BlockCipher
Definition: block_cipher.h:19