feisty meow concerns codebase
2.140
|
Provides BlowFish encryption on byte_arrays using the OpenSSL package. More...
#include <blowfish_crypto.h>
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_crypto & | operator= (const blowfish_crypto &to_copy) |
DEFINE_CLASS_NAME ("blowfish_crypto") | |
int | key_size () const |
const basis::byte_array & | get_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_array & | init_vector () |
returns the initialization vector that is used by this class. More... | |
Provides BlowFish encryption on byte_arrays using the OpenSSL package.
Definition at line 25 of file blowfish_crypto.h.
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().
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().
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().
|
virtual |
Definition at line 125 of file blowfish_crypto.cpp.
References FUNCDEF, LOG, and basis::WHACK().
bool crypto::blowfish_crypto::decrypt | ( | const basis::byte_array & | source, |
basis::byte_array & | target | ||
) | const |
decrypts the "target" array from the encrypted "source" array.
Definition at line 253 of file blowfish_crypto.cpp.
References basis::array< contents >::access(), BITS_PER_BYTE, continuable_error, crypto::FUDGE, FUNCDEF, init_vector(), basis::array< contents >::last(), basis::array< contents >::length(), LOG, NULL_POINTER, basis::array< contents >::observe(), basis::array< contents >::reset(), and basis::array< contents >::zap().
Referenced by octopi::encryption_tentacle::consume().
crypto::blowfish_crypto::DEFINE_CLASS_NAME | ( | "blowfish_crypto" | ) |
bool crypto::blowfish_crypto::encrypt | ( | const basis::byte_array & | source, |
basis::byte_array & | target | ||
) | const |
encrypts the "source" array into the "target" array.
Definition at line 197 of file blowfish_crypto.cpp.
References basis::array< contents >::access(), continuable_error, crypto::FUDGE, FUNCDEF, init_vector(), basis::array< contents >::last(), basis::array< contents >::length(), LOG, NULL_POINTER, basis::array< contents >::observe(), basis::array< contents >::reset(), and basis::array< contents >::zap().
Referenced by cromp::cromp_server::wrap_infoton().
|
static |
creates a "new_key" of the "size" (in bits) specified.
Definition at line 163 of file blowfish_crypto.cpp.
References BITS_PER_BYTE, DISCUSS_KEY_SIZE, FUNCDEF, mathematics::chaos::inclusive(), maximum_key_size(), minimum_key_size(), crypto::ssl_init::randomizer(), basis::array< contents >::reset(), and crypto::static_ssl_initializer().
Referenced by blowfish_crypto().
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().
|
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.
int crypto::blowfish_crypto::key_size | ( | ) | const |
Definition at line 133 of file blowfish_crypto.cpp.
Referenced by blowfish_crypto(), and set_key().
|
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().
|
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().
blowfish_crypto & crypto::blowfish_crypto::operator= | ( | const blowfish_crypto & | to_copy | ) |
Definition at line 141 of file blowfish_crypto.cpp.
bool crypto::blowfish_crypto::set_key | ( | const basis::byte_array & | new_key, |
int | key_size | ||
) |
sets the encryption key to "new_key".
Definition at line 149 of file blowfish_crypto.cpp.
References BITS_PER_BYTE, DISCUSS_KEY_SIZE, DISCUSS_PROVIDED_KEY, FUNCDEF, key_size(), basis::array< contents >::length(), maximum_key_size(), and minimum_key_size().
Referenced by octopi::encryption_infoton::extract_response(), and cromp::cromp_client::login().