Add support for Twofish in KeePass2 code

This commit is contained in:
Timothy Redaelli
2015-08-04 15:18:41 +02:00
committed by Janek Bevendorff
parent a3fd3205a9
commit a01607e869
5 changed files with 29 additions and 4 deletions

View File

@@ -83,3 +83,23 @@ QString SymmetricCipher::errorString() const
{
return m_backend->errorString();
}
SymmetricCipher::Algorithm SymmetricCipher::cipherToAlgorithm(Uuid cipher)
{
if (cipher == KeePass2::CIPHER_AES) {
return SymmetricCipher::Aes256;
}
else {
return SymmetricCipher::Twofish;
}
}
Uuid SymmetricCipher::algorithmToCipher(SymmetricCipher::Algorithm algo)
{
switch (algo) {
case SymmetricCipher::Aes256:
return KeePass2::CIPHER_AES;
default:
return KeePass2::CIPHER_TWOFISH;
}
}

View File

@@ -23,6 +23,7 @@
#include <QString>
#include "crypto/SymmetricCipherBackend.h"
#include "format/KeePass2.h"
class SymmetricCipher
{
@@ -71,6 +72,9 @@ public:
int blockSize() const;
QString errorString() const;
static SymmetricCipher::Algorithm cipherToAlgorithm(Uuid cipher);
static Uuid algorithmToCipher(SymmetricCipher::Algorithm algo);
private:
static SymmetricCipherBackend* createBackend(SymmetricCipher::Algorithm algo, SymmetricCipher::Mode mode,
SymmetricCipher::Direction direction);