Botan
2.1.0
Crypto and TLS for C++11
Main Page
Namespaces
Classes
Files
File List
File Members
src
lib
stream
shake_cipher
shake_cipher.h
Go to the documentation of this file.
1
/*
2
* SHAKE-128 as a stream cipher
3
* (C) 2016 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_SHAKE128_CIPHER_H__
9
#define BOTAN_SHAKE128_CIPHER_H__
10
11
#include <botan/stream_cipher.h>
12
#include <botan/secmem.h>
13
14
namespace
Botan
{
15
16
/**
17
* SHAKE-128 XOF presented as a stream cipher
18
*/
19
class
BOTAN_DLL
SHAKE_128_Cipher
final :
public
StreamCipher
20
{
21
public
:
22
SHAKE_128_Cipher
();
23
24
/**
25
* Produce more XOF output
26
*/
27
void
cipher(
const
uint8_t in[], uint8_t out[],
size_t
length)
override
;
28
29
/**
30
* Seeking is not supported, this function will throw
31
*/
32
void
seek(uint64_t offset)
override
;
33
34
/**
35
* IV not supported, this function will throw unless iv_len == 0
36
*/
37
void
set_iv(
const
uint8_t iv[],
size_t
iv_len)
override
;
38
39
bool
valid_iv_length
(
size_t
iv_len)
const override
{
return
(iv_len == 0); }
40
41
/**
42
* In principle SHAKE can accept arbitrary length inputs, but this
43
* does not seem required for a stream cipher.
44
*/
45
Key_Length_Specification
key_spec
()
const override
46
{
47
return
Key_Length_Specification
(16, 160, 8);
48
}
49
50
void
clear()
override
;
51
std::string
name
()
const override
{
return
"SHAKE-128"
; }
52
StreamCipher
*
clone
()
const override
{
return
new
SHAKE_128_Cipher
; }
53
54
private
:
55
void
key_schedule(
const
uint8_t key[],
size_t
key_len)
override
;
56
57
secure_vector<uint64_t>
m_state;
// internal state
58
secure_vector<uint8_t>
m_buffer;
// ciphertext buffer
59
size_t
m_buf_pos;
// position in m_buffer
60
};
61
62
}
63
64
#endif
Botan::SHAKE_128_Cipher::key_spec
Key_Length_Specification key_spec() const override
Definition:
shake_cipher.h:45
Botan::Key_Length_Specification
Definition:
key_spec.h:18
Botan::SHAKE_128_Cipher::valid_iv_length
bool valid_iv_length(size_t iv_len) const override
Definition:
shake_cipher.h:39
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition:
secmem.h:121
Botan::SHAKE_128_Cipher::clone
StreamCipher * clone() const override
Definition:
shake_cipher.h:52
Botan::StreamCipher
Definition:
stream_cipher.h:19
Botan
Definition:
alg_id.cpp:13
Botan::SHAKE_128_Cipher
Definition:
shake_cipher.h:19
Botan::SHAKE_128_Cipher::name
std::string name() const override
Definition:
shake_cipher.h:51
Generated on Fri Aug 4 2017 19:29:39 for Botan by
1.8.9.1