Botan 1.10.17

salsa20.h
Go to the documentation of this file.
1 /*
2 * Salsa20 / XSalsa20
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_SALSA20_H__
9 #define BOTAN_SALSA20_H__
10
11 #include <botan/stream_cipher.h>
12
13 namespace Botan {
14
15 /**
16 * DJB's Salsa20 (and XSalsa20)
17 */
18 class BOTAN_DLL Salsa20 : public StreamCipher
19 {
20 public:
21 void cipher(const byte in[], byte out[], size_t length);
22
23 void set_iv(const byte iv[], size_t iv_len);
24
25 bool valid_iv_length(size_t iv_len) const
26 { return (iv_len == 8 || iv_len == 24); }
27
28 Key_Length_Specification key_spec() const
29 {
30 return Key_Length_Specification(16, 32, 16);
31 }
32
33 void clear();
34 std::string name() const;
35 StreamCipher* clone() const { return new Salsa20; }
36
37 Salsa20() : state(16), buffer(64), position(0) {}
38 private:
39 void key_schedule(const byte key[], size_t key_len);
40
41 SecureVector<u32bit> state;
42 SecureVector<byte> buffer;
43 size_t position;
44 };
45
46 }
47
48 #endif
Botan::Key_Length_Specification
Definition: key_spec.h:18
Botan::Salsa20::clone
StreamCipher * clone() const
Definition: salsa20.h:35
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::StreamCipher
Definition: stream_cipher.h:18
Botan::Salsa20::valid_iv_length
bool valid_iv_length(size_t iv_len) const
Definition: salsa20.h:25
Botan
Definition: algo_base.h:14
Botan::Salsa20
Definition: salsa20.h:18
Botan::SecureVector< u32bit >
Botan::Salsa20::key_spec
Key_Length_Specification key_spec() const
Definition: salsa20.h:28
Botan::Salsa20::Salsa20
Salsa20()
Definition: salsa20.h:37