Botan 1.10.17
ctr.h
Go to the documentation of this file.
1/*
2* CTR-BE Mode
3* (C) 1999-2007 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
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
14namespace Botan {
15
16/**
17* CTR-BE (Counter mode, big-endian)
18*/
19class BOTAN_DLL CTR_BE : public StreamCipher
20 {
21 public:
22 void cipher(const byte in[], byte out[], size_t length);
23
24 void set_iv(const byte iv[], size_t iv_len);
25
26 bool valid_iv_length(size_t iv_len) const
27 { return (iv_len <= permutation->block_size()); }
28
30 {
31 return permutation->key_spec();
32 }
33
34 std::string name() const;
35
36 CTR_BE* clone() const
37 { return new CTR_BE(permutation->clone()); }
38
39 void clear();
40
41 /**
42 * @param cipher the underlying block cipher to use
43 */
44 CTR_BE(BlockCipher* cipher);
45 ~CTR_BE();
46 private:
47 void key_schedule(const byte key[], size_t key_len);
48 void increment_counter();
49
50 BlockCipher* permutation;
51 SecureVector<byte> counter, buffer;
52 size_t position;
53 };
54
55}
56
57#endif
Key_Length_Specification key_spec() const
Definition ctr.h:29
bool valid_iv_length(size_t iv_len) const
Definition ctr.h:26
void cipher(const byte in[], byte out[], size_t length)
Definition ctr.cpp:66
void set_iv(const byte iv[], size_t iv_len)
Definition ctr.cpp:83
CTR_BE(BlockCipher *cipher)
Definition ctr.cpp:17
CTR_BE * clone() const
Definition ctr.h:36