#include <rsa_crypto.h>
Inheritance diagram for RSA_crypto:


Public Member Functions | |
| RSA_crypto (int key_size) | |
| constructs using a randomized private key of the "key_size". | |
| RSA_crypto (const 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_crypto & | operator= (const RSA_crypto &to_copy) |
| IMPLEMENT_CLASS_NAME ("RSA_crypto") | |
| bool | set_key (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 byte_array &source, byte_array &target) const |
| encrypts "source" using our public key and stores it in "target". | |
| bool | private_decrypt (const byte_array &source, byte_array &target) const |
| decrypts "source" using our private key and stores it in "target". | |
| bool | private_encrypt (const byte_array &source, byte_array &target) const |
| encrypts "source" using our private key and stores it in "target". | |
| bool | public_decrypt (const byte_array &source, byte_array &target) const |
| decrypts "source" using our public key and stores it in "target". | |
| bool | public_key (byte_array &pubkey) const |
| makes a copy of the public key held here. | |
| bool | private_key (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. | |
This class uses the OpenSSL package's support for RSA encryption.
Definition at line 30 of file rsa_crypto.h.
| 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 45 of file rsa_crypto.cpp.
References generate_key().
| RSA_crypto::RSA_crypto | ( | const 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 51 of file rsa_crypto.cpp.
References set_key(), and static_ssl_initializer().
| RSA_crypto::RSA_crypto | ( | rsa_st * | key | ) |
starts with a pre-existing "key" in the low-level form.
Definition at line 59 of file rsa_crypto.cpp.
References set_key(), and static_ssl_initializer().
| RSA_crypto::RSA_crypto | ( | const RSA_crypto & | to_copy | ) |
Definition at line 66 of file rsa_crypto.cpp.
References _key, set_key(), and static_ssl_initializer().
| RSA_crypto::~RSA_crypto | ( | ) | [virtual] |
Definition at line 74 of file rsa_crypto.cpp.
| const RSA_crypto & RSA_crypto::operator= | ( | const RSA_crypto & | to_copy | ) |
| RSA_crypto::IMPLEMENT_CLASS_NAME | ( | "RSA_crypto" | ) |
| bool RSA_crypto::set_key | ( | 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 101 of file rsa_crypto.cpp.
References array< contents >::access(), continuable_error, basis::detach(), FUNCDEF, array< contents >::length(), NIL, and static_class_name.
Referenced by operator=(), and RSA_crypto().
| bool 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 156 of file rsa_crypto.cpp.
References continuable_error, FUNCDEF, NIL, and static_class_name.
| bool RSA_crypto::check_key | ( | rsa_st * | key | ) |
| bool RSA_crypto::public_encrypt | ( | const byte_array & | source, | |
| 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 221 of file rsa_crypto.cpp.
References array< contents >::access(), FUNCDEF, array< contents >::last(), array< contents >::length(), and array< contents >::reset().
Referenced by encryption_infoton::prepare_blowfish_key().
| bool RSA_crypto::private_decrypt | ( | const byte_array & | source, | |
| byte_array & | target | |||
| ) | const |
decrypts "source" using our private key and stores it in "target".
Definition at line 242 of file rsa_crypto.cpp.
References array< contents >::access(), FUNCDEF, array< contents >::last(), array< contents >::length(), array< contents >::reset(), and array< contents >::zap().
Referenced by encryption_infoton::extract_response().
| bool RSA_crypto::private_encrypt | ( | const byte_array & | source, | |
| 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 266 of file rsa_crypto.cpp.
References array< contents >::access(), FUNCDEF, array< contents >::last(), array< contents >::length(), and array< contents >::reset().
| bool RSA_crypto::public_decrypt | ( | const byte_array & | source, | |
| byte_array & | target | |||
| ) | const |
decrypts "source" using our public key and stores it in "target".
Definition at line 287 of file rsa_crypto.cpp.
References array< contents >::access(), FUNCDEF, array< contents >::last(), array< contents >::length(), array< contents >::reset(), and array< contents >::zap().
| bool RSA_crypto::public_key | ( | byte_array & | pubkey | ) | const |
makes a copy of the public key held here.
Definition at line 174 of file rsa_crypto.cpp.
References array< contents >::access(), basis::attach(), and FUNCDEF.
Referenced by encryption_infoton::prepare_public_key(), and private_key().
| bool RSA_crypto::private_key | ( | 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 190 of file rsa_crypto.cpp.
References array< contents >::access(), basis::attach(), FUNCDEF, array< contents >::length(), and public_key().
Referenced by cromp_client::enable_encryption().
| rsa_st * RSA_crypto::generate_key | ( | int | key_size | ) | [static] |
creates a random RSA key using the lower-level openssl methods.
Definition at line 86 of file rsa_crypto.cpp.
References continuable_error, FUNCDEF, NIL, static_class_name, and static_ssl_initializer().
Referenced by RSA_crypto().
1.5.1