Botan::CBC_Encryption Class Reference

#include <cbc.h>

Inheritance diagram for Botan::CBC_Encryption:

Botan::Keyed_Filter Botan::Buffered_Filter Botan::Filter

List of all members.

Public Member Functions

virtual bool attachable ()
 CBC_Encryption (BlockCipher *cipher, BlockCipherModePaddingMethod *padding, const SymmetricKey &key, const InitializationVector &iv)
 CBC_Encryption (BlockCipher *cipher, BlockCipherModePaddingMethod *padding)
std::string name () const
void set_iv (const InitializationVector &iv)
void set_key (const SymmetricKey &key)
virtual void start_msg ()
bool valid_iv_length (u32bit iv_len) const
bool valid_keylength (u32bit key_len) const
 ~CBC_Encryption ()

Protected Member Functions

void send (const MemoryRegion< byte > &in)
void send (byte in)
void send (const byte in[], u32bit length)

Private Member Functions

void buffer_reset ()
u32bit buffered_block_size () const
u32bit current_position () const


Detailed Description

CBC Encryption

Definition at line 21 of file cbc.h.


Constructor & Destructor Documentation

Botan::CBC_Encryption::CBC_Encryption ( BlockCipher cipher,
BlockCipherModePaddingMethod padding 
)

Definition at line 17 of file cbc.cpp.

References Botan::BlockCipher::BLOCK_SIZE, Botan::BlockCipherModePaddingMethod::name(), name(), Botan::MemoryRegion< T >::resize(), and Botan::BlockCipherModePaddingMethod::valid_blocksize().

00018                                                                   :
00019    Buffered_Filter(ciph->BLOCK_SIZE, 0),
00020    cipher(ciph), padder(pad)
00021    {
00022    if(!padder->valid_blocksize(cipher->BLOCK_SIZE))
00023       throw Invalid_Block_Size(name(), padder->name());
00024 
00025    state.resize(cipher->BLOCK_SIZE);
00026    }

Botan::CBC_Encryption::CBC_Encryption ( BlockCipher cipher,
BlockCipherModePaddingMethod padding,
const SymmetricKey key,
const InitializationVector iv 
)

Definition at line 31 of file cbc.cpp.

References Botan::BlockCipher::BLOCK_SIZE, Botan::BlockCipherModePaddingMethod::name(), name(), Botan::MemoryRegion< T >::resize(), set_iv(), set_key(), and Botan::BlockCipherModePaddingMethod::valid_blocksize().

00034                                                                :
00035    Buffered_Filter(ciph->BLOCK_SIZE, 0),
00036    cipher(ciph), padder(pad)
00037    {
00038    if(!padder->valid_blocksize(cipher->BLOCK_SIZE))
00039       throw Invalid_Block_Size(name(), padder->name());
00040 
00041    state.resize(cipher->BLOCK_SIZE);
00042 
00043    set_key(key);
00044    set_iv(iv);
00045    }

Botan::CBC_Encryption::~CBC_Encryption (  )  [inline]

Definition at line 45 of file cbc.h.

00045 { delete cipher; delete padder; }


Member Function Documentation

virtual bool Botan::Filter::attachable (  )  [inline, virtual, inherited]

Check whether this filter is an attachable filter.

Returns:
true if this filter is attachable, false otherwise

Reimplemented in Botan::DataSink, and Botan::SecureQueue.

Definition at line 50 of file filter.h.

00050 { return true; }

std::string Botan::CBC_Encryption::name (  )  const [virtual]

Returns:
descriptive name for this filter

Implements Botan::Filter.

Definition at line 107 of file cbc.cpp.

References Botan::BlockCipherModePaddingMethod::name(), and Botan::SymmetricAlgorithm::name().

Referenced by CBC_Encryption(), and set_iv().

00108    {
00109    return (cipher->name() + "/CBC/" + padder->name());
00110    }

void Botan::Filter::send ( const MemoryRegion< byte > &  in  )  [inline, protected, inherited]

Parameters:
in some input for the filter

Definition at line 68 of file filter.h.

References Botan::MemoryRegion< T >::begin(), Botan::Filter::send(), and Botan::MemoryRegion< T >::size().

Referenced by Botan::Filter::send().

00068 { send(in.begin(), in.size()); }

void Botan::Filter::send ( byte  in  )  [inline, protected, inherited]

Parameters:
in some input for the filter

