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

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

#include <hdicoreCrypt.h>

Public Member Functions

 InitVector ()
 Constructs a new(ly generated) InitVector object for some random initialization vector values. More...
 
 InitVector (const InitVector &iv_)
 Constructs an InitVector object from another (copy constructor) More...
 
 InitVector (const std::string &serializedIV_)
 Constructs an InitVector object from a previous serialization of the initialization vector (using the serialize() method) More...
 
virtual ~InitVector ()
 Destructs an InitVector object. More...
 
InitVectoroperator= (const InitVector &rhs_)
 Assigns one InitVector object to another. More...
 
ByteVector bytes () const
 Gets the raw bytes of the AES initialization vector. More...
 
std::string serialize () const
 Serializes the initialization vector in a base-64 string; useful for transmitting the string to another party or writing the IV to disk. More...
 
bool operator== (const InitVector &rhs_) const
 Compares two InitVector objects for equality. More...
 
bool operator!= (const InitVector &rhs_) const
 Compares two InitVector objects for inequality. More...
 

Friends

plugin::AESInitializationVector * __accessImpl (const InitVector &)
 
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 initialization vector's raw data for some added conveniences.

Constructor & Destructor Documentation

hdi::core::crypt::aes::InitVector::InitVector ( )

Constructs a new(ly generated) InitVector object for some random initialization vector values.

Author
GW
Date
10/2013
Note
Initialization vectors are used to ensure that indentical plain values encoded with indentical keys do not result in indentical cipher values.
Always use same vector for one encryption and decryption operation, but generate a new vector each time something new is encrypted with the same key (see note above!)
hdi::core::crypt::aes::InitVector::InitVector ( const InitVector iv_)

Constructs an InitVector object from another (copy constructor)

Author
GW
Date
10/2013
Parameters
iv_InitVector object to copy values from
hdi::core::crypt::aes::InitVector::InitVector ( const std::string &  serializedIV_)

Constructs an InitVector object from a previous serialization of the initialization vector (using the serialize() method)

Author
GW
Date
10/2013
Parameters
serializedIV_Base-64 encoded serialization of an AES initialization vector
virtual hdi::core::crypt::aes::InitVector::~InitVector ( )
virtual

Destructs an InitVector object.

Author
GW
Date
10/2013

Member Function Documentation

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

Gets the raw bytes of the AES initialization vector.

Author
GW
Date
10/2013
Returns
A container of all the raw byte values of the AES init vector
bool hdi::core::crypt::aes::InitVector::operator!= ( const InitVector rhs_) const

Compares two InitVector objects for inequality.

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

Assigns one InitVector object to another.

Author
GW
Date
10/2013
Parameters
rhs_Righthand side of the assignment operator; InitVector 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::InitVector::operator== ( const InitVector rhs_) const

Compares two InitVector objects for equality.

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

Serializes the initialization vector in a base-64 string; useful for transmitting the string to another party or writing the IV to disk.

Author
GW
Date
10/2013
Returns
The serialized version of the initialization vector
Note
An InitVector serialization string can be converted back into an IV object at runtime with the InitVector(const std::string&) constructor.

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).