Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

BlockCipherBase Class Reference

Cryptographic block cipher base class. More...

#include <bcipherbase.h>

Inheritance diagram for BlockCipherBase:

Inheritance graph
[legend]
Collaboration diagram for BlockCipherBase:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BlockCipherBase ()
 Constructor; nothing special.

virtual ~BlockCipherBase ()
 Destructor: Must clean up the key data.

virtual const ParametersGetPar () const
 Returns a pointer to the (normally static) parameters of this block cipher.

virtual int SetKey (char *key, size_t len)
virtual int CheckWeakKey ()
 Checks if the currently set key is weak.

virtual int CopyFrom (BlockCipherBase *bcb)
 Used to clone a block cipher (copy the keys).

virtual void EncryptBlock (char *ibuf, char *obuf)
virtual void DecryptBlock (char *ibuf, char *obuf)

Static Public Attributes

const Parameters par

Private Member Functions

 BlockCipherBase (const BlockCipherBase &)
 Do not use these:.

void operator= (const BlockCipherBase &)

Detailed Description

Cryptographic block cipher base class.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
This is a base class for cryptographic block ciphers.

If no derived class is used but this class itself, a null-cipher (which is not modifying the input) is used.

NOTE: This class is NOT "C++-safe" and you should generally be careful with cryptographic data, so it is best to manage (de)allocation of these objects in a higher order.

Definition at line 42 of file bcipherbase.h.


Constructor & Destructor Documentation

BlockCipherBase::BlockCipherBase const BlockCipherBase  )  [private]
 

Do not use these:.

BlockCipherBase::BlockCipherBase  )  [inline]
 

Constructor; nothing special.

Definition at line 68 of file bcipherbase.h.

virtual BlockCipherBase::~BlockCipherBase  )  [inline, virtual]
 

Destructor: Must clean up the key data.

Definition at line 70 of file bcipherbase.h.


Member Function Documentation

int BlockCipherBase::CheckWeakKey  )  [virtual]
 

Checks if the currently set key is weak.

Returns:
  • 0 -> the key is not weak or weak key check is not supported by this algorithm
  • !=0 -> the key is weak; future implementations may discriminate between different weaknesses via the return value.

Reimplemented in BlowFishCipher, and TwoFishCipher.

Definition at line 43 of file bcipherbase.cc.

int BlockCipherBase::CopyFrom BlockCipherBase bcb  )  [virtual]
 

Used to clone a block cipher (copy the keys).

You have to cast bcb back to the derived class' type.

Returns:
0 -> OK -2 -> bcb is NULL or of wrong type (see cipher_ID).

Reimplemented in BlowFishCipher, and TwoFishCipher.

Definition at line 67 of file bcipherbase.cc.

References BlockCipherBase::Parameters::cipher_ID, GetPar(), and par.

void BlockCipherBase::DecryptBlock char *  ibuf,
char *  obuf
[virtual]
 

Reimplemented in BlowFishCipher, and TwoFishCipher.

Definition at line 58 of file bcipherbase.cc.

References BLOCKSIZE.

void BlockCipherBase::EncryptBlock char *  ibuf,
char *  obuf
[virtual]
 

Encrypt/decrypt functions dealing with just one block of input.

  • The data does not have to be aligned.
  • You may set ibuf=obuf to get you data en/decrypted in-place.
  • Make sure, ibuf and obuf contain (at least) BlockSize() number of bytes.

Reimplemented in BlowFishCipher, and TwoFishCipher.

Definition at line 49 of file bcipherbase.cc.

References BLOCKSIZE.

virtual const Parameters* BlockCipherBase::GetPar  )  const [inline, virtual]
 

Returns a pointer to the (normally static) parameters of this block cipher.

The returned pointer may only be used in read-only manner.

It may point to memory allocated by the cipher class as the pointer may not be used after the cipher class was destroyed.

Reimplemented in BlowFishCipher, and TwoFishCipher.

Definition at line 81 of file bcipherbase.h.

References par.

Referenced by TwoFishCipher::CopyFrom(), BlowFishCipher::CopyFrom(), and CopyFrom().

void BlockCipherBase::operator= const BlockCipherBase  )  [private]
 

int BlockCipherBase::SetKey char *  key,
size_t  len
[virtual]
 

Set key with specified size.

Returns:
0 -> OK; -2 -> illegal length

Reimplemented in BlowFishCipher, and TwoFishCipher.

Definition at line 34 of file bcipherbase.cc.

References BlockCipherBase::Parameters::key_length, BlockCipherBase::Parameters::n_key_lengths, and par.


Member Data Documentation

const BlockCipherBase::Parameters BlockCipherBase::par [static]
 

Initial value:

 
{
    INIT_FIELD(block_size) BLOCKSIZE,
    INIT_FIELD(n_key_lengths) 9,
    INIT_FIELD(key_length) null_par_kl,
    INIT_FIELD(cipher_ID) 0x0000,
    INIT_FIELD(name) "null"
}
Parameters of the block cipher; every derived class must provide its own _static_ parameter description.

Reimplemented in BlowFishCipher, and TwoFishCipher.

Definition at line 24 of file bcipherbase.cc.

Referenced by CopyFrom(), GetPar(), and SetKey().


The documentation for this class was generated from the following files:
Generated on Sat Feb 19 22:35:22 2005 for Ray by doxygen 1.3.5