Definition at line 63 of file filter.h.

References Botan::Filter::send().

Referenced by Botan::Filter::send().

00063 { send(&in, 1); }

void Botan::Filter::send ( const byte  in[],
u32bit  length 
) [protected, inherited]

Parameters:
in some input for the filter
length the length of in

Definition at line 28 of file filter.cpp.

References Botan::MemoryRegion< T >::append(), Botan::MemoryRegion< T >::destroy(), Botan::MemoryRegion< T >::size(), and Botan::Filter::write().

Referenced by Botan::Zlib_Decompression::end_msg(), Botan::Zlib_Compression::end_msg(), Botan::PK_Verifier_Filter::end_msg(), Botan::PK_Signer_Filter::end_msg(), Botan::PK_Decryptor_Filter::end_msg(), Botan::PK_Encryptor_Filter::end_msg(), Botan::Hex_Encoder::end_msg(), Botan::Bzip_Decompression::end_msg(), Botan::Bzip_Compression::end_msg(), Botan::Base64_Decoder::end_msg(), Botan::Base64_Encoder::end_msg(), Botan::MAC_Filter::end_msg(), Botan::Hash_Filter::end_msg(), Botan::Zlib_Compression::flush(), Botan::Bzip_Compression::flush(), Botan::Zlib_Decompression::write(), Botan::Zlib_Compression::write(), Botan::Bzip_Decompression::write(), Botan::Bzip_Compression::write(), and Botan::StreamCipher_Filter::write().

00029    {
00030    bool nothing_attached = true;
00031    for(u32bit j = 0; j != total_ports(); ++j)
00032       if(next[j])
00033          {
00034          if(write_queue.size())
00035             next[j]->write(write_queue, write_queue.size());
00036          next[j]->write(input, length);
00037          nothing_attached = false;
00038          }
00039 
00040    if(nothing_attached)
00041       write_queue.append(input, length);
00042    else
00043       write_queue.destroy();
00044    }

void Botan::CBC_Encryption::set_iv ( const InitializationVector iv  )  [virtual]

Set the initialization vector of this filter. Note: you should call set_iv() only after you have called set_key()

Parameters:
iv the initialization vector to use

Reimplemented from Botan::Keyed_Filter.

Definition at line 50 of file cbc.cpp.

References Botan::OctetString::bits_of(), Botan::Buffered_Filter::buffer_reset(), Botan::OctetString::length(), name(), and valid_iv_length().

Referenced by CBC_Encryption().

00051    {
00052    if(!valid_iv_length(iv.length()))
00053       throw Invalid_IV_Length(name(), iv.length());
00054 
00055    state = iv.bits_of();
00056    buffer_reset();
00057    }

void Botan::CBC_Encryption::set_key ( const SymmetricKey key  )  [inline, virtual]

Set the key of this filter

Parameters:
key the key to use

Implements Botan::Keyed_Filter.

Definition at line 29 of file cbc.h.

Referenced by CBC_Encryption().

00029 { cipher->set_key(key); }

virtual void Botan::Filter::start_msg (  )  [inline, virtual, inherited]

Start a new message. Must be closed by end_msg() before another message can be started.

Reimplemented in Botan::Bzip_Compression, Botan::Bzip_Decompression, Botan::EAX_Base, Botan::Zlib_Compression, Botan::Zlib_Decompression, Botan::PBE_PKCS5v15, and Botan::PBE_PKCS5v20.

Definition at line 38 of file filter.h.

00038 {}

bool Botan::CBC_Encryption::valid_iv_length ( u32bit  length  )  const [inline, virtual]

Check whether an IV length is valid for this filter

Parameters:
length the IV length to be checked for validity
Returns:
true if the IV length is valid, false otherwise

Reimplemented from Botan::Keyed_Filter.

Definition at line 34 of file cbc.h.

Referenced by set_iv().

00035          { return (iv_len == cipher->BLOCK_SIZE); }

bool Botan::CBC_Encryption::valid_keylength ( u32bit  length  )  const [inline, virtual]

Check whether a key length is valid for this filter

Parameters:
length the key length to be checked for validity
Returns:
true if the key length is valid, false otherwise

Implements Botan::Keyed_Filter.

Definition at line 31 of file cbc.h.

00032          { return cipher->valid_keylength(key_len); }


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

Generated on Tue Jun 29 08:56:42 2010 for Botan by  doxygen 1.5.8