Botan  1.11.15
Public Types | Public Member Functions | Protected Member Functions
Botan::CFB_Mode Class Reference

#include <cfb.h>

Inheritance diagram for Botan::CFB_Mode:
Botan::Cipher_Mode Botan::Keyed_Transform Botan::Transform Botan::CFB_Decryption Botan::CFB_Encryption

List of all members.

Public Types

typedef SCAN_Name Spec

Public Member Functions

virtual bool authenticated () const
void clear () override
size_t default_nonce_length () const override
virtual void finish (secure_vector< byte > &final_block, size_t offset=0)=0
Key_Length_Specification key_spec () const override
size_t minimum_final_size () const override
std::string name () const override
size_t output_length (size_t input_length) const override
virtual std::string provider () const
template<typename Alloc >
void set_key (const std::vector< byte, Alloc > &key)
void set_key (const SymmetricKey &key)
void set_key (const byte key[], size_t length)
template<typename Alloc >
secure_vector< bytestart (const std::vector< byte, Alloc > &nonce)
secure_vector< bytestart (const byte nonce[], size_t nonce_len)
secure_vector< bytestart ()
template<typename Alloc >
secure_vector< bytestart_vec (const std::vector< byte, Alloc > &nonce)
virtual size_t tag_size () const
virtual void update (secure_vector< byte > &blocks, size_t offset=0)=0
size_t update_granularity () const override
bool valid_keylength (size_t length) const
bool valid_nonce_length (size_t n) const override

Protected Member Functions

 CFB_Mode (BlockCipher *cipher, size_t feedback_bits)
const BlockCiphercipher () const
size_t feedback () const
secure_vector< byte > & keystream_buf ()
secure_vector< byte > & shift_register ()

Detailed Description

CFB Mode

Definition at line 20 of file cfb.h.


Member Typedef Documentation

typedef SCAN_Name Botan::Transform::Spec [inherited]

Definition at line 27 of file transform.h.


Constructor & Destructor Documentation

Botan::CFB_Mode::CFB_Mode ( BlockCipher cipher,
size_t  feedback_bits 
) [protected]

Definition at line 16 of file cfb.cpp.

References Botan::BlockCipher::block_size(), feedback(), name(), and Botan::ASN1::to_string().

                                                            :
   m_cipher(cipher),
   m_feedback_bytes(feedback_bits ? feedback_bits / 8 : cipher->block_size())
   {
   if(feedback_bits % 8 || feedback() > cipher->block_size())
      throw std::invalid_argument(name() + ": feedback bits " +
                                  std::to_string(feedback_bits) + " not supported");
   }

Member Function Documentation

virtual bool Botan::Cipher_Mode::authenticated ( ) const [inline, virtual, inherited]

Returns true iff this mode provides authentication as well as confidentiality.

Reimplemented in Botan::AEAD_Mode.

Definition at line 26 of file cipher_mode.h.

{ return false; }
const BlockCipher& Botan::CFB_Mode::cipher ( ) const [inline, protected]
void Botan::CFB_Mode::clear ( ) [override, virtual]

Implements Botan::Transform.

Definition at line 25 of file cfb.cpp.

   {
   m_cipher->clear();
   m_shift_register.clear();
   }
size_t Botan::CFB_Mode::default_nonce_length ( ) const [override, virtual]

Return the default size for a nonce

Implements Botan::Transform.

Definition at line 59 of file cfb.cpp.

References Botan::BlockCipher::block_size(), and cipher().

   {
   return cipher().block_size();
   }
size_t Botan::CFB_Mode::feedback ( ) const [inline, protected]

Definition at line 43 of file cfb.h.

Referenced by CFB_Mode(), name(), Botan::CFB_Encryption::update(), Botan::CFB_Decryption::update(), and update_granularity().

{ return m_feedback_bytes; }
virtual void Botan::Transform::finish ( secure_vector< byte > &  final_block,
size_t  offset = 0 
) [pure virtual, inherited]
Key_Length_Specification Botan::CFB_Mode::key_spec ( ) const [override, virtual]
Returns:
object describing limits on key size

Implements Botan::Keyed_Transform.

Definition at line 54 of file cfb.cpp.

References cipher(), and Botan::SymmetricAlgorithm::key_spec().

   {
   return cipher().key_spec();
   }
secure_vector<byte>& Botan::CFB_Mode::keystream_buf ( ) [inline, protected]

Definition at line 47 of file cfb.h.

Referenced by Botan::CFB_Encryption::update(), and Botan::CFB_Decryption::update().

{ return m_keystream_buf; }
size_t Botan::CFB_Mode::minimum_final_size ( ) const [override, virtual]
Returns:
required minimium size to finalize() - may be any length larger than this.

Implements Botan::Transform.

Definition at line 49 of file cfb.cpp.

   {
   return 0;
   }
std::string Botan::CFB_Mode::name ( ) const [override, virtual]

Implements Botan::Transform.

Definition at line 31 of file cfb.cpp.

