dodo
0.0.1
A C++ library to create containerized Linux services
|
Go to the documentation of this file.
23 #ifndef common_datacrypt_hpp
24 #define common_datacrypt_hpp
29 #include <openssl/err.h>
99 case Cipher::Invalid :
return 0;
114 case Cipher::Invalid :
return 0;
129 case Cipher::Invalid :
return 0;
144 case Cipher::Invalid :
return 0;
159 case Cipher::Invalid :
return "Invalid cipher";
161 return "Invalid cipher";
173 else return Cipher::Invalid;
185 const std::string &key,
198 static int decrypt(
const std::string &key,
199 const std::string src,
222 static bool decode(
const std::string &src,
static int blockOctets(Cipher cipher)
Return the block size of the Cipher in octets.
static int keyOctets(Cipher cipher)
Return the size of the key for the given Cipher in bits.
static int decrypt(const std::string &key, const std::string src, Bytes &dest)
Decrypt data with a key.
An array of Octets with size elements.
static Cipher string2Cipher(const std::string &s)
Convert a string representation to an Cipher.
static void encrypt(Cipher cipher, const std::string &key, const Bytes &src, std::string &dst)
Encrypt data with a key into a string (so the encrypted data will not contain a 0/zero).
static size_t cipherOctets(Cipher cipher, size_t octets)
Calculate the size of the encrypted data from the input size.
static int ivOctets(Cipher cipher)
Return the size of the IV (initialization vector) for the given Cipher in bits.
static std::string cipher2String(const Cipher &cipher)
String representation of an Cipher instance.
Common and utility interfaces.
@ EVP_aes_128_gcm
https://www.openssl.org/docs/man1.0.2/man3/EVP_aes_128_gcm.html
static std::string paddedKey(Cipher cipher, const std::string key)
Pad or trim a key to match the key size for the Cipher.
@ EVP_aes_256_gcm
https://www.openssl.org/docs/man1.0.2/man3/EVP_aes_256_gcm.html
static bool decode(const std::string &src, std::string &cipher, std::string &data, std::string &iv, std::string &tag)
Decode an ENC[] string into its parts.
Interface to encrypt and decrypt Bytes data to/from a secure string.
static int tagLength(Cipher cipher)
Return the tag length of the Cipher in octets.
@ EVP_aes_192_gcm
https://www.openssl.org/docs/man1.0.2/man3/EVP_aes_192_gcm.html