Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
Loading...
Searching...
No Matches
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.
 
 InitVector (const InitVector &iv_)
 Constructs an InitVector object from another (copy constructor)
 
 InitVector (const std::string &serializedIV_)
 Constructs an InitVector object from a previous serialization of the initialization vector (using the serialize() method)
 
virtual ~InitVector ()
 Destructs an InitVector object.
 
InitVectoroperator= (const InitVector &rhs_)
 Assigns one InitVector object to another.
 
ByteVector bytes () const
 Gets the raw bytes of the AES initialization vector.
 
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.
 
bool operator== (const InitVector &rhs_) const
 Compares two InitVector objects for equality.
 
bool operator!= (const InitVector &rhs_) const
 Compares two InitVector objects for inequality.
 

Friends

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

Detailed Description

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

Constructor & Destructor Documentation

◆ InitVector() [1/3]

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

◆ InitVector() [2/3]

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

◆ InitVector() [3/3]

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

◆ ~InitVector()

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

Destructs an InitVector object.

Author
GW
Date
10/2013

Member Function Documentation

◆ bytes()

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

◆ operator!=()

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

◆ operator=()

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

◆ operator==()

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

◆ serialize()

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

◆ decrypt

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

◆ encrypt

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