Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
Public Member Functions | Friends | List of all members
hdi::core::crypt::aes::Key Class Reference

Wraps around an AES key's raw data for some added conveniences. More...

#include <hdicoreCrypt.h>

Public Member Functions

 Key (const Key &key_)
 Constructs a Key object from another (copy constructor) More...
 
 Key (const std::string &serializedKey_)
 Constructs a Key object from a previous serialization of the key (using the serialize() method) More...
 
 Key (const int32_t size_)
 Constructs a new(ly generated) Key object of a given size/length. More...
 
 Key (const int32_t size_, const ByteVector &bytes_)
 Constructs a new(ly generated) Key object of a given size/length and a predetermined set of bytes. More...
 
virtual ~Key ()
 Destructs a Key object. More...
 
Keyoperator= (const Key &rhs_)
 Assigns one Key object to another. More...
 
bool valid () const
 Gets whether the object contains a valid key. More...
 
int32_t length () const
 Gets the size/length of the key in bits. More...
 
ByteVector bytes () const
 Gets the raw bytes of the AES key. More...
 
std::string serialize () const
 Serializes the key in a base-64 string; useful for transmitting the string to another party or writing the key to disk (not recommended without encrypting it first!) More...
 
bool operator== (const Key &rhs_) const
 Compares two Key objects for equality. More...
 
bool operator!= (const Key &rhs_) const
 Compares two Key objects for inequality. More...
 

Friends

plugin::AESKey * __accessImpl (const Key &)
 
bool encrypt (const Key &, const InitVector &, const std::string &, std::string &)
 Encrypts a string (or raw bytes stuffed into a string) with an AES key. More...
 
bool decrypt (const Key &, const InitVector &, const std::string &, std::string &)
 Decrypts a base-64 encoded string of cipher text (previously encrypted with the encrypt() function or equivalent) More...
 

Detailed Description

Wraps around an AES key's raw data for some added conveniences.

Constructor & Destructor Documentation

hdi::core::crypt::aes::Key::Key ( const Key key_)

Constructs a Key object from another (copy constructor)

Author
GW
Date
10/2013
Parameters
key_Key object to copy values from
hdi::core::crypt::aes::Key::Key ( const std::string &  serializedKey_)

Constructs a Key object from a previous serialization of the key (using the serialize() method)

Author
GW
Date
10/2013
Parameters
serializedKey_Base-64 encoded serialization of an AES key
hdi::core::crypt::aes::Key::Key ( const int32_t  size_)

Constructs a new(ly generated) Key object of a given size/length.

Author
GW
Date
10/2013
Parameters
size_Size/length of the key in bits (must be 128, 192, or 256)
hdi::core::crypt::aes::Key::Key ( const int32_t  size_,
const ByteVector &  bytes_ 
)

Constructs a new(ly generated) Key object of a given size/length and a predetermined set of bytes.

Author
GW
Date
10/2013
Parameters
size_Size/length of the key in bits (must be 128, 192, or 256)
bytes_Raw bytes to use for the AES key (must contain size_/8 bytes)
virtual hdi::core::crypt::aes::Key::~Key ( )
virtual

Destructs a Key object.

Author
GW
Date
10/2013

Member Function Documentation

ByteVector hdi::core::crypt::aes::Key::bytes ( ) const

Gets the raw bytes of the AES key.

Author
GW
Date
10/2013
Returns
A container of all the raw byte values of the AES key
int32_t hdi::core::crypt::aes::Key::length ( ) const

Gets the size/length of the key in bits.

Author
GW
Date
10/2013
Returns
The number of bits for the key
bool hdi::core::crypt::aes::Key::operator!= ( const Key rhs_) const

Compares two Key objects for inequality.

Author
GW
Date
10/2013
Parameters
rhs_Righthand side of the inequality operator; Key object to compare against
Returns
true if the two objects have differing key values, false otherwise
Key& hdi::core::crypt::aes::Key::operator= ( const Key rhs_)

Assigns one Key object to another.

Author
GW
Date
10/2013
Parameters
rhs_Righthand side of the assignment operator; key object to copy values from
Returns
A reference to the target object (lefthand side of assignment operator), but with its values updated
bool hdi::core::crypt::aes::Key::operator== ( const Key rhs_) const

Compares two Key objects for equality.

Author
GW
Date
10/2013
Parameters
rhs_Righthand side of the equality operator; Key object to compare against
Returns
true if the two objects have the same key values, false otherwise
std::string hdi::core::crypt::aes::Key::serialize ( ) const

Serializes the key in a base-64 string; useful for transmitting the string to another party or writing the key to disk (not recommended without encrypting it first!)

Author
GW
Date
10/2013
Returns
The serialized version of the key
Note
A key serialization string can be converted back into a Key object at runtime with the Key(const std::string&) constructor.
bool hdi::core::crypt::aes::Key::valid ( ) const

Gets whether the object contains a valid key.

Author
GW
Date
10/2013
Returns
true if the key is valid/not empty, false otherwise

Friends And Related Function Documentation

bool decrypt ( const Key ,
const InitVector ,
const std::string &  ,
std::string &   
)
friend

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

Author
GW
Date
10/2013
Parameters
key_AES key to use for decryption
iv_Initialization vector to use for this decryption call
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
bool encrypt ( const Key ,
const InitVector ,
const std::string &  ,
std::string &   
)
friend

Encrypts a string (or raw bytes stuffed into a string) with an AES key.

Author
GW
Date
10/2013
Parameters
key_AES key to use for encryption
iv_Initialization vector to use for this encryption call
data_Plain data to be encrypted (in the form of a string or binary data 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 decrypt() function (or equivalent - this lib is built on OpenSSL and the AES standard, so any base-64 decoder and function that understands AES decryption can decrypt the cipher with the correct key and initialization vector).