Botan  2.12.1
Crypto and TLS for C++11
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 
15 
16 namespace Botan {
17 
18 /**
19 * CTR-BE (Counter mode, big-endian)
20 */
22  {
23  public:
24  void cipher(const uint8_t in[], uint8_t out[], size_t length) override;
25 
26  void set_iv(const uint8_t iv[], size_t iv_len) override;
27 
28  size_t default_iv_length() const override;
29 
30  bool valid_iv_length(size_t iv_len) const override;
31 
32  Key_Length_Specification key_spec() const override;
33 
34  std::string name() const override;
35 
36  CTR_BE* clone() const override;
37 
38  void clear() override;
39 
40  /**
41  * @param cipher the block cipher to use
42  */
43  explicit CTR_BE(BlockCipher* cipher);
44 
45  CTR_BE(BlockCipher* cipher, size_t ctr_size);
46 
47  void seek(uint64_t offset) override;
48  private:
49  void key_schedule(const uint8_t key[], size_t key_len) override;
50  void add_counter(const uint64_t counter);
51 
52  std::unique_ptr<BlockCipher> m_cipher;
53 
54  const size_t m_block_size;
55  const size_t m_ctr_size;
56  const size_t m_ctr_blocks;
57 
58  secure_vector<uint8_t> m_counter, m_pad;
59  std::vector<uint8_t> m_iv;
60  size_t m_pad_pos;
61  };
62 
63 }
64 
65 #endif
virtual size_t default_iv_length() const
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
virtual void cipher(const uint8_t in[], uint8_t out[], size_t len)=0
virtual bool valid_iv_length(size_t iv_len) const
virtual std::string name() const =0
virtual void clear()=0
virtual void seek(uint64_t offset)=0
Definition: alg_id.cpp:13
virtual Key_Length_Specification key_spec() const =0
virtual StreamCipher * clone() const =0
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
virtual void set_iv(const uint8_t iv[], size_t iv_len)=0
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:139