-
Notifications
You must be signed in to change notification settings - Fork 5
QAEAD
BrutalWizard edited this page Dec 24, 2023
·
10 revisions
Example:
#include <QByteArray>
#include "QAEAD.h"
int main() {
QByteArray key = "AABBCCEEFFGGHHKKLLMMNNOOPPRRSSTT";
QByteArray iv = "AABBCCEEFFGGHHKKLLMMNNOOPPRRSSTT";
QByteArray aad = "AABBCCDDEEFF";
QByteArray tag = "AABBCCDDEEFF";
QSimpleCrypto::QAEAD aead;
QByteArray encrypted = aead.encryptAesGcm("Hello World", key, iv, &tag, aad);
QByteArray decrypted = aead.decryptAesGcm(bytes, key, iv, &tag, aad);
}
QByteArray encryptAesGcm(QByteArray data, QByteArray key, QByteArray iv, QByteArray* tag, QByteArray aad = "", const EVP_CIPHER* cipher = EVP_aes_256_gcm())
- data - Data that will be encrypted.
- key - AES key. Example: "AABBCCEEFFGGHHKKLLMMNNOOPPRRSSTT"
- iv - Initialization vector. Example: "AABBCCEEFFGGHHKKLLMMNNOOPPRRSSTT"
- tag - Authorization tag. Example: "AABBCCDDEEFF"
- aad - Additional authenticated data. Must be nullptr, if not used
- cipher - Can be used with OpenSSL EVP_CIPHER (gcm) - 128, 192, 256. Example: EVP_aes_256_gcm()
Returns encrypted data on success and "" on failure.
QByteArray decryptAesGcm(QByteArray data, QByteArray key, QByteArray iv, QByteArray* tag, QByteArray aad = "", const EVP_CIPHER* cipher = EVP_aes_256_gcm())
- data - Data that will be decrypted
- key - AES key. Example: "AABBCCEEFFGGHHKKLLMMNNOOPPRRSSTT"
- iv - Initialization vector. Example: "AABBCCEEFFGGHHKKLLMMNNOOPPRRSSTT"
- tag - Authorization tag. Example: "AABBCCDDEEFF"
- aad - Additional authenticated data. Must be nullptr, if not used
- cipher - Can be used with OpenSSL EVP_CIPHER (gcm) - 128, 192, 256. Example: EVP_aes_256_gcm()
Returns decrypted data on success and "" on failure.
QByteArray encryptAesCcm(QByteArray data, QByteArray key, QByteArray iv, QByteArray* tag, QByteArray aad = "", const EVP_CIPHER* cipher = EVP_aes_256_ccm())
- data - Data that will be encrypted
- key - AES key
- iv - Initialization vector (7 bytes)
- tag - Authorization tag (12 bytes)
- aad - Additional authenticated data. Must be nullptr, if not used
- cipher - Can be used with OpenSSL EVP_CIPHER (ccm) - 128, 192, 256. Example: EVP_aes_256_ccm()
Returns encrypted data on success and "" on failure.
QByteArray decryptAesCcm(QByteArray data, QByteArray key, QByteArray iv, QByteArray* tag, QByteArray aad = "", const EVP_CIPHER* cipher = EVP_aes_256_ccm())
- data - Data that will be decrypted
- key - AES key
- iv - Initialization vector (7 bytes)
- tag - Authorization tag (12 bytes)
- aad - Additional authenticated data. Must be nullptr, if not used
- cipher - Can be used with OpenSSL EVP_CIPHER (ccm) - 128, 192, 256. Example: EVP_aes_256_ccm()
Returns decrypted data on success and "" on failure.