Botan  1.11.15
Public Types | Public Member Functions
Botan::StreamCipher Class Reference

#include <stream_cipher.h>

Inheritance diagram for Botan::StreamCipher:
Botan::SymmetricAlgorithm Botan::ChaCha Botan::CTR_BE Botan::OFB Botan::RC4 Botan::Salsa20

List of all members.

Public Types

typedef SCAN_Name Spec

Public Member Functions

virtual void cipher (const byte in[], byte out[], size_t len)=0
void cipher1 (byte buf[], size_t len)
virtual void clear ()=0
virtual StreamCipherclone () const =0
template<typename Alloc >
void decrypt (std::vector< byte, Alloc > &inout)
template<typename Alloc >
void encipher (std::vector< byte, Alloc > &inout)
template<typename Alloc >
void encrypt (std::vector< byte, Alloc > &inout)
virtual Key_Length_Specification key_spec () const =0
size_t maximum_keylength () const
size_t minimum_keylength () const
virtual std::string name () const =0
virtual void set_iv (const byte[], size_t iv_len)
void set_key (const SymmetricKey &key)
template<typename Alloc >
void set_key (const std::vector< byte, Alloc > &key)
void set_key (const byte key[], size_t length)
virtual bool valid_iv_length (size_t iv_len) const
bool valid_keylength (size_t length) const

Detailed Description

Base class for all stream ciphers

Definition at line 20 of file stream_cipher.h.


Member Typedef Documentation

Definition at line 73 of file stream_cipher.h.


Member Function Documentation

virtual void Botan::StreamCipher::cipher ( const byte  in[],
byte  out[],
size_t  len 
) [pure virtual]

Encrypt or decrypt a message

Parameters:
inthe plaintext
outthe byte array to hold the output, i.e. the ciphertext
lenthe length of both in and out in bytes

Implemented in Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::ChaCha, and Botan::Salsa20.

Referenced by Botan::SIV_Decryption::finish().

void Botan::StreamCipher::cipher1 ( byte  buf[],
size_t  len 
) [inline]

Encrypt or decrypt a message

Parameters:
bufthe plaintext / ciphertext
lenthe length of buf in bytes

Definition at line 36 of file stream_cipher.h.

Referenced by Botan::SIV_Encryption::finish().

         { cipher(buf, buf, len); }
virtual void Botan::SymmetricAlgorithm::clear ( ) [pure virtual, inherited]
virtual StreamCipher* Botan::StreamCipher::clone ( ) const [pure virtual]

Get a new object representing the same algorithm as *this

Implemented in Botan::CTR_BE, Botan::OFB, Botan::ChaCha, Botan::Salsa20, and Botan::RC4.

template<typename Alloc >
void Botan::StreamCipher::decrypt ( std::vector< byte, Alloc > &  inout) [inline]

Definition at line 48 of file stream_cipher.h.

         { cipher(&inout[0], &inout[0], inout.size()); }
template<typename Alloc >
void Botan::StreamCipher::encipher ( std::vector< byte, Alloc > &  inout) [inline]

Definition at line 40 of file stream_cipher.h.

         { cipher(&inout[0], &inout[0], inout.size()); }
template<typename Alloc >
void Botan::StreamCipher::encrypt ( std::vector< byte, Alloc > &  inout) [inline]

Definition at line 44 of file stream_cipher.h.

         { cipher(&inout[0], &inout[0], inout.size()); }
virtual Key_Length_Specification Botan::SymmetricAlgorithm::key_spec ( ) const [pure virtual, inherited]
size_t Botan::SymmetricAlgorithm::maximum_keylength ( ) const [inline, inherited]
Returns:
minimum allowed key length

Definition at line 36 of file sym_algo.h.

References Botan::Key_Length_Specification::maximum_keylength().

         {
         return key_spec().maximum_keylength();
         }
size_t Botan::SymmetricAlgorithm::minimum_keylength ( ) const [inline, inherited]
Returns:
maxmium allowed key length

Definition at line 44 of file sym_algo.h.

         {
         return key_spec().minimum_keylength();
         }
virtual std::string Botan::SymmetricAlgorithm::name ( ) const [pure virtual, inherited]
virtual void Botan::StreamCipher::set_iv ( const byte  [],
size_t  iv_len 
) [inline, virtual]

Resync the cipher using the IV

Parameters:
ivthe initialization vector
iv_lenthe length of the IV in bytes

Reimplemented in Botan::CTR_BE, Botan::OFB, Botan::ChaCha, and Botan::Salsa20.

Definition at line 56 of file stream_cipher.h.

Referenced by Botan::SIV_Mode::set_ctr_iv().

         {
         if(iv_len)
            throw Invalid_IV_Length(name(), iv_len);
         }
void Botan::SymmetricAlgorithm::set_key ( const SymmetricKey key) [inline, inherited]

Set the symmetric key of this object.

Parameters:
keythe SymmetricKey to be set.

Definition at line 63 of file sym_algo.h.

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

Referenced by Botan::aont_package(), Botan::aont_unpackage(), botan_mac_set_key(), Botan::TLS::Session::decrypt(), Botan::TLS::Session::encrypt(), and Botan::pbkdf2().

         {
         set_key(key.begin(), key.length());
         }
template<typename Alloc >
void Botan::SymmetricAlgorithm::set_key ( const std::vector< byte, Alloc > &  key) [inline, inherited]

Definition at line 69 of file sym_algo.h.

         {
         set_key(&key[0], key.size());
         }
void Botan::SymmetricAlgorithm::set_key ( const byte  key[],
size_t  length 
) [inline, inherited]

Set the symmetric key of this object.

Parameters:
keythe to be set as a byte array.
lengthin bytes of key param

Definition at line 79 of file sym_algo.h.

         {
         if(!valid_keylength(length))
            throw Invalid_Key_Length(name(), length);
         key_schedule(key, length);
         }
virtual bool Botan::StreamCipher::valid_iv_length ( size_t  iv_len) const [inline, virtual]
Parameters:
iv_lenthe length of the IV in bytes
Returns:
if the length is valid for this algorithm

Reimplemented in Botan::CTR_BE, Botan::OFB, Botan::ChaCha, and Botan::Salsa20.

Definition at line 66 of file stream_cipher.h.

{ return (iv_len == 0); }
bool Botan::SymmetricAlgorithm::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 54 of file sym_algo.h.

Referenced by Botan::aont_package(), and Botan::aont_unpackage().

         {
         return key_spec().valid_keylength(length);
         }

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