References cipher(), feedback(), Botan::SymmetricAlgorithm::name(), and Botan::ASN1::to_string().

Referenced by CFB_Mode().

   {
   if(feedback() == cipher().block_size())
      return cipher().name() + "/CFB";
   else
      return cipher().name() + "/CFB(" + std::to_string(feedback()*8) + ")";
   }
size_t Botan::CFB_Mode::output_length ( size_t  input_length) const [override, virtual]

Returns the size of the output if this transform is used to process a message with input_length bytes. Will throw if unable to give a precise answer.

Implements Botan::Transform.

Definition at line 39 of file cfb.cpp.

   {
   return input_length;
   }
virtual std::string Botan::Transform::provider ( ) const [inline, virtual, inherited]

Return some short name describing the provider of this tranformation. Useful in cases where multiple implementations are available (eg, different implementations of AES). Default "core" is used for the 'standard' implementation included in the library.

Definition at line 120 of file transform.h.

{ return "core"; }
template<typename Alloc >
void Botan::Keyed_Transform::set_key ( const std::vector< byte, Alloc > &  key) [inline, inherited]

Definition at line 148 of file transform.h.

Referenced by botan_cipher_set_key().

         {
         set_key(&key[0], key.size());
         }
void Botan::Keyed_Transform::set_key ( const SymmetricKey key) [inline, inherited]

Definition at line 153 of file transform.h.

References Botan::OctetString::begin(), and Botan::OctetString::length().

         {
         set_key(key.begin(), key.length());
         }
void Botan::Keyed_Transform::set_key ( const byte  key[],
size_t  length 
) [inline, inherited]

Set the symmetric key of this transform

Parameters:
keycontains the key material
lengthin bytes of key param

Definition at line 163 of file transform.h.

         {
         if(!valid_keylength(length))
            throw Invalid_Key_Length(name(), length);
         key_schedule(key, length);
         }
secure_vector<byte>& Botan::CFB_Mode::shift_register ( ) [inline, protected]

Definition at line 45 of file cfb.h.

Referenced by Botan::CFB_Encryption::update(), and Botan::CFB_Decryption::update().

{ return m_shift_register; }
template<typename Alloc >
secure_vector<byte> Botan::Transform::start ( const std::vector< byte, Alloc > &  nonce) [inline, inherited]

Begin processing a message.

Parameters:
noncethe per message nonce

Definition at line 34 of file transform.h.

Referenced by botan_cipher_start().

         {
         return start(&nonce[0], nonce.size());
         }
secure_vector<byte> Botan::Transform::start ( const byte  nonce[],
size_t  nonce_len 
) [inline, inherited]

Begin processing a message.

Parameters:
noncethe per message nonce
nonce_lenlength of nonce

Definition at line 55 of file transform.h.

         {
         return start_raw(nonce, nonce_len);
         }
secure_vector<byte> Botan::Transform::start ( ) [inline, inherited]

Begin processing a message.

Definition at line 63 of file transform.h.

         {
         return start_raw(nullptr, 0);
         }
template<typename Alloc >
secure_vector<byte> Botan::Transform::start_vec ( const std::vector< byte, Alloc > &  nonce) [inline, inherited]

Begin processing a message.

Parameters:
noncethe per message nonce

Definition at line 45 of file transform.h.

         {
         return start(&nonce[0], nonce.size());
         }
virtual size_t Botan::Cipher_Mode::tag_size ( ) const [inline, virtual, inherited]

Return the size of the authentication tag used (in bytes)

Reimplemented in Botan::SIV_Mode, Botan::CCM_Mode, Botan::OCB_Mode, Botan::ChaCha20Poly1305_Mode, Botan::GCM_Mode, and Botan::EAX_Mode.

Definition at line 31 of file cipher_mode.h.

Referenced by botan_cipher_get_tag_length().

{ return 0; }
virtual void Botan::Transform::update ( secure_vector< byte > &  blocks,
size_t  offset = 0 
) [pure virtual, inherited]
size_t Botan::CFB_Mode::update_granularity ( ) const [override, virtual]
Returns:
size of required blocks to update

Implements Botan::Transform.

Definition at line 44 of file cfb.cpp.

References feedback().

   {
   return feedback();
   }
bool Botan::Keyed_Transform::valid_keylength ( size_t  length) const [inline, inherited]

Check whether a given key length is valid for this algorithm.

Parameters:
lengththe key length to be checked.
Returns:
true if the key length is valid.

Definition at line 142 of file transform.h.

References Botan::Key_Length_Specification::valid_keylength().

         {
         return key_spec().valid_keylength(length);
         }
bool Botan::CFB_Mode::valid_nonce_length ( size_t  nonce_len) const [override, virtual]

Return true iff nonce_len is a valid length for the nonce

Implements Botan::Transform.

Definition at line 64 of file cfb.cpp.

References cipher().

   {
   return (n == cipher().block_size());
   }

The documentation for this class was generated from the following files: