From e26dbc56081f0578f51958ef00750a564d63b3f9 Mon Sep 17 00:00:00 2001 From: Carlo Teubner Date: Sat, 1 Jun 2024 20:53:35 +0100 Subject: [PATCH] Botan: don't call deprecated functions (#10826) * Botan: use raw_private_key_bits() if available Botan 3.x introduces raw_private_key_bits() as an alias for get_private_key(), and deprecates the latter. * Botan: use Cipher_Dir::Encryption Botan 3.x introduces Cipher_Dir::Encryption as an alias for Cipher_Dir::ENCRYPTION, and deprecates the latter. Likewise for Decryption/DECRYPTION. --- src/browser/BrowserPasskeys.cpp | 5 +++++ src/crypto/SymmetricCipher.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/browser/BrowserPasskeys.cpp b/src/browser/BrowserPasskeys.cpp index 3e81a25f7..059e1509c 100644 --- a/src/browser/BrowserPasskeys.cpp +++ b/src/browser/BrowserPasskeys.cpp @@ -19,6 +19,7 @@ #include "BrowserMessageBuilder.h" #include "BrowserService.h" #include "PasskeyUtils.h" +#include "config-keepassx.h" #include "crypto/Random.h" #include #include @@ -276,7 +277,11 @@ BrowserPasskeys::buildCredentialPrivateKey(int alg, const QString& predefinedFir try { Botan::Ed25519_PrivateKey key(*randomGen()->getRng()); auto publicKey = key.get_public_key(); +#ifdef WITH_XC_BOTAN3 + auto privateKey = key.raw_private_key_bits(); +#else auto privateKey = key.get_private_key(); +#endif firstPart = browserMessageBuilder()->getQByteArray(publicKey.data(), publicKey.size()); secondPart = browserMessageBuilder()->getQByteArray(privateKey.data(), privateKey.size()); diff --git a/src/crypto/SymmetricCipher.cpp b/src/crypto/SymmetricCipher.cpp index 1253763bc..f819bb3ec 100644 --- a/src/crypto/SymmetricCipher.cpp +++ b/src/crypto/SymmetricCipher.cpp @@ -34,7 +34,11 @@ bool SymmetricCipher::init(Mode mode, Direction direction, const QByteArray& key try { auto botanMode = modeToString(mode); auto botanDirection = +#ifdef WITH_XC_BOTAN3 + (direction == SymmetricCipher::Encrypt ? Botan::Cipher_Dir::Encryption : Botan::Cipher_Dir::Decryption); +#else (direction == SymmetricCipher::Encrypt ? Botan::Cipher_Dir::ENCRYPTION : Botan::Cipher_Dir::DECRYPTION); +#endif auto cipher = Botan::Cipher_Mode::create_or_throw(botanMode.toStdString(), botanDirection); m_cipher.reset(cipher.release());