feisty meow concerns codebase  2.140
crypto::blowfish_crypto Class Reference

Provides BlowFish encryption on byte_arrays using the OpenSSL package. More...

#include <blowfish_crypto.h>

Inheritance diagram for crypto::blowfish_crypto:
Collaboration diagram for crypto::blowfish_crypto:

Public Member Functions

 blowfish_crypto (int key_size)
 this will create a new random key of the "key_size", in bits. More...
 
 blowfish_crypto (const basis::byte_array &key, int key_size)
 uses a pre-existing "key". More...
 
 blowfish_crypto (const blowfish_crypto &to_copy)
 copy constructor. More...
 
virtual ~blowfish_crypto ()
 
blowfish_cryptooperator= (const blowfish_crypto &to_copy)
 
 DEFINE_CLASS_NAME ("blowfish_crypto")
 
int key_size () const
 
const basis::byte_arrayget_key () const
 returns our current key. More...
 
bool set_key (const basis::byte_array &new_key, int key_size)
 sets the encryption key to "new_key". More...
 
bool encrypt (const basis::byte_array &source, basis::byte_array &target) const
 encrypts the "source" array into the "target" array. More...
 
bool decrypt (const basis::byte_array &source, basis::byte_array &target) const
 decrypts the "target" array from the encrypted "source" array. More...
 

Static Public Member Functions

static int minimum_key_size ()
 returns the minimum key size (in bits) supported here. More...
 
static int maximum_key_size ()
 returns the maximum key size (in bits) supported here. More...
 
static void generate_key (int size, basis::byte_array &new_key)
 creates a "new_key" of the "size" (in bits) specified. More...
 
static const basis::byte_arrayinit_vector ()
 returns the initialization vector that is used by this class. More...
 

Detailed Description

Provides BlowFish encryption on byte_arrays using the OpenSSL package.

Definition at line 25 of file blowfish_crypto.h.

Constructor & Destructor Documentation

◆ blowfish_crypto() [1/3]

crypto::blowfish_crypto::blowfish_crypto ( int  key_size)

this will create a new random key of the "key_size", in bits.

the valid sizes are from 64 bits to 448 bits (we are forcing a higher minimum than the published algorithm because we have found smaller keys to be unreliable during decryption. keys of 168 bits and larger should be very secure. it is said that if a billion computers each tried a billion keys a second, then a 168 bit key would take 10 * 10^24 years to break (using brute force). this is essentially unbreakable since the age of the universe is only 10 * 10^9 years so far.

Definition at line 82 of file blowfish_crypto.cpp.

References DISCUSS_KEY_SIZE, FUNCDEF, generate_key(), key_size(), LOG, maximum_key_size(), minimum_key_size(), and crypto::static_ssl_initializer().

◆ blowfish_crypto() [2/3]

crypto::blowfish_crypto::blowfish_crypto ( const basis::byte_array key,
int  key_size 
)

uses a pre-existing "key".

Definition at line 99 of file blowfish_crypto.cpp.

References DISCUSS_KEY_SIZE, DISCUSS_PROVIDED_KEY, FUNCDEF, key_size(), LOG, and crypto::static_ssl_initializer().

◆ blowfish_crypto() [3/3]

crypto::blowfish_crypto::blowfish_crypto ( const blowfish_crypto to_copy)

copy constructor.

Definition at line 115 of file blowfish_crypto.cpp.

References FUNCDEF, LOG, and crypto::static_ssl_initializer().

◆ ~blowfish_crypto()

crypto::blowfish_crypto::~blowfish_crypto ( )
virtual

Definition at line 125 of file blowfish_crypto.cpp.

References FUNCDEF, LOG, and basis::WHACK().

Member Function Documentation

◆ decrypt()

◆ DEFINE_CLASS_NAME()

crypto::blowfish_crypto::DEFINE_CLASS_NAME ( "blowfish_crypto"  )

◆ encrypt()

◆ generate_key()

void crypto::blowfish_crypto::generate_key ( int  size,
basis::byte_array new_key 
)
static

◆ get_key()

const byte_array & crypto::blowfish_crypto::get_key ( ) const

returns our current key.

Definition at line 135 of file blowfish_crypto.cpp.

Referenced by cromp::cromp_client::login(), and octopi::encryption_infoton::prepare_blowfish_key().

◆ init_vector()

const byte_array & crypto::blowfish_crypto::init_vector ( )
static

returns the initialization vector that is used by this class.

decryption of chunks that were encrypted by this class will require the same init vector as this function returns. this is mainly provided for third-party applications that want to be able to decrypt interoperably with this class. if you are creating such an application but for some reason cannot run this class in order to invoke this method, the vector is created by the algorithm in this class's implementation file (currently named blowfish_crypto.cpp).

Definition at line 180 of file blowfish_crypto.cpp.

References FUNCDEF, and LOG.

Referenced by decrypt(), and encrypt().

◆ key_size()

int crypto::blowfish_crypto::key_size ( ) const

Definition at line 133 of file blowfish_crypto.cpp.

Referenced by blowfish_crypto(), and set_key().

◆ maximum_key_size()

int crypto::blowfish_crypto::maximum_key_size ( )
static

returns the maximum key size (in bits) supported here.

Definition at line 139 of file blowfish_crypto.cpp.

Referenced by blowfish_crypto(), generate_key(), and set_key().

◆ minimum_key_size()

int crypto::blowfish_crypto::minimum_key_size ( )
static

returns the minimum key size (in bits) supported here.

Definition at line 137 of file blowfish_crypto.cpp.

Referenced by blowfish_crypto(), generate_key(), and set_key().

◆ operator=()

blowfish_crypto & crypto::blowfish_crypto::operator= ( const blowfish_crypto to_copy)

Definition at line 141 of file blowfish_crypto.cpp.

◆ set_key()

bool crypto::blowfish_crypto::set_key ( const basis::byte_array new_key,
int  key_size 
)

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