Botan 3.6.1
Crypto and TLS for C&
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
13namespace Botan {
14
15/**
16* DJB's Salsa20 (and XSalsa20)
17*/
18class Salsa20 final : public StreamCipher {
19 public:
20 bool valid_iv_length(size_t iv_len) const override;
21 size_t default_iv_length() const override;
22 Key_Length_Specification key_spec() const override;
23 void clear() override;
24 std::string name() const override;
25 std::unique_ptr<StreamCipher> new_object() const override;
26 bool has_keying_material() const override;
27 void seek(uint64_t offset) override;
28
29 size_t buffer_size() const override;
30
31 // For internal use only
32 static void salsa_core(uint8_t output[64], const uint32_t input[16], size_t rounds);
33
34 // For internal use only
35 static void hsalsa20(uint32_t output[8], const uint32_t input[16]);
36
37 protected:
38 void cipher_bytes(const uint8_t in[], uint8_t out[], size_t length) override;
39 void set_iv_bytes(const uint8_t iv[], size_t iv_len) override;
40
41 private:
42 void key_schedule(std::span<const uint8_t> key) override;
43
44 void initialize_state();
45
49 size_t m_position = 0;
50};
51
52} // namespace Botan
53
54#endif
void seek(uint64_t offset) override
Definition salsa20.cpp:267
bool has_keying_material() const override
Definition salsa20.cpp:164
void clear() override
Definition salsa20.cpp:260
size_t buffer_size() const override
Definition salsa20.cpp:168
void set_iv_bytes(const uint8_t iv[], size_t iv_len) override
Definition salsa20.cpp:188
void cipher_bytes(const uint8_t in[], uint8_t out[], size_t length) override
Definition salsa20.cpp:102
static void hsalsa20(uint32_t output[8], const uint32_t input[16])
Definition salsa20.cpp:31
bool valid_iv_length(size_t iv_len) const override
Definition salsa20.cpp:237
size_t default_iv_length() const override
Definition salsa20.cpp:241
static void salsa_core(uint8_t output[64], const uint32_t input[16], size_t rounds)
Definition salsa20.cpp:62
std::unique_ptr< StreamCipher > new_object() const override
Definition salsa20.cpp:249
std::string name() const override
Definition salsa20.cpp:253
Key_Length_Specification key_spec() const override
Definition salsa20.cpp:245
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61