::memset( keybuff, 0, algorithmlength * sizeof(unsigned char) );
const QByteArray salt = entry->salt();
// password should be UTF-8 encoded
- const QByteArray bytepass = m_password.toUtf8();
- gpg_error_t gcrypterror = gcry_kdf_derive(bytepass.constData(), bytepass.size(),
+ const QByteArray utf8pass = m_password.toUtf8();
+ gpg_error_t gcrypterror = gcry_kdf_derive(utf8pass.constData(), utf8pass.size(),
GCRY_KDF_PBKDF2, gcryptkeyalgorithm,
salt.constData(), salt.size(),
entry->iterationCount(), algorithmlength, keybuff);
gcrypterror = gcry_cipher_setkey( dec, keybuff, algorithmlength );
if ( gcrypterror != 0 ) {
kWarning(OooDebug) << "gcry_cipher_setkey: " << gcry_strerror(gcrypterror);
+ gcry_cipher_close( dec );
return;
}
gcrypterror = gcry_cipher_setiv( dec, initializationvector.constData(), initializationvector.size() );
if ( gcrypterror != 0 ) {
kWarning(OooDebug) << "gcry_cipher_setiv: " << gcry_strerror(gcrypterror);
+ gcry_cipher_close( dec );
return;
}
unsigned int decbufflen = fileData.size() * algorithmlength;
unsigned char decbuff[decbufflen];
::memset( decbuff, 0, decbufflen * sizeof(unsigned char) );
- gcry_cipher_decrypt( dec, decbuff, decbufflen, fileData.constData(), fileData.size() );
- gcry_cipher_final( dec );
+ gcrypterror = gcry_cipher_decrypt( dec, decbuff, decbufflen, fileData.constData(), fileData.size() );
+ if ( gcrypterror != 0 ) {
+ kWarning(OooDebug) << "gcry_cipher_decrypt: " << gcry_strerror(gcrypterror);
+ gcry_cipher_close( dec );
+ return;
+ }
+ gcrypterror = gcry_cipher_final( dec );
+ if ( gcrypterror != 0 ) {
+ kWarning(OooDebug) << "gcry_cipher_final: " << gcry_strerror(gcrypterror);
+ gcry_cipher_close( dec );
+ return;
+ }
gcry_cipher_close( dec );
const int size = entry->size().toInt();