mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-12 15:59:58 -05:00
Use the libgcrypt SALSA20 cipher if available.
This commit is contained in:
parent
eee909e948
commit
0b6b149351
@ -167,6 +167,10 @@ find_package(Qt4 4.6.0 REQUIRED ${QT_REQUIRED_MODULES})
|
|||||||
include(${QT_USE_FILE})
|
include(${QT_USE_FILE})
|
||||||
|
|
||||||
find_package(Gcrypt REQUIRED)
|
find_package(Gcrypt REQUIRED)
|
||||||
|
if(NOT (${GCRYPT_VERSION_STRING} VERSION_LESS "1.6.0"))
|
||||||
|
message(STATUS "Gcrypt ${GCRYPT_VERSION_STRING} supports the SALSA20 cipher")
|
||||||
|
set(GCRYPT_HAS_SALSA20 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
|
|
||||||
|
@ -53,15 +53,9 @@ set(keepassx_SOURCES
|
|||||||
crypto/Crypto.cpp
|
crypto/Crypto.cpp
|
||||||
crypto/CryptoHash.cpp
|
crypto/CryptoHash.cpp
|
||||||
crypto/Random.cpp
|
crypto/Random.cpp
|
||||||
crypto/salsa20/ecrypt-config.h
|
|
||||||
crypto/salsa20/ecrypt-machine.h
|
|
||||||
crypto/salsa20/ecrypt-portable.h
|
|
||||||
crypto/salsa20/ecrypt-sync.h
|
|
||||||
crypto/salsa20/salsa20.c
|
|
||||||
crypto/SymmetricCipher.cpp
|
crypto/SymmetricCipher.cpp
|
||||||
crypto/SymmetricCipherBackend.h
|
crypto/SymmetricCipherBackend.h
|
||||||
crypto/SymmetricCipherGcrypt.cpp
|
crypto/SymmetricCipherGcrypt.cpp
|
||||||
crypto/SymmetricCipherSalsa20.cpp
|
|
||||||
format/KeePass1.h
|
format/KeePass1.h
|
||||||
format/KeePass1Reader.cpp
|
format/KeePass1Reader.cpp
|
||||||
format/KeePass2.h
|
format/KeePass2.h
|
||||||
@ -117,6 +111,18 @@ set(keepassx_SOURCES
|
|||||||
streams/SymmetricCipherStream.cpp
|
streams/SymmetricCipherStream.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(NOT GCRYPT_HAS_SALSA20)
|
||||||
|
set(keepassx_SOURCES
|
||||||
|
${keepassx_SOURCES}
|
||||||
|
crypto/salsa20/ecrypt-config.h
|
||||||
|
crypto/salsa20/ecrypt-machine.h
|
||||||
|
crypto/salsa20/ecrypt-portable.h
|
||||||
|
crypto/salsa20/ecrypt-sync.h
|
||||||
|
crypto/salsa20/salsa20.c
|
||||||
|
crypto/SymmetricCipherSalsa20.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(keepassx_SOURCES_MAINEXE
|
set(keepassx_SOURCES_MAINEXE
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
|
@ -13,4 +13,6 @@
|
|||||||
#cmakedefine HAVE_RLIMIT_CORE 1
|
#cmakedefine HAVE_RLIMIT_CORE 1
|
||||||
#cmakedefine HAVE_PT_DENY_ATTACH 1
|
#cmakedefine HAVE_PT_DENY_ATTACH 1
|
||||||
|
|
||||||
|
#cmakedefine GCRYPT_HAS_SALSA20
|
||||||
|
|
||||||
#endif // KEEPASSX_CONFIG_H
|
#endif // KEEPASSX_CONFIG_H
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "SymmetricCipher.h"
|
#include "SymmetricCipher.h"
|
||||||
|
|
||||||
|
#include "config-keepassx.h"
|
||||||
#include "crypto/SymmetricCipherGcrypt.h"
|
#include "crypto/SymmetricCipherGcrypt.h"
|
||||||
#include "crypto/SymmetricCipherSalsa20.h"
|
#include "crypto/SymmetricCipherSalsa20.h"
|
||||||
|
|
||||||
@ -39,10 +40,15 @@ SymmetricCipherBackend* SymmetricCipher::createBackend(SymmetricCipher::Algorith
|
|||||||
switch (algo) {
|
switch (algo) {
|
||||||
case SymmetricCipher::Aes256:
|
case SymmetricCipher::Aes256:
|
||||||
case SymmetricCipher::Twofish:
|
case SymmetricCipher::Twofish:
|
||||||
|
#if defined(GCRYPT_HAS_SALSA20)
|
||||||
|
case SymmetricCipher::Salsa20:
|
||||||
|
#endif
|
||||||
return new SymmetricCipherGcrypt(algo, mode, direction);
|
return new SymmetricCipherGcrypt(algo, mode, direction);
|
||||||
|
|
||||||
|
#if !defined(GCRYPT_HAS_SALSA20)
|
||||||
case SymmetricCipher::Salsa20:
|
case SymmetricCipher::Salsa20:
|
||||||
return new SymmetricCipherSalsa20(algo, mode, direction);
|
return new SymmetricCipherSalsa20(algo, mode, direction);
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "SymmetricCipherGcrypt.h"
|
#include "SymmetricCipherGcrypt.h"
|
||||||
|
|
||||||
|
#include "config-keepassx.h"
|
||||||
#include "crypto/Crypto.h"
|
#include "crypto/Crypto.h"
|
||||||
|
|
||||||
SymmetricCipherGcrypt::SymmetricCipherGcrypt(SymmetricCipher::Algorithm algo, SymmetricCipher::Mode mode,
|
SymmetricCipherGcrypt::SymmetricCipherGcrypt(SymmetricCipher::Algorithm algo, SymmetricCipher::Mode mode,
|
||||||
@ -43,6 +44,11 @@ int SymmetricCipherGcrypt::gcryptAlgo(SymmetricCipher::Algorithm algo)
|
|||||||
case SymmetricCipher::Twofish:
|
case SymmetricCipher::Twofish:
|
||||||
return GCRY_CIPHER_TWOFISH;
|
return GCRY_CIPHER_TWOFISH;
|
||||||
|
|
||||||
|
#ifdef GCRYPT_HAS_SALSA20
|
||||||
|
case SymmetricCipher::Salsa20:
|
||||||
|
return GCRY_CIPHER_SALSA20;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
return -1;
|
return -1;
|
||||||
@ -58,6 +64,9 @@ int SymmetricCipherGcrypt::gcryptMode(SymmetricCipher::Mode mode)
|
|||||||
case SymmetricCipher::Cbc:
|
case SymmetricCipher::Cbc:
|
||||||
return GCRY_CIPHER_MODE_CBC;
|
return GCRY_CIPHER_MODE_CBC;
|
||||||
|
|
||||||
|
case SymmetricCipher::Stream:
|
||||||
|
return GCRY_CIPHER_MODE_STREAM;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user