Files
keepassxc/tests/TestKeys.h
T
oasaleh 469ab761ee Reject AES-KDF seeds that are not 32 bytes long
The seed of AES-KDF is the AES-256 key, but seeds of 8 to 31 bytes were
accepted from the KDF parameters of a KDBX 4 database. Botan then
rejected the key and the error was ignored, so the database key was
derived without any AES rounds, while the database settings still showed
the configured number of rounds. Saving the database kept the short
seed.

Require seeds of exactly 32 bytes, as the KDBX format specifies, and
fail the key derivation when the AES transformation fails. Mark
SymmetricCipher::aesKdf() Q_REQUIRED_RESULT, so that its result can't be
ignored again unnoticed.

KeeShare ignored a failure to set the key of an export. Now that the key
derivation can fail, for example when memory runs out, a signed export
that needs KDBX 4 would then be written with an empty key instead of the
share password. Abort the export instead.
2026-11-28 22:02:25 -05:00

44 lines
1.3 KiB
C++

/*
* Copyright (C) 2011 Felix Geyer <[email protected]>
* Copyright (C) 2017 KeePassXC Team <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSX_TESTKEYS_H
#define KEEPASSX_TESTKEYS_H
#include <QObject>
class TestKeys : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void testComposite();
void testFileKey();
void testFileKey_data();
void testCreateFileKey();
void testCreateAndOpenFileKey();
void testFileKeyHash();
void testFileKeyError();
void testCompositeKeyComponents();
void testAesKdfSeedSize();
void testAesKdfSeedSize_data();
void benchmarkTransformKey();
};
#endif // KEEPASSX_TESTKEYS_H