7#ifndef __HDI_CORE_CRYPT__
8#define __HDI_CORE_CRYPT__
19 class AESInitializationVector;
41 std::string
rot13(
const std::string& str_);
52 std::string
md5(
const std::string& str_);
63 std::string
sha1(
const std::string& str_);
118 typedef std::vector<byte> ByteVector;
176 Key(
const std::string& serializedKey_);
196 Key(
const int32_t size_,
const ByteVector& bytes_);
279 friend plat::AESKey* __accessImpl(
const Key&);
287 plat::AESKey* __impl;
297 typedef std::unique_ptr<Key> KeyUP;
298 typedef std::shared_ptr<Key> KeySP;
299 typedef std::weak_ptr<Key> KeyWP;
402 friend plat::AESInitializationVector* __accessImpl(
const InitVector&);
410 plat::AESInitializationVector* __impl;
413 typedef std::unique_ptr<InitVector> InitVectorUP;
414 typedef std::shared_ptr<InitVector> InitVectorSP;
415 typedef std::weak_ptr<InitVector> InitVectorWP;
417 extern plat::AESKey* __accessImpl(
const Key&);
418 extern plat::AESInitializationVector* __accessImpl(
const InitVector&);
632 plat::PublicRSAKey* __impl;
635 typedef std::unique_ptr<PublicKey> PublicKeyUP;
636 typedef std::shared_ptr<PublicKey> PublicKeySP;
637 typedef std::weak_ptr<PublicKey> PublicKeyWP;
759 plat::PrivateRSAKey* __impl;
762 typedef std::unique_ptr<PrivateKey> PrivateKeyUP;
763 typedef std::shared_ptr<PrivateKey> PrivateKeySP;
764 typedef std::weak_ptr<PrivateKey> PrivateKeyWP;
Wraps around an AES initialization vector's raw data for some added conveniences.
Definition: hdicoreCrypt.h:305
bool operator==(const InitVector &rhs_) const
Compares two InitVector objects for equality.
ByteVector bytes() const
Gets the raw bytes of the AES initialization vector.
friend 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.
friend 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...
bool operator!=(const InitVector &rhs_) const
Compares two InitVector objects for inequality.
virtual ~InitVector()
Destructs an InitVector object.
InitVector()
Constructs a new(ly generated) InitVector object for some random initialization vector values.
InitVector(const std::string &serializedIV_)
Constructs an InitVector object from a previous serialization of the initialization vector (using the...
std::string serialize() const
Serializes the initialization vector in a base-64 string; useful for transmitting the string to anoth...
InitVector & operator=(const InitVector &rhs_)
Assigns one InitVector object to another.
InitVector(const InitVector &iv_)
Constructs an InitVector object from another (copy constructor)
Wraps around an AES key's raw data for some added conveniences.
Definition: hdicoreCrypt.h:157
Key(const Key &key_)
Constructs a Key object from another (copy constructor)
Key & operator=(const Key &rhs_)
Assigns one Key object to another.
friend 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.
friend 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...
std::string serialize() const
Serializes the key in a base-64 string; useful for transmitting the string to another party or writin...
Key(const std::string &serializedKey_)
Constructs a Key object from a previous serialization of the key (using the serialize() method)
Key(const int32_t size_)
Constructs a new(ly generated) Key object of a given size/length.
ByteVector bytes() const
Gets the raw bytes of the AES key.
int32_t length() const
Gets the size/length of the key in bits.
virtual ~Key()
Destructs a Key object.
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.
bool operator==(const Key &rhs_) const
Compares two Key objects for equality.
bool valid() const
Gets whether the object contains a valid key.
bool operator!=(const Key &rhs_) const
Compares two Key objects for inequality.
Wraps around a private RSA key's raw data for some added conveniences.
Definition: hdicoreCrypt.h:643
int32_t length() const
Gets the size/length of the key in bits.
PrivateKey & operator=(const PrivateKey &rhs_)
Assigns one PrivateKey object to another.
friend bool encryptWithPublicKey(const PublicKey &, const std::string &, std::string &)
Encrypts a string (or raw bytes stuffed into a string) with a public RSA key.
PrivateKey(const std::string &serializedKey_)
Constructs a PrivateKey object from a previous serialization of the key (using the serialize() method...
bool operator!=(const PrivateKey &rhs_) const
Compares two PrivateKey objects for inequality.
friend bool generateKeyPair(const int32_t, PrivateKey &, PublicKey &)
Generates a new RSA key pair of a given size/length.
friend bool decryptWithPrivateKey(const PrivateKey &, const std::string &, std::string &)
Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPublicKey(...
friend bool decryptWithPublicKey(const PublicKey &, const std::string &, std::string &)
Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPrivateKey...
bool operator==(const PrivateKey &rhs_) const
Compares two PrivateKey objects for equality.
bool valid() const
Gets whether the object contains a valid key.
std::string serialize() const
Serializes the private key in a base-64 string; useful for transmitting the string to another party (...
PrivateKey()
Constructs an empty PrivateKey object.
virtual ~PrivateKey()
Destructs a PrivateKey object.
PrivateKey(const PrivateKey &key_)
Constructs a PrivateKey object from another (copy constructor)
friend bool encryptWithPrivateKey(const PrivateKey &, const std::string &, std::string &)
Encrypts a string (or raw bytes stuffed into a string) with a private RSA key.
Wraps around a public RSA key's raw data for some added conveniences.
Definition: hdicoreCrypt.h:517
PublicKey(const std::string &serializedKey_)
Constructs a PublicKey object from a previous serialization of the key (using the serialize() method)
friend bool encryptWithPublicKey(const PublicKey &, const std::string &, std::string &)
Encrypts a string (or raw bytes stuffed into a string) with a public RSA key.
bool operator!=(const PublicKey &rhs_) const
Compares two PublicKey objects for inequality.
int32_t length() const
Gets the length of the key in bits.
PublicKey()
Constructs an empty PublicKey object.
bool valid() const
Gets whether the object contains a valid key.
PublicKey & operator=(const PublicKey &rhs_)
Assigns one PublicKey object to another.
friend bool generateKeyPair(const int32_t, PrivateKey &, PublicKey &)
Generates a new RSA key pair of a given size/length.
friend bool decryptWithPrivateKey(const PrivateKey &, const std::string &, std::string &)
Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPublicKey(...
friend bool decryptWithPublicKey(const PublicKey &, const std::string &, std::string &)
Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPrivateKey...
bool operator==(const PublicKey &rhs_) const
Compares two PublicKey objects for equality.
std::string serialize() const
Serializes the public key in a base-64 string; useful for transmitting the string to another party or...
PublicKey(const PublicKey &key_)
Constructs a PublicKey object from another (copy constructor)
friend bool encryptWithPrivateKey(const PrivateKey &, const std::string &, std::string &)
Encrypts a string (or raw bytes stuffed into a string) with a private RSA key.
virtual ~PublicKey()
Destructs a PublicKey object.
Header file for a wide variety of necessary typedefs, enums, and forwards declarations.
bool decrypt(const Key &key_, const InitVector &iv_, const std::string &b64Cipher_, std::string &data__)
Decrypts a base-64 encoded string of cipher text (previously encrypted with the encrypt() function or...
bool encrypt(const Key &key_, const InitVector &iv_, const std::string &data_, std::string &b64Cipher__)
Encrypts a string (or raw bytes stuffed into a string) with an AES 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...
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(...
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.
std::string base64Encode(const std::string &plain_)
Base-64 encodes any data stuffed into a string.
std::string sha1(const std::string &str_)
Generates an SHA1 hash of a given source string.
std::string sha2_256(const std::string &str_)
Generates an SHA2-256 hash of a given source string.
std::string rot13(const std::string &str_)
Performs a rot-13 cipher (Caeser's cipher) on a string.
std::string md5(const std::string &str_)
Generates an MD5 hash of a given source string.
std::string base64Decode(const std::string &cipher_)
Decodes any data previously base-64 encoded.
std::string sha2_512(const std::string &str_)
Generates an SHA2-512 hash of a given source string.