-
Notifications
You must be signed in to change notification settings - Fork 5
QAEAD
BrutalWizard edited this page Sep 21, 2020
·
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
- iv - Initialization vector
- tag - Authorization tag
- 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
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
- iv - Initialization vector
- tag - Authorization tag
- 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
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
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