Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
hdi::core::crypt::rsa Namespace Reference

Organizes all RSA functionality into one namespace for convenience. More...

Classes

class  PrivateKey
 Wraps around a private RSA key's raw data for some added conveniences. More...
 
class  PublicKey
 Wraps around a public RSA key's raw data for some added conveniences. More...
 

Typedefs

typedef std::unique_ptr< PublicKeyPublicKeyUP
 
typedef std::shared_ptr< PublicKeyPublicKeySP
 
typedef std::weak_ptr< PublicKeyPublicKeyWP
 
typedef std::unique_ptr< PrivateKeyPrivateKeyUP
 
typedef std::shared_ptr< PrivateKeyPrivateKeySP
 
typedef std::weak_ptr< PrivateKeyPrivateKeyWP
 

Functions

bool generateKeyPair (const int32_t size_, PrivateKey &privKey__, PublicKey &pubKey__)
 Generates a new RSA key pair of a given size/length.
 
bool encryptWithPublicKey (const PublicKey &key_, const std::string &data_, std::string &b64Cipher__)
 Encrypts a string (or raw bytes stuffed into a string) with a public RSA key.
 
bool decryptWithPrivateKey (const PrivateKey &key_, const std::string &b64Cipher_, std::string &data__)
 Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPublicKey() function or equivalent)
 
bool encryptWithPrivateKey (const PrivateKey &key_, const std::string &data_, std::string &b64Cipher__)
 Encrypts a string (or raw bytes stuffed into a string) with a private RSA key.
 
bool decryptWithPublicKey (const PublicKey &key_, const std::string &b64Cipher_, std::string &data__)
 Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPrivateKey() function or equivalent)
 

Detailed Description

Organizes all RSA functionality into one namespace for convenience.

Function Documentation

◆ decryptWithPrivateKey()

bool hdi::core::crypt::rsa::decryptWithPrivateKey ( const PrivateKey key_,
const std::string &  b64Cipher_,
std::string &  data__ 
)

Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPublicKey() function or equivalent)

Author
GW
Date
10/2013
Parameters
key_Private RSA key to use for decryption
b64Cipher_Base-64 encoded cipher text to attempt to decrypt
data__Return-by-reference for the decrypted plain text (or raw bytes stuffed into a string)
Returns
true if the data could be decrypted, false otherwise

◆ decryptWithPublicKey()

bool hdi::core::crypt::rsa::decryptWithPublicKey ( const PublicKey key_,
const std::string &  b64Cipher_,
std::string &  data__ 
)

Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPrivateKey() function or equivalent)

Author
GW
Date
10/2013
Parameters
key_Public RSA key to use for decryption
b64Cipher_Base-64 encoded cipher text to attempt to decrypt
data__Return-by-reference for the decrypted plain text (or raw bytes stuffed into a string)
Returns
true if the data could be decrypted, false otherwise

◆ encryptWithPrivateKey()

bool hdi::core::crypt::rsa::encryptWithPrivateKey ( const PrivateKey key_,
const std::string &  data_,
std::string &  b64Cipher__ 
)

Encrypts a string (or raw bytes stuffed into a string) with a private RSA key.

Author
GW
Date
10/2013
Parameters
key_Private RSA key to use for encryption
data_Plain data to be encrypted (in the form of a string or binary data put inside of a string object)
b64Cipher__Return-by-reference for the base-64 encoded cipher text
Returns
true if the data could be encrypted, false otherwise
Note
To decrypt the cipher, use the decryptWithPublicKey() function (or equivalent - this lib is built on OpenSSL and the RSA standard, so any base-64 decoder and function that understands RSA private key decryption can decrypt the cipher with the correct key).
Typically, sensitive data is not encrypted with a private key because anyone with the public key can decrypt it. However, "signing" (encrypting) some token data with a private key is a common practice to prove to a holder of the public key that the true owner of the private key e.g. received a message and is responding to it (as only the holder of the private key could do this).

◆ encryptWithPublicKey()

bool hdi::core::crypt::rsa::encryptWithPublicKey ( const PublicKey key_,
const std::string &  data_,
std::string &  b64Cipher__ 
)

Encrypts a string (or raw bytes stuffed into a string) with a public RSA key.

Author
GW
Date
10/2013
Parameters
key_Public RSA key to use for encryption
data_Plain data to be encrypted (in the form of a string or binary data put inside of a string object)
b64Cipher__Return-by-reference for the base-64 encoded cipher text
Returns
true if the data could be encrypted, false otherwise
Note
To decrypt the cipher, use the decryptWithPrivateKey() function (or equivalent - this lib is built on OpenSSL and the RSA standard, so any base-64 decoder and function that understands RSA private key decryption can decrypt the cipher with the correct key).

◆ generateKeyPair()

bool hdi::core::crypt::rsa::generateKeyPair ( const int32_t  size_,
PrivateKey privKey__,
PublicKey pubKey__ 
)

Generates a new RSA key pair of a given size/length.

Author
GW
Date
10/2013
Parameters
size_Size/length of the key in bits (must be n*1024; not recommended for n>16)
privKey__Return-by-reference for the new private key
pubKey__Return-by-reference for the new public key
Returns
true if the key pair could be generated, false otherwise
Note
A minimum key size of 2048 bits is recommended.