Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

salsa20.h
Go to the documentation of this file.
1 /*
2 * Salsa20 / XSalsa20
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
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 final : public StreamCipher
19 {
20 public:
21 void cipher(const uint8_t in[], uint8_t out[], size_t length) override;
22
23 void set_iv(const uint8_t iv[], size_t iv_len) override;
24
25 bool valid_iv_length(size_t iv_len) const override
26 { return (iv_len == 0 || iv_len == 8 || iv_len == 24); }
27
28 Key_Length_Specification key_spec() const override
29 {
30 return Key_Length_Specification(16, 32, 16);
31 }
32
33 void clear() override;
34 std::string name() const override;
35 StreamCipher* clone() const override { return new Salsa20; }
36
37 void seek(uint64_t offset) override;
38 private:
39 void key_schedule(const uint8_t key[], size_t key_len) override;
40
41 secure_vector<uint32_t> m_state;
42 secure_vector<uint8_t> m_buffer;
43 size_t m_position = 0;
44 };
45
46 }
47
48 #endif
Botan::Key_Length_Specification
Definition: key_spec.h:18
Botan::Salsa20::clone
StreamCipher * clone() const override
Definition: salsa20.h:35
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::Salsa20
Definition: salsa20.h:18
Botan::Salsa20::valid_iv_length
bool valid_iv_length(size_t iv_len) const override
Definition: salsa20.h:25
Botan::Salsa20::key_spec
Key_Length_Specification key_spec() const override
Definition: salsa20.h:28