#include <encryption_infoton.h>
Inheritance diagram for encryption_infoton:


Public Member Functions | |
| encryption_infoton (const byte_array &public_key=byte_array::empty_array(), const byte_array &encrypted_blowfish_key=byte_array::empty_array()) | |
| encryption_infoton (const encryption_infoton &to_copy) | |
| virtual | ~encryption_infoton () |
| IMPLEMENT_CLASS_NAME ("encryption_infoton") | |
| encryption_infoton & | operator= (const encryption_infoton &to_copy) |
| outcome | prepare_blowfish_key (blowfish_crypto &new_key) |
| performs the server side's job on the current key. | |
| outcome | prepare_public_key (const RSA_crypto &private_key) |
| prepares the request side for a client. | |
| outcome | prepare_both_keys (RSA_crypto &private_key) |
| sets up both keys by randomly generating the "private_key". | |
| outcome | extract_response (const RSA_crypto &private_key, blowfish_crypto &new_key) const |
| used by the client to extract the shared blowfish key from the server. | |
| virtual void | pack (byte_array &packed_form) const |
| stuffs the data in the infoton into the "packed_form". | |
| virtual bool | unpack (byte_array &packed_form) |
| restores an infoton from a packed form. | |
| virtual clonable * | clone () const |
| must be provided to allow creation of a copy of this object. | |
| virtual int | packed_size () const |
| reports how large the infoton will be when packed. | |
Static Public Member Functions | |
| static const string_array & | encryption_classifier () |
| returns the classifier for this type of infoton. | |
Public Attributes | |
| byte_array | _public_key |
| valid during the request stage of encryption. | |
| byte_array | _encrypted_blowfish_key |
| valid during the response stage of encryption. | |
| outcome | _success |
| did the request succeed? | |
Static Public Attributes | |
| static const int | RSA_KEY_SIZE |
| this key size should be used for all RSA private keys. | |
| static const int | BLOWFISH_KEY_SIZE |
| this will be used for blowfish keys that this object generates. | |
This is framed in terms of a client and a server, where the client creates a private key and gives the server the public key. The server side creates a blowfish key and encrypts it using the public key.
Definition at line 36 of file encryption_infoton.h.
| encryption_infoton::encryption_infoton | ( | const byte_array & | public_key = byte_array::empty_array(), |
|
| const byte_array & | encrypted_blowfish_key = byte_array::empty_array() | |||
| ) |
Definition at line 42 of file encryption_infoton.cpp.
| encryption_infoton::encryption_infoton | ( | const encryption_infoton & | to_copy | ) |
Definition at line 50 of file encryption_infoton.cpp.
| encryption_infoton::~encryption_infoton | ( | ) | [virtual] |
Definition at line 59 of file encryption_infoton.cpp.
| encryption_infoton::IMPLEMENT_CLASS_NAME | ( | "encryption_infoton" | ) |
| encryption_infoton & encryption_infoton::operator= | ( | const encryption_infoton & | to_copy | ) |
Definition at line 65 of file encryption_infoton.cpp.
| outcome encryption_infoton::prepare_blowfish_key | ( | blowfish_crypto & | new_key | ) |
performs the server side's job on the current key.
the public key had better be set already or this will fail. the "new_key" will always be used to communicate with the client after this.
Definition at line 101 of file encryption_infoton.cpp.
References _encrypted_blowfish_key, _public_key, _success, tentacle::BAD_INPUT, BLOWFISH_KEY_SIZE, FUNCDEF, tentacle::GARBAGE, blowfish_crypto::get_key(), array< contents >::length(), tentacle::OKAY, RSA_crypto::public_encrypt(), and array< contents >::reset().
Referenced by encryption_tentacle::consume().
| outcome encryption_infoton::prepare_public_key | ( | const RSA_crypto & | private_key | ) |
prepares the request side for a client.
the rsa public key will be generated from the "private_key".
Definition at line 131 of file encryption_infoton.cpp.
References _public_key, tentacle::DISALLOWED, tentacle::OKAY, and RSA_crypto::public_key().
Referenced by cromp_client::login(), and prepare_both_keys().
| outcome encryption_infoton::prepare_both_keys | ( | RSA_crypto & | private_key | ) |
sets up both keys by randomly generating the "private_key".
Definition at line 123 of file encryption_infoton.cpp.
References tentacle::OKAY, prepare_public_key(), and RSA_KEY_SIZE.
| outcome encryption_infoton::extract_response | ( | const RSA_crypto & | private_key, | |
| blowfish_crypto & | new_key | |||
| ) | const |
used by the client to extract the shared blowfish key from the server.
using the private key, the server's response is decrypted and stored in "new_key". note that this will only succeed if the _success member is OKAY. otherwise it means the server has beefed on the request.
Definition at line 138 of file encryption_infoton.cpp.
References _encrypted_blowfish_key, _success, tentacle::BAD_INPUT, BLOWFISH_KEY_SIZE, FUNCDEF, tentacle::OKAY, RSA_crypto::private_decrypt(), and blowfish_crypto::set_key().
Referenced by encryption_tentacle::consume().
| static const string_array& encryption_infoton::encryption_classifier | ( | ) | [static] |
| void encryption_infoton::pack | ( | byte_array & | packed_form | ) | const [virtual] |
stuffs the data in the infoton into the "packed_form".
the derived method must know how to pack this particular type of infoton.
Implements infoton.
Definition at line 86 of file encryption_infoton.cpp.
References _encrypted_blowfish_key, _public_key, _success, basis::attach(), and outcome::pack().
| bool encryption_infoton::unpack | ( | byte_array & | packed_form | ) | [virtual] |
restores an infoton from a packed form.
the unpack() method will be utilized by tentacles that support this type of object.
Implements infoton.
Definition at line 93 of file encryption_infoton.cpp.
References _encrypted_blowfish_key, _public_key, _success, basis::detach(), and outcome::unpack().
| clonable * encryption_infoton::clone | ( | ) | const [virtual] |
must be provided to allow creation of a copy of this object.
Implements infoton.
Definition at line 61 of file encryption_infoton.cpp.
Referenced by encryption_tentacle::consume().
| virtual int encryption_infoton::packed_size | ( | ) | const [virtual] |
reports how large the infoton will be when packed.
must be overridden by derived classes to provide a guess at how large the packed size of this will be. this is important to estimate accurately.
Implements infoton.
valid during the request stage of encryption.
this is used when the client is telling the server how to talk to it to provide the key.
Definition at line 40 of file encryption_infoton.h.
Referenced by pack(), prepare_blowfish_key(), prepare_public_key(), and unpack().
valid during the response stage of encryption.
this is used when the server reports a blowfish key that it will use on this connection with the client.
Definition at line 44 of file encryption_infoton.h.
Referenced by extract_response(), pack(), prepare_blowfish_key(), and unpack().
did the request succeed?
Definition at line 48 of file encryption_infoton.h.
Referenced by extract_response(), pack(), prepare_blowfish_key(), and unpack().
const int encryption_infoton::RSA_KEY_SIZE [static] |
this key size should be used for all RSA private keys.
Definition at line 59 of file encryption_infoton.h.
Referenced by cromp_client::enable_encryption(), and prepare_both_keys().
const int encryption_infoton::BLOWFISH_KEY_SIZE [static] |
this will be used for blowfish keys that this object generates.
Definition at line 61 of file encryption_infoton.h.
Referenced by extract_response(), cromp_client::login(), and prepare_blowfish_key().
1.5.1