Wraps around an AES initialization vector's raw data for some added conveniences.
More...
#include <hdicoreCrypt.h>
|
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)
|
|
Wraps around an AES initialization vector's raw data for some added conveniences.
◆ 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
-
◆ 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
◆ 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=()
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.
◆ 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).