27 using namespace basis;
35 const int encryption_infoton::BLOWFISH_KEY_SIZE = 314;
39 const int encryption_infoton::RSA_KEY_SIZE = 1480;
43 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s);
45 encryption_infoton::encryption_infoton(
const byte_array &pub_key,
47 :
infoton(encryption_classifier()),
49 _encrypted_blowfish_key(secret_blowfish),
56 _public_key(to_copy._public_key),
57 _encrypted_blowfish_key(to_copy._encrypted_blowfish_key),
58 _success(to_copy._success)
65 {
return cloner<encryption_infoton>(*
this); }
70 if (
this == &to_copy)
return *
this;
72 _encrypted_blowfish_key = to_copy._encrypted_blowfish_key;
73 _success = to_copy._success;
108 FUNCDEF(
"prepare_blowfish_key");
118 new_key = agreed_key;
void reset(int number=0, const contents *initial_contents=NULL_POINTER)
Resizes this array and sets the contents from an array of contents.
int length() const
Returns the current reported length of the allocated C array.
A very common template for a dynamic array of bytes.
A clonable object knows how to make copy of itself.
Outcomes describe the state of completion for an operation.
Provides BlowFish encryption on byte_arrays using the OpenSSL package.
bool set_key(const basis::byte_array &new_key, int key_size)
sets the encryption key to "new_key".
const basis::byte_array & get_key() const
returns our current key.
Supports public key encryption and decryption.
bool public_encrypt(const basis::byte_array &source, basis::byte_array &target) const
encrypts "source" using our public key and stores it in "target".
bool private_decrypt(const basis::byte_array &source, basis::byte_array &target) const
decrypts "source" using our private key and stores it in "target".
bool public_key(basis::byte_array &pubkey) const
makes a copy of the public key held here.
Encapsulates the chit-chat necessary to establish an encrypted connection.
basis::outcome prepare_public_key(const crypto::rsa_crypto &private_key)
prepares the request side for a client.
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.
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())
virtual int packed_size() const
reports how large the infoton will be when packed.
basis::outcome prepare_both_keys(crypto::rsa_crypto &private_key)
sets up both keys by randomly generating the "private_key".
basis::byte_array _public_key
valid during the request stage of encryption.
basis::outcome prepare_blowfish_key(crypto::blowfish_crypto &new_key)
performs the server side's job on the current key.
virtual clonable * clone() const
must be provided to allow creation of a copy of this object.
basis::outcome _success
did the request succeed?
static const int RSA_KEY_SIZE
this key size should be used for all RSA private keys.
virtual void pack(basis::byte_array &packed_form) const
stuffs the data in the infoton into the "packed_form".
virtual ~encryption_infoton()
static const int BLOWFISH_KEY_SIZE
this will be used for blowfish keys that this object generates.
static const structures::string_array & encryption_classifier()
returns the classifier for this type of infoton.
basis::byte_array _encrypted_blowfish_key
valid during the response stage of encryption.
virtual bool unpack(basis::byte_array &packed_form)
restores an infoton from a packed form.
An infoton is an individual request parcel with accompanying information.
Manages a service within an octopus by processing certain infotons.
An array of strings with some additional helpful methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
The guards collection helps in testing preconditions and reporting errors.
SAFE_STATIC_CONST(string_array, identity_infoton::identity_classifier,(1, identity_classifier_strings)) int identity_infoton
const char * encryption_class_constant
A dynamic container class that holds any kind of object via pointers.
void attach(byte_array &packed_form, const byte_array &to_attach)
Packs a byte_array "to_attach" into "packed_form".
bool detach(byte_array &packed_form, byte_array &to_detach)
Unpacks a byte_array "to_detach" from "packed_form".