Coverage Report

Created: 2023-06-07 07:00

/src/botan/build/include/botan/internal/rc4.h
Line
Count
Source (jump to first uncovered line)
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
14
namespace Botan {
15
16
/**
17
* RC4 stream cipher
18
*/
19
class 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 has_keying_material() const override;
31
32
      size_t buffer_size() const override;
33
34
      /**
35
      * @param skip skip this many initial bytes in the keystream
36
      */
37
      explicit RC4(size_t skip = 0);
38
39
0
      ~RC4() { clear(); }
40
41
   private:
42
      void key_schedule(const uint8_t[], size_t) override;
43
      void cipher_bytes(const uint8_t in[], uint8_t out[], size_t length) override;
44
      void set_iv_bytes(const uint8_t iv[], size_t iv_len) override;
45
      void generate();
46
47
      const size_t m_SKIP;
48
      uint8_t m_X = 0;
49
      uint8_t m_Y = 0;
50
      secure_vector<uint8_t> m_state;
51
      secure_vector<uint8_t> m_buffer;
52
      size_t m_position = 0;
53
};
54
55
}  // namespace Botan
56
57
#endif