[cse] Call the encrypt and decrypt functions on fake data

This commit is contained in:
Tomaz Canabrava 2017-09-15 17:38:20 +02:00 committed by Roeland Jago Douma
parent e0d368cbb3
commit ba3d2a61d5
No known key found for this signature in database
GPG key ID: F941078878347C0C

View file

@ -432,8 +432,37 @@ void ClientSideEncryption::encryptPrivateKey(EVP_PKEY *keyPair)
//: FIRST TRY A SILLY PHRASE. //: FIRST TRY A SILLY PHRASE.
//: Hardcoed IV, really bad. //: Hardcoed IV, really bad.
unsigned char *iv = (unsigned char *)"0123456789012345"; unsigned char *iv = (unsigned char *)"0123456789012345";
const EVP_CIPHER *cipher = EVP_aes_256_gcm (); unsigned char encryptTag[16];
const char *encryptTest = "a quick brown fox jumps over the lazy dog";
// TODO: Find a way to
unsigned char cryptedText[128];
unsigned char decryptedText[128];
unsigned char tag[16];
int cryptedText_len = encrypt(
(unsigned char*) encryptTest, //unsigned char *plaintext,
strlen(encryptTest), // int plaintext_len,
nullptr, // unsigned char *aad,
0, // int aad_len,
secretKey, // unsigned char *key,
iv, // unsigned char *iv,
cryptedText, // unsigned char *ciphertext,
tag // unsigned char *tag
);
qCInfo(lcCse()) << "Encrypted Text" << QByteArray( (const char*) cryptedText, cryptedText_len);
int decryptedText_len = decrypt(
cryptedText, //unsigned char *ciphertext,
cryptedText_len, //int ciphertext_len,
NULL, //unsigned char *aad,
0, //int aad_len,
tag, //unsigned char *tag,
secretKey, //unsigned char *key,
iv, //unsigned char *iv,
decryptedText //unsigned char *plaintext
);
qCInfo(lcCse()) << "Decrypted Text" << QByteArray( (const char*) decryptedText, decryptedText_len);
// Now, Try to encrypt it. // Now, Try to encrypt it.
} }