crypto::rsa_crypto Class Reference

Supports public key encryption and decryption. More...

#include <rsa_crypto.h>

Inheritance diagram for crypto::rsa_crypto:
Inheritance graph
[legend]
Collaboration diagram for crypto::rsa_crypto:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 rsa_crypto (int key_size)
 constructs using a randomized private key of the "key_size".
 rsa_crypto (const basis::byte_array &key)
 constructs with the specified "key" as our private key.
 rsa_crypto (rsa_st *key)
 starts with a pre-existing "key" in the low-level form.
 rsa_crypto (const rsa_crypto &to_copy)
virtual ~rsa_crypto ()
const rsa_cryptooperator= (const rsa_crypto &to_copy)
 DEFINE_CLASS_NAME ("rsa_crypto")
bool set_key (basis::byte_array &key)
 resets this object's key to "key".
bool set_key (rsa_st *key)
 sets our new "key".
bool check_key (rsa_st *key)
 checks the RSA "key" provided for validity.
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 private_encrypt (const basis::byte_array &source, basis::byte_array &target) const
 encrypts "source" using our private key and stores it in "target".
bool public_decrypt (const basis::byte_array &source, basis::byte_array &target) const
 decrypts "source" using our public key and stores it in "target".
bool public_key (basis::byte_array &pubkey) const
 makes a copy of the public key held here.
bool private_key (basis::byte_array &privkey) const
 makes a copy of the private key held here.

Static Public Member Functions

static rsa_st * generate_key (int key_size)
 creates a random RSA key using the lower-level openssl methods.

Detailed Description

Supports public key encryption and decryption.

This class uses the OpenSSL package's support for RSA encryption.

Definition at line 31 of file rsa_crypto.h.


Constructor & Destructor Documentation

crypto::rsa_crypto::rsa_crypto ( int  key_size  ) 

constructs using a randomized private key of the "key_size".

the "key_size" must be at least 1024 bits for acceptable security. smaller keys are considered insecure.

Definition at line 48 of file rsa_crypto.cpp.

References generate_key().

crypto::rsa_crypto::rsa_crypto ( const basis::byte_array key  ) 

constructs with the specified "key" as our private key.

the "key" is used for encryption rather than generating a random one. the key is only valid if it was created with this class. also, if the key is a public key, then only the public_encryption and public_decryption methods will be available.

Definition at line 54 of file rsa_crypto.cpp.

References set_key(), and crypto::static_ssl_initializer().

crypto::rsa_crypto::rsa_crypto ( rsa_st *  key  ) 

starts with a pre-existing "key" in the low-level form.

Definition at line 62 of file rsa_crypto.cpp.

References set_key(), and crypto::static_ssl_initializer().

crypto::rsa_crypto::rsa_crypto ( const rsa_crypto to_copy  ) 

Definition at line 69 of file rsa_crypto.cpp.

References set_key(), and crypto::static_ssl_initializer().

crypto::rsa_crypto::~rsa_crypto (  )  [virtual]

Definition at line 77 of file rsa_crypto.cpp.


Member Function Documentation

bool crypto::rsa_crypto::check_key ( rsa_st *  key  ) 

checks the RSA "key" provided for validity.

Definition at line 102 of file rsa_crypto.cpp.

crypto::rsa_crypto::DEFINE_CLASS_NAME ( "rsa_crypto"   ) 
rsa_st * crypto::rsa_crypto::generate_key ( int  key_size  )  [static]

creates a random RSA key using the lower-level openssl methods.

Definition at line 89 of file rsa_crypto.cpp.

References continuable_error, FUNCDEF, NIL, static_class_name, and crypto::static_ssl_initializer().

Referenced by rsa_crypto().

const rsa_crypto & crypto::rsa_crypto::operator= ( const rsa_crypto to_copy  ) 

Definition at line 82 of file rsa_crypto.cpp.

References set_key().

bool crypto::rsa_crypto::private_decrypt ( const basis::byte_array source,
basis::byte_array target 
) const
bool crypto::rsa_crypto::private_encrypt ( const basis::byte_array source,
basis::byte_array target 
) const

encrypts "source" using our private key and stores it in "target".

private_encrypt and public_decrypt are also a pair. the trusted user with the private key can create encrypted chunks that anyone with the public key can decrypt.

Definition at line 269 of file rsa_crypto.cpp.

References basis::array< contents >::access(), basis::array< contents >::last(), basis::array< contents >::length(), and basis::array< contents >::reset().

bool crypto::rsa_crypto::private_key ( basis::byte_array privkey  )  const

makes a copy of the private key held here.

the private key should never be exposed to anyone else.

Definition at line 193 of file rsa_crypto.cpp.

References basis::array< contents >::access(), basis::attach(), basis::array< contents >::length(), and public_key().

Referenced by cromp::cromp_client::enable_encryption().

bool crypto::rsa_crypto::public_decrypt ( const basis::byte_array source,
basis::byte_array target 
) const

decrypts "source" using our public key and stores it in "target".

Definition at line 290 of file rsa_crypto.cpp.

References basis::array< contents >::access(), basis::array< contents >::last(), basis::array< contents >::length(), basis::array< contents >::reset(), and basis::array< contents >::zap().

bool crypto::rsa_crypto::public_encrypt ( const basis::byte_array source,
basis::byte_array target 
) const

encrypts "source" using our public key and stores it in "target".

public_encrypt and private_decrypt are a pair. an untrusted user can encrypt with the public key and only the possessor of the private key should be able to decrypt it.

Definition at line 224 of file rsa_crypto.cpp.

References basis::array< contents >::access(), basis::array< contents >::last(), basis::array< contents >::length(), and basis::array< contents >::reset().

Referenced by octopi::encryption_infoton::prepare_blowfish_key().

bool crypto::rsa_crypto::public_key ( basis::byte_array pubkey  )  const

makes a copy of the public key held here.

Definition at line 177 of file rsa_crypto.cpp.

References basis::array< contents >::access(), and basis::attach().

Referenced by octopi::encryption_infoton::prepare_public_key(), and private_key().

bool crypto::rsa_crypto::set_key ( rsa_st *  key  ) 

sets our new "key".

this must be a valid key created via the RSA algorithms.

Definition at line 159 of file rsa_crypto.cpp.

References continuable_error, FUNCDEF, NIL, and static_class_name.

bool crypto::rsa_crypto::set_key ( basis::byte_array key  ) 

resets this object's key to "key".

the key is only valid if this class created it. note: the "key" is destructively consumed during the set method; do not pass in your only copy.

Definition at line 104 of file rsa_crypto.cpp.

References basis::array< contents >::access(), continuable_error, structures::detach(), FUNCDEF, basis::array< contents >::length(), NIL, and static_class_name.

Referenced by operator=(), and rsa_crypto().


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