feisty meow concerns codebase  2.140
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:
Collaboration diagram for octopi::encryption_infoton:

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. More...
 
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. More...
 
basis::outcome prepare_public_key (const crypto::rsa_crypto &private_key)
 prepares the request side for a client. More...
 
basis::outcome prepare_both_keys (crypto::rsa_crypto &private_key)
 sets up both keys by randomly generating the "private_key". More...
 
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. More...
 
virtual void pack (basis::byte_array &packed_form) const
 stuffs the data in the infoton into the "packed_form". More...
 
virtual bool unpack (basis::byte_array &packed_form)
 restores an infoton from a packed form. More...
 
virtual clonableclone () const
 must be provided to allow creation of a copy of this object. More...
 
virtual int packed_size () const
 reports how large the infoton will be when packed. More...
 
- Public Member Functions inherited from octopi::infoton
 infoton (const structures::string_array &classifier)
 creates an infoton with the "classifier". More...
 
 infoton (const basis::astring &class_1)
 
 infoton (const basis::astring &class_1, const basis::astring &class_2)
 
 infoton (const basis::astring &class_1, const basis::astring &class_2, const basis::astring &cl_3)
 
 infoton (const infoton &to_copy)
 copies only the base class portion of the infoton. More...
 
virtual ~infoton ()
 
 DEFINE_CLASS_NAME ("infoton")
 
infotonoperator= (const infoton &to_copy)
 assigns only the base class portion. More...
 
const structures::string_arrayclassifier () const
 this array of strings is the "name" for this infoton. More...
 
void set_classifier (const structures::string_array &new_classifier)
 sets the infoton's classifier to the "new_classifier". More...
 
void set_classifier (const basis::astring &class_1)
 
void set_classifier (const basis::astring &class_1, const basis::astring &class_2)
 
void set_classifier (const basis::astring &class_1, const basis::astring &class_2, const basis::astring &cl_3)
 
bool check_classifier (const basis::astring &class_name, const basis::astring &caller)
 checks that the classifier seems valid. More...
 
virtual basis::astring text_form () const
 local version just makes text_form() more functional. More...
 
- Public Member Functions inherited from basis::text_formable
virtual const char * class_name () const =0
 Returns the bare name of this class as a constant character pointer. More...
 

Static Public Member Functions

static const structures::string_arrayencryption_classifier ()
 returns the classifier for this type of infoton. More...
 
- Static Public Member Functions inherited from octopi::infoton
static void fast_pack (basis::byte_array &packed_form, const infoton &to_pack)
 flattens an infoton "to_pack" into the byte array "packed_form". More...
 
static bool fast_unpack (basis::byte_array &packed_form, structures::string_array &classifier, basis::byte_array &info)
 undoes a previous fast_pack to restore the previous information. More...
 
static bool test_fast_unpack (const basis::byte_array &packed_form, int &packed_length)
 checks that the "packed_form" could hold a valid packed infoton. More...
 
static int fast_pack_overhead (const structures::string_array &classifier)
 reports how much space is needed to pack the "classifier". More...
 

Public Attributes

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

Static Public Attributes

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

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

◆ encryption_infoton() [1/2]

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.

◆ encryption_infoton() [2/2]

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

Definition at line 53 of file encryption_infoton.cpp.

◆ ~encryption_infoton()

octopi::encryption_infoton::~encryption_infoton ( )
virtual

Definition at line 62 of file encryption_infoton.cpp.

Member Function Documentation

◆ clone()

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().

◆ DEFINE_CLASS_NAME()

octopi::encryption_infoton::DEFINE_CLASS_NAME ( "encryption_infoton"  )

◆ encryption_classifier()

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().

◆ extract_response()

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, FUNCDEF, octopi::tentacle::OKAY, crypto::rsa_crypto::private_decrypt(), and crypto::blowfish_crypto::set_key().

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

◆ operator=()

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

Definition at line 67 of file encryption_infoton.cpp.

References _public_key.

◆ pack()

virtual 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.

◆ packed_size()

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.

◆ prepare_blowfish_key()

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, FUNCDEF, 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().

◆ prepare_both_keys()

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.

◆ prepare_public_key()

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().

◆ text_form()

void octopi::encryption_infoton::text_form ( basis::base_string state_fill) const
inlinevirtual

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().

◆ unpack()

virtual 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.

Member Data Documentation

◆ _encrypted_blowfish_key

basis::byte_array octopi::encryption_infoton::_encrypted_blowfish_key

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

Referenced by extract_response(), prepare_blowfish_key(), and octopi::SAFE_STATIC_CONST().

◆ _public_key

basis::byte_array octopi::encryption_infoton::_public_key

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

Referenced by operator=(), prepare_blowfish_key(), prepare_public_key(), and octopi::SAFE_STATIC_CONST().

◆ _success

basis::outcome octopi::encryption_infoton::_success

did the request succeed?

Definition at line 44 of file encryption_infoton.h.

Referenced by extract_response(), and prepare_blowfish_key().

◆ BLOWFISH_KEY_SIZE

const int octopi::encryption_infoton::BLOWFISH_KEY_SIZE = 314
static

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

Definition at line 56 of file encryption_infoton.h.

Referenced by extract_response(), and prepare_blowfish_key().

◆ RSA_KEY_SIZE

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

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

Definition at line 54 of file encryption_infoton.h.

Referenced by prepare_both_keys().


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