8#ifndef BOTAN_STREAM_MODE_H_
9#define BOTAN_STREAM_MODE_H_
11#include <botan/cipher_mode.h>
13#if defined(BOTAN_HAS_STREAM_CIPHER)
14 #include <botan/stream_cipher.h>
21#if defined(BOTAN_HAS_STREAM_CIPHER)
29 explicit Stream_Cipher_Mode(StreamCipher* cipher) : m_cipher(cipher) {}
31 size_t process(uint8_t buf[],
size_t sz)
override
33 m_cipher->cipher1(buf, sz);
37 void finish(secure_vector<uint8_t>& buf,
size_t offset)
override
38 {
return update(buf, offset); }
40 size_t output_length(
size_t input_length)
const override {
return input_length; }
42 size_t update_granularity()
const override {
return 1; }
44 size_t minimum_final_size()
const override {
return 0; }
46 size_t default_nonce_length()
const override {
return 0; }
48 bool valid_nonce_length(
size_t nonce_len)
const override
49 {
return m_cipher->valid_iv_length(nonce_len); }
51 Key_Length_Specification key_spec()
const override {
return m_cipher->key_spec(); }
53 std::string
name()
const override {
return m_cipher->name(); }
61 void reset()
override { }
64 void start_msg(
const uint8_t nonce[],
size_t nonce_len)
override
68 m_cipher->set_iv(nonce, nonce_len);
72 void key_schedule(
const uint8_t key[],
size_t length)
override
74 m_cipher->set_key(key, length);
77 std::unique_ptr<StreamCipher> m_cipher;
int(* update)(CTX *, const void *, CC_LONG len)
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)