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

BlowFishCipher Class Reference

Cryptographic blowfish cipher. More...

#include <blowfishcipher.h>

Inheritance diagram for BlowFishCipher:

Inheritance graph
[legend]
Collaboration diagram for BlowFishCipher:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BlowFishCipher ()
 Construct a blowfish cipher; key must be set separately.

 ~BlowFishCipher ()
 Destructor: Cleans up the key data.

const Parameters * GetPar () const
 Return pointer to static parameters.

int SetKey (char *userkey, size_t len)
 Set the key for the following encryption/decryption.

int CheckWeakKey ()
 Check for weak blowfish key.

int CopyFrom (BlockCipherBase *from)
 Copy the prepared keys from another BlowFishCipher.

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

Static Public Attributes

const BlockCipherBase::Parameters par
 Parameters of the block cipher.


Private Member Functions

void _EncryptRounds (uint32 *_yl, uint32 *_yr)
void _reset ()
 Clean up the key data.

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

void operator= (const BlowFishCipher &)

Private Attributes

uint32 c_P [18]
uint32 c_S [1024]

Detailed Description

Cryptographic blowfish cipher.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
Blowfish is a quite fast cipher algorithm.

ADVANTAGE: FAST

DISADVANTAGE: quite LARGE
Note:
sizeof(BlowFishCipher)=4168 bytes (!) snd thus nothing for small stacks..

Definition at line 55 of file blowfishcipher.h.


Constructor & Destructor Documentation

BlowFishCipher::BlowFishCipher const BlowFishCipher  )  [private]
 

Do not use these:.

BlowFishCipher::BlowFishCipher  )  [inline]
 

Construct a blowfish cipher; key must be set separately.

Definition at line 79 of file blowfishcipher.h.

BlowFishCipher::~BlowFishCipher  )  [inline]
 

Destructor: Cleans up the key data.

Definition at line 81 of file blowfishcipher.h.

References _reset().


Member Function Documentation

void BlowFishCipher::_EncryptRounds uint32 _yl,
uint32 _yr
[inline, private]
 

For internal use only.

Do the encryption.

Definition at line 309 of file blowfishcipher.cc.

References c_P, c_S, ROUND, and uint32.

Referenced by SetKey().

void BlowFishCipher::_reset  )  [private]
 

Clean up the key data.

Definition at line 489 of file blowfishcipher.cc.

References c_P, c_S, and uint32.

Referenced by ~BlowFishCipher().

int BlowFishCipher::CheckWeakKey  )  [virtual]
 

Check for weak blowfish key.

Weak blowfish keys are generated with a probability of 1:2^14 (1:16384).

Returns:
This returns 1, if the currently set key is weak. Returns 0 if the key is not weak.

Reimplemented from BlockCipherBase.

Definition at line 387 of file blowfishcipher.cc.

References c_S, and uint32.

int BlowFishCipher::CopyFrom BlockCipherBase from  )  [virtual]
 

Copy the prepared keys from another BlowFishCipher.

Returns:
0 -> OK -2 -> from is not a BlowFishCipher.

Reimplemented from BlockCipherBase.

Definition at line 499 of file blowfishcipher.cc.

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

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

Reimplemented from BlockCipherBase.

Definition at line 457 of file blowfishcipher.cc.

References c_P, c_S, INPACK, OUTPACK, ROUND, and uint32.

Referenced by test_blowfish().

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

ibuf and obuf do not have to be aligned.
You may set ibuf=obuf.

Reimplemented from BlockCipherBase.

Definition at line 424 of file blowfishcipher.cc.

References c_P, c_S, INPACK, OUTPACK, ROUND, and uint32.

Referenced by test_blowfish().

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

Return pointer to static parameters.

Reimplemented from BlockCipherBase.

Definition at line 84 of file blowfishcipher.h.

References par.

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

int BlowFishCipher::SetKey char *  userkey,
size_t  len
[virtual]
 

Set the key for the following encryption/decryption.

userkey must be 128 or 256 bits long (see BlockCipher::KeyLength()).

The key does not have to be aligned.
The key length is passed in len (must be 16 or 32 [bytes]).

Make sure, len is a value as returned by BlockCipher::KeyLength() or the functin fails.

Returns:
0 -> OK; -2 -> illegal key size.

Reimplemented from BlockCipherBase.

Definition at line 335 of file blowfishcipher.cc.

References _EncryptRounds(), bf_pbox, bf_sbox, c_P, c_S, and uint32.

Referenced by test_blowfish().


Member Data Documentation

uint32 BlowFishCipher::c_P[18] [private]
 

Structure for an expanded blowfish key.

Definition at line 64 of file blowfishcipher.h.

Referenced by _EncryptRounds(), _reset(), CopyFrom(), DecryptBlock(), EncryptBlock(), and SetKey().

uint32 BlowFishCipher::c_S[1024] [private]
 

Definition at line 65 of file blowfishcipher.h.

Referenced by _EncryptRounds(), _reset(), CheckWeakKey(), CopyFrom(), DecryptBlock(), EncryptBlock(), and SetKey().

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

Initial value:

 
{
    INIT_FIELD(block_size) 8,
    INIT_FIELD(n_key_lengths) 7,
    INIT_FIELD(key_length) blowfish_par_kl,
    INIT_FIELD(cipher_ID) 0xBF15,
    INIT_FIELD(name) "blowfish"
}
Parameters of the block cipher.

Reimplemented from BlockCipherBase.

Definition at line 513 of file blowfishcipher.cc.

Referenced by CopyFrom(), and GetPar().


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