octopi::encryption_infoton Class Reference

Encapsulates the chit-chat necessary to establish an encrypted connection. More...

#include <encryption_infoton.h>

Inheritance diagram for octopi::encryption_infoton:
Inheritance graph
[legend]
Collaboration diagram for octopi::encryption_infoton:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 encryption_infoton (const basis::byte_array &public_key=basis::byte_array::empty_array(), const basis::byte_array &encrypted_blowfish_key=basis::byte_array::empty_array())
 encryption_infoton (const encryption_infoton &to_copy)
virtual ~encryption_infoton ()
 DEFINE_CLASS_NAME ("encryption_infoton")
void text_form (basis::base_string &fill) const
 requires derived infotons to be able to show their state as a string.
encryption_infotonoperator= (const encryption_infoton &to_copy)
basis::outcome prepare_blowfish_key (crypto::blowfish_crypto &new_key)
 performs the server side's job on the current key.
basis::outcome prepare_public_key (const crypto::rsa_crypto &private_key)
 prepares the request side for a client.
basis::outcome prepare_both_keys (crypto::rsa_crypto &private_key)
 sets up both keys by randomly generating the "private_key".
basis::outcome extract_response (const crypto::rsa_crypto &private_key, crypto::blowfish_crypto &new_key) const
 used by the client to extract the shared blowfish key from the server.
virtual void pack (basis::byte_array &packed_form) const
 stuffs the data in the infoton into the "packed_form".
virtual bool unpack (basis::byte_array &packed_form)
 restores an infoton from a packed form.
virtual clonableclone () 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
structures::string_array
encryption_classifier ()
 returns the classifier for this type of infoton.

Public Attributes

basis::byte_array _public_key
 valid during the request stage of encryption.
basis::byte_array _encrypted_blowfish_key
 valid during the response stage of encryption.
basis::outcome _success
 did the request succeed?

Static Public Attributes

static const int RSA_KEY_SIZE = 1480
 this key size should be used for all RSA private keys.
static const int BLOWFISH_KEY_SIZE = 314
 this will be used for blowfish keys that this object generates.

Detailed Description

Encapsulates the chit-chat necessary to establish an encrypted connection.

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 32 of file encryption_infoton.h.


Constructor & Destructor Documentation

octopi::encryption_infoton::encryption_infoton ( const basis::byte_array public_key = basis::byte_array::empty_array(),
const basis::byte_array encrypted_blowfish_key = basis::byte_array::empty_array() 
)

Definition at line 45 of file encryption_infoton.cpp.

octopi::encryption_infoton::encryption_infoton ( const encryption_infoton to_copy  ) 

Definition at line 53 of file encryption_infoton.cpp.

octopi::encryption_infoton::~encryption_infoton (  )  [virtual]

Definition at line 62 of file encryption_infoton.cpp.


Member Function Documentation

clonable * octopi::encryption_infoton::clone (  )  const [virtual]

must be provided to allow creation of a copy of this object.

Implements octopi::infoton.

Definition at line 64 of file encryption_infoton.cpp.

Referenced by octopi::encryption_tentacle::consume().

octopi::encryption_infoton::DEFINE_CLASS_NAME ( "encryption_infoton"   ) 
static const structures::string_array& octopi::encryption_infoton::encryption_classifier (  )  [static]

returns the classifier for this type of infoton.

Referenced by octopi::encryption_tentacle::reconstitute().

outcome octopi::encryption_infoton::extract_response ( const crypto::rsa_crypto private_key,
crypto::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 143 of file encryption_infoton.cpp.

References _encrypted_blowfish_key, _success, octopi::tentacle::BAD_INPUT, BLOWFISH_KEY_SIZE, octopi::tentacle::OKAY, crypto::rsa_crypto::private_decrypt(), and crypto::blowfish_crypto::set_key().

Referenced by octopi::encryption_tentacle::consume().

encryption_infoton & octopi::encryption_infoton::operator= ( const encryption_infoton to_copy  ) 

Definition at line 68 of file encryption_infoton.cpp.

void octopi::encryption_infoton::pack ( basis::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 octopi::infoton.

Definition at line 89 of file encryption_infoton.cpp.

References _encrypted_blowfish_key, _public_key, _success, basis::attach(), and basis::outcome::value().

virtual int octopi::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 octopi::infoton.

outcome octopi::encryption_infoton::prepare_blowfish_key ( crypto::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 106 of file encryption_infoton.cpp.

References _encrypted_blowfish_key, _public_key, _success, octopi::tentacle::BAD_INPUT, BLOWFISH_KEY_SIZE, octopi::tentacle::GARBAGE, crypto::blowfish_crypto::get_key(), basis::array< contents >::length(), octopi::tentacle::OKAY, crypto::rsa_crypto::public_encrypt(), and basis::array< contents >::reset().

Referenced by octopi::encryption_tentacle::consume().

outcome octopi::encryption_infoton::prepare_both_keys ( crypto::rsa_crypto private_key  ) 

sets up both keys by randomly generating the "private_key".

Definition at line 128 of file encryption_infoton.cpp.

References octopi::tentacle::OKAY, prepare_public_key(), and RSA_KEY_SIZE.

outcome octopi::encryption_infoton::prepare_public_key ( const crypto::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 136 of file encryption_infoton.cpp.

References _public_key, octopi::tentacle::DISALLOWED, octopi::tentacle::OKAY, and crypto::rsa_crypto::public_key().

Referenced by cromp::cromp_client::login(), and prepare_both_keys().

void octopi::encryption_infoton::text_form ( basis::base_string state_fill  )  const [inline, virtual]

requires derived infotons to be able to show their state as a string.

Implements octopi::infoton.

Definition at line 59 of file encryption_infoton.h.

References basis::base_string::assign(), and basis::text_formable::class_name().

bool octopi::encryption_infoton::unpack ( basis::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 octopi::infoton.

Definition at line 96 of file encryption_infoton.cpp.

References _encrypted_blowfish_key, _public_key, _success, and structures::detach().


Member Data Documentation

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 40 of file encryption_infoton.h.

Referenced by extract_response(), pack(), prepare_blowfish_key(), and unpack().

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 36 of file encryption_infoton.h.

Referenced by pack(), prepare_blowfish_key(), prepare_public_key(), and unpack().

did the request succeed?

Definition at line 44 of file encryption_infoton.h.

Referenced by extract_response(), pack(), prepare_blowfish_key(), and unpack().

this will be used for blowfish keys that this object generates.

Definition at line 57 of file encryption_infoton.h.

Referenced by extract_response(), and prepare_blowfish_key().

const int octopi::encryption_infoton::RSA_KEY_SIZE = 1480 [static]

this key size should be used for all RSA private keys.

Definition at line 55 of file encryption_infoton.h.

Referenced by prepare_both_keys().


The documentation for this class was generated from the following files:
Generated on Sat Jan 28 04:25:47 2012 for hoople2 project by  doxygen 1.6.3