8#ifndef BOTAN_STREAM_MODE_H_ 
    9#define BOTAN_STREAM_MODE_H_ 
   11#include <botan/cipher_mode.h> 
   13#include <botan/assert.h> 
   15#if defined(BOTAN_HAS_STREAM_CIPHER) 
   16   #include <botan/stream_cipher.h> 
   21#if defined(BOTAN_HAS_STREAM_CIPHER) 
   23class Stream_Cipher_Mode final : 
public Cipher_Mode {
 
   28      explicit Stream_Cipher_Mode(std::unique_ptr<StreamCipher> cipher) : m_cipher(std::move(cipher)) {}
 
   30      size_t output_length(
size_t input_length)
 const override { 
return input_length; }
 
   32      size_t update_granularity()
 const override { 
return 1; }
 
   34      size_t ideal_granularity()
 const override {
 
   35         const size_t buf_size = m_cipher->buffer_size();
 
   40         return buf_size * (256 / buf_size);
 
   43      size_t minimum_final_size()
 const override { 
return 0; }
 
   45      size_t default_nonce_length()
 const override { 
return 0; }
 
   47      bool valid_nonce_length(
size_t nonce_len)
 const override { 
return m_cipher->valid_iv_length(nonce_len); }
 
   49      Key_Length_Specification key_spec()
 const override { 
return m_cipher->key_spec(); }
 
   51      std::string name()
 const override { 
return m_cipher->name(); }
 
   53      void clear()
 override {
 
   58      void reset()
 override { 
 
   61      bool has_keying_material()
 const override { 
return m_cipher->has_keying_material(); }
 
   64      void start_msg(
const uint8_t nonce[], 
size_t nonce_len)
 override {
 
   66            m_cipher->set_iv(nonce, nonce_len);
 
   70      size_t process_msg(uint8_t buf[], 
size_t sz)
 override {
 
   71         m_cipher->cipher1(buf, sz);
 
   75      void finish_msg(secure_vector<uint8_t>& buf, 
size_t offset)
 override { 
return update(buf, offset); }
 
   77      void key_schedule(std::span<const uint8_t> key)
 override { m_cipher->set_key(key); }
 
   79      std::unique_ptr<StreamCipher> m_cipher;
 
#define BOTAN_ASSERT_NOMSG(expr)