34 static std::unique_ptr<StreamCipher> create(std::string_view algo_spec, std::string_view provider =
"");
43 static std::unique_ptr<StreamCipher> create_or_throw(std::string_view algo_spec, std::string_view provider =
"");
48 static std::vector<std::string> providers(std::string_view algo_spec);
60 void cipher(
const uint8_t in[], uint8_t out[],
size_t len) { cipher_bytes(in, out, len); }
68 void cipher(std::span<const uint8_t> in, std::span<uint8_t> out) {
70 "Output buffer of stream cipher must be at least as long as input buffer");
71 cipher_bytes(in.data(), out.data(), in.size());
91 void write_keystream(std::span<uint8_t> out) { generate_keystream(out.data(), out.size()); }
100 template <concepts::resizable_
byte_buffer T = secure_vector<u
int8_t>>
103 write_keystream(out);
113 void cipher1(uint8_t buf[],
size_t len) { cipher(buf, buf, len); }
120 void cipher1(std::span<uint8_t> buf) { cipher(buf, buf); }
127 void encipher(std::span<uint8_t> inout) { cipher(inout.data(), inout.data(), inout.size()); }
134 void encrypt(std::span<uint8_t> inout) { cipher(inout.data(), inout.data(), inout.size()); }
141 void decrypt(std::span<uint8_t> inout) { cipher(inout.data(), inout.data(), inout.size()); }
171 void set_iv(
const uint8_t iv[],
size_t iv_len) { set_iv_bytes(iv, iv_len); }
178 void set_iv(std::span<const uint8_t> iv) { set_iv_bytes(iv.data(), iv.size()); }
188 virtual size_t default_iv_length()
const;
204 virtual std::unique_ptr<StreamCipher>
new_object()
const = 0;
219 virtual void seek(uint64_t offset) = 0;
225 virtual std::string
provider()
const {
return "base"; }
231 virtual void cipher_bytes(
const uint8_t in[], uint8_t out[],
size_t len) = 0;
236 virtual void generate_keystream(uint8_t out[],
size_t len);