Botan 3.13.0
Crypto and TLS for C&
rc4.h
Go to the documentation of this file.
1/*
2* RC4
3* (C) 1999-2008 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_RC4_H_
9#define BOTAN_RC4_H_
10
11#include <botan/stream_cipher.h>
12#include <botan/types.h>
13
14namespace Botan {
15
16/**
17* RC4 stream cipher
18*/
19class RC4 final : public StreamCipher {
20 public:
21 void clear() override;
22 std::string name() const override;
23
24 std::unique_ptr<StreamCipher> new_object() const override;
25
26 Key_Length_Specification key_spec() const override;
27
28 void seek(uint64_t offset) override;
29
30 bool supports_seek() const override { return false; }
31
32 std::optional<uint64_t> remaining_keystream_bytes() const override { return {}; }
33
34 bool has_keying_material() const override;
35
36 size_t buffer_size() const override;
37
38 /**
39 * @param skip skip this many initial bytes in the keystream
40 */
41 explicit RC4(size_t skip = 0);
42
43 private:
44 void key_schedule(std::span<const uint8_t> key) override;
45 void cipher_bytes(const uint8_t in[], uint8_t out[], size_t length) override;
46 void set_iv_bytes(const uint8_t iv[], size_t iv_len) override;
47 void generate();
48
49 const size_t m_SKIP;
50 uint8_t m_X = 0;
51 uint8_t m_Y = 0;
54 size_t m_position = 0;
55};
56
57} // namespace Botan
58
59#endif
Key_Length_Specification key_spec() const override
Definition rc4.cpp:40
bool supports_seek() const override
Definition rc4.h:30
std::string name() const override
Definition rc4.cpp:119
std::unique_ptr< StreamCipher > new_object() const override
Definition rc4.cpp:32
void clear() override
Definition rc4.cpp:132
RC4(size_t skip=0)
Definition rc4.cpp:141
size_t buffer_size() const override
Definition rc4.cpp:36
void seek(uint64_t offset) override
Definition rc4.cpp:145
std::optional< uint64_t > remaining_keystream_bytes() const override
Definition rc4.h:32
bool has_keying_material() const override
Definition rc4.cpp:87
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128