diff options
author | Tobias Fella <9750016+TobiasFella@users.noreply.github.com> | 2022-05-20 20:33:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-20 20:33:12 +0200 |
commit | 59f2b60835752fc87e75f456145d21cc5f77a433 (patch) | |
tree | 235b45618ca593818616c4955c352a4585302e64 /lib/events | |
parent | 44f34c60fe1f1dde859655bbda86221b6cec4811 (diff) | |
download | libquotient-59f2b60835752fc87e75f456145d21cc5f77a433.tar.gz libquotient-59f2b60835752fc87e75f456145d21cc5f77a433.zip |
Apply suggestions from code review
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
Diffstat (limited to 'lib/events')
-rw-r--r-- | lib/events/encryptedfile.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/events/encryptedfile.cpp b/lib/events/encryptedfile.cpp index 140dca7f..33ebb514 100644 --- a/lib/events/encryptedfile.cpp +++ b/lib/events/encryptedfile.cpp @@ -64,10 +64,10 @@ std::pair<EncryptedFile, QByteArray> EncryptedFile::encryptFile(const QByteArray int length; auto* ctx = EVP_CIPHER_CTX_new(); - QByteArray cipherText(plainText.size() + EVP_MAX_BLOCK_LENGTH - 1, '\0'); EVP_EncryptInit_ex(ctx, EVP_aes_256_ctr(), nullptr, reinterpret_cast<const unsigned char*>(k.data()),reinterpret_cast<const unsigned char*>(iv.data())); + const auto blockSize = EVP_CIPHER_CTX_block_size(ctx); + QByteArray cipherText(plainText.size() + blockSize - 1, '\0'); EVP_EncryptUpdate(ctx, reinterpret_cast<unsigned char*>(cipherText.data()), &length, reinterpret_cast<const unsigned char*>(plainText.data()), plainText.size()); - cipherText.resize(length); EVP_EncryptFinal_ex(ctx, reinterpret_cast<unsigned char*>(cipherText.data()) + length, &length); EVP_CIPHER_CTX_free(ctx); |