[arch-commits] Commit in qca/trunk (PKGBUILD qca-botan2.patch)

Antonio Rojas arojas at archlinux.org
Fri Apr 6 21:03:32 UTC 2018


    Date: Friday, April 6, 2018 @ 21:03:31
  Author: arojas
Revision: 321275

Add botan 2 support

Added:
  qca/trunk/qca-botan2.patch
Modified:
  qca/trunk/PKGBUILD

------------------+
 PKGBUILD         |   17 ++-
 qca-botan2.patch |  241 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 251 insertions(+), 7 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2018-04-06 20:55:39 UTC (rev 321274)
+++ PKGBUILD	2018-04-06 21:03:31 UTC (rev 321275)
@@ -6,15 +6,16 @@
 pkgbase=qca
 pkgname=(qca-qt4 qca-qt5)
 pkgver=2.1.3
-pkgrel=6
+pkgrel=7
 pkgdesc="Qt Cryptographic Architecture"
 arch=(x86_64)
 url="http://delta.affinix.com/qca/"
 license=(LGPL)
-makedepends=(qt4 qt5-base cmake doxygen nss pkcs11-helper botan1.10)
-source=("http://download.kde.org/stable/$pkgbase/$pkgver/src/$pkgbase-$pkgver.tar.xz" qca-openssl-1.1.patch)
+makedepends=(qt4 qt5-base cmake doxygen nss pkcs11-helper botan)
+source=("http://download.kde.org/stable/$pkgbase/$pkgver/src/$pkgbase-$pkgver.tar.xz" qca-openssl-1.1.patch qca-botan2.patch)
 sha256sums=('003fd86a32421057a03b18a8168db52e2940978f9db5ebbb6a08882f8ab1e353'
-            'b1505bc313fd2f4e350cd4c94af69256c901afa419ae6700b208cb6e40e6926d')
+            'b1505bc313fd2f4e350cd4c94af69256c901afa419ae6700b208cb6e40e6926d'
+            'f5132f3bc1c5098a583311d73b93ceef1d0c353cd15d02703e142045bd3ae7ea')
 
 prepare() {
   mkdir -p build{4,5}
@@ -21,6 +22,7 @@
 
   cd $pkgbase-$pkgver
   patch -p1 -i ../qca-openssl-1.1.patch # Fix build with OpenSSL 1.1 https://bugs.kde.org/show_bug.cgi?id=379810
+  patch -p1 -i ../qca-botan2.patch      # Fix build with botan 2
 }
 
 build() {
@@ -31,7 +33,8 @@
     -DBUILD_TESTS=OFF \
     -DQCA_LIBRARY_INSTALL_DIR=/usr/lib \
     -DQCA_FEATURE_INSTALL_DIR=/usr/share/qt4/mkspecs/features/ \
-    -DQT4_BUILD=ON
+    -DQT4_BUILD=ON \
+    -DWITH_botan_PLUGIN=OFF
   make
 
   cd ../build5
@@ -46,7 +49,7 @@
 
 package_qca-qt4() {
   depends=(qt4 nss)
-  optdepends=('pkcs11-helper: PKCS-11 plugin' 'botan1.10: botan plugin')
+  optdepends=('pkcs11-helper: PKCS-11 plugin')
   conflicts=(qca qca-gnupg qca-ossl)
   provides=(qca qca-gnupg qca-ossl)
   replaces=(qca qca-gnupg qca-ossl)
@@ -57,7 +60,7 @@
 
 package_qca-qt5() {
   depends=(qt5-base nss ca-certificates)
-  optdepends=('pkcs11-helper: PKCS-11 plugin' 'botan1.10: botan plugin')
+  optdepends=('pkcs11-helper: PKCS-11 plugin' 'botan: botan plugin')
 
   cd build5
   make DESTDIR="$pkgdir" install

Added: qca-botan2.patch
===================================================================
--- qca-botan2.patch	                        (rev 0)
+++ qca-botan2.patch	2018-04-06 21:03:31 UTC (rev 321275)
@@ -0,0 +1,241 @@
+diff --git a/cmake/modules/FindBotan.cmake b/cmake/modules/FindBotan.cmake
+index 0c4e24b..ce92df5 100644
+--- a/cmake/modules/FindBotan.cmake
++++ b/cmake/modules/FindBotan.cmake
+@@ -11,30 +11,12 @@
+ # Redistribution and use is allowed according to the terms of the BSD license.
+ # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+ 
+-# libgcrypt is moving to pkg-config, but earlier version don't have it
+-
+-#search in typical paths for libgcrypt-config
+-FIND_PROGRAM(BOTANCONFIG_EXECUTABLE NAMES botan-config botan-config-1.10)
+-mark_as_advanced(BOTANCONFIG_EXECUTABLE)
+-
+ #reset variables
+ set(BOTAN_LIBRARIES)
+ set(BOTAN_CFLAGS)
+ 
+-# if botan-config has been found
+-IF(BOTANCONFIG_EXECUTABLE)
+-
+-  EXEC_PROGRAM(${BOTANCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE BOTAN_LIBRARIES)
+-
+-  EXEC_PROGRAM(${BOTANCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE BOTAN_CFLAGS)
+-
+-  IF(BOTAN_LIBRARIES)
+-    SET(BOTAN_FOUND TRUE)
+-  ENDIF(BOTAN_LIBRARIES)
+-
+-  MARK_AS_ADVANCED(BOTAN_CFLAGS BOTAN_LIBRARIES)
+-
+-ENDIF(BOTANCONFIG_EXECUTABLE)
++find_package(PkgConfig)
++pkg_search_module(BOTAN REQUIRED botan>=1.10 botan-1.10 botan-2)
+ 
+ if (BOTAN_FOUND)
+    if (NOT Botan_FIND_QUIETLY)
+diff --git a/plugins/qca-botan/qca-botan.cpp b/plugins/qca-botan/qca-botan.cpp
+index f387575..ab28e57 100644
+--- a/plugins/qca-botan/qca-botan.cpp
++++ b/plugins/qca-botan/qca-botan.cpp
+@@ -23,13 +23,18 @@
+ 
+ #include <qstringlist.h>
+ 
+-#include <botan/botan.h>
+ #include <botan/hmac.h>
+-#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,0)
+-#include <botan/s2k.h>
+-#endif
+-#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,8,0)
++#include <botan/version.h>
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
++#include <botan/botan.h>
+ #include <botan/algo_factory.h>
++#else
++#include <botan/auto_rng.h>
++#include <botan/block_cipher.h>
++#include <botan/filters.h>
++#include <botan/hash.h>
++#include <botan/pbkdf.h>
++#include <botan/stream_cipher.h>
+ #endif
+ 
+ #include <stdlib.h>
+@@ -51,14 +56,8 @@ public:
+     QCA::SecureArray nextBytes(int size)
+     {
+         QCA::SecureArray buf(size);
+-#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,5,0)
+-	Botan::Global_RNG::randomize( (Botan::byte*)buf.data(), buf.size(), Botan::SessionKey );
+-#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,6)
+-	Botan::Global_RNG::randomize( (Botan::byte*)buf.data(), buf.size() );
+-#else
+ 	Botan::AutoSeeded_RNG rng;
+ 	rng.randomize(reinterpret_cast<Botan::byte*>(buf.data()), buf.size());
+-#endif
+ 	return buf;
+     }
+ };
+@@ -70,7 +69,11 @@ class BotanHashContext : public QCA::HashContext
+ public:
+     BotanHashContext( const QString &hashName, QCA::Provider *p, const QString &type) : QCA::HashContext(p, type)
+     {
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
+ 	m_hashObj = Botan::get_hash(hashName.toStdString());
++#else
++	m_hashObj = Botan::HashFunction::create(hashName.toStdString()).release();
++#endif
+     }
+ 
+     ~BotanHashContext()
+@@ -95,11 +98,7 @@ public:
+ 
+     QCA::MemoryRegion final()
+     {
+-#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,0)
+-        QCA::SecureArray a( m_hashObj->OUTPUT_LENGTH );
+-#else
+ 	QCA::SecureArray a( m_hashObj->output_length() );
+-#endif
+ 	m_hashObj->final( (Botan::byte *)a.data() );
+ 	return a;
+     }
+@@ -115,10 +114,10 @@ class BotanHMACContext : public QCA::MACContext
+ public:
+     BotanHMACContext( const QString &hashName, QCA::Provider *p, const QString &type) : QCA::MACContext(p, type)
+     {
+-#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,8,0)
+-	m_hashObj = new Botan::HMAC(hashName.toStdString());
+-#else
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
+ 	m_hashObj = new Botan::HMAC(Botan::global_state().algorithm_factory().make_hash_function(hashName.toStdString()));
++#else
++	m_hashObj = new Botan::HMAC(Botan::HashFunction::create_or_throw(hashName.toStdString()).release());
+ #endif
+ 	if (0 == m_hashObj) {
+ 	    std::cout << "null context object" << std::endl;
+@@ -161,11 +160,7 @@ public:
+ 
+     void final( QCA::MemoryRegion *out)
+     {
+-#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,0)
+-	QCA::SecureArray sa( m_hashObj->OUTPUT_LENGTH, 0 );
+-#else
+ 	QCA::SecureArray sa( m_hashObj->output_length(), 0 );
+-#endif
+ 	m_hashObj->final( (Botan::byte *)sa.data() );
+ 	*out = sa;
+     }
+@@ -197,15 +192,8 @@ public:
+     QCA::SymmetricKey makeKey(const QCA::SecureArray &secret, const QCA::InitializationVector &salt,
+ 			      unsigned int keyLength, unsigned int iterationCount)
+     {
+-#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,0)
+-	m_s2k->set_iterations(iterationCount);
+-	m_s2k->change_salt((const Botan::byte*)salt.data(), salt.size());
+-	std::string secretString(secret.data(), secret.size() );
+-	Botan::OctetString key = m_s2k->derive_key(keyLength, secretString);
+-#else
+ 	std::string secretString(secret.data(), secret.size() );
+ 	Botan::OctetString key = m_s2k->derive_key(keyLength, secretString, (const Botan::byte*)salt.data(), salt.size(), iterationCount);
+-#endif
+         QCA::SecureArray retval(QByteArray((const char*)key.begin(), key.length()));
+ 	return QCA::SymmetricKey(retval);
+     }
+@@ -222,15 +210,6 @@ public:
+ 		std::string secretString(secret.data(), secret.size() );
+ 
+ 		*iterationCount = 0;
+-#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,0)
+-		m_s2k->set_iterations(1);
+-		m_s2k->change_salt((const Botan::byte*)salt.data(), salt.size());
+-		timer.start();
+-		while (timer.elapsed() < msecInterval) {
+-			key = m_s2k->derive_key(keyLength, secretString);
+-			++(*iterationCount);
+-		}
+-#else
+ 		timer.start();
+ 		while (timer.elapsed() < msecInterval) {
+ 			key = m_s2k->derive_key(keyLength,
+@@ -240,7 +219,6 @@ public:
+ 									1);
+ 			++(*iterationCount);
+ 		}
+-#endif
+ 		return makeKey(secret, salt, keyLength, *iterationCount);
+ 	}
+ 
+@@ -304,7 +282,12 @@ public:
+ 
+     int blockSize() const
+     {
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
+ 	return Botan::block_size_of(m_algoName);
++#else
++	if(const Botan::BlockCipher *bc = Botan::BlockCipher::create(m_algoName).release())
++	    return bc->block_size();
++#endif
+     }
+ 
+     QCA::AuthTag tag() const
+@@ -337,23 +320,31 @@ public:
+ 
+     QCA::KeyLength keyLength() const
+     {
+-#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,0)
+-	return QCA::KeyLength( Botan::min_keylength_of(m_algoName),
+-			       Botan::max_keylength_of(m_algoName),
+-			       Botan::keylength_multiple_of(m_algoName) );
+-#else
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
+         Botan::Algorithm_Factory &af = Botan::global_state().algorithm_factory();
++#endif
+         Botan::Key_Length_Specification kls(0);
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
+         if(const Botan::BlockCipher *bc = af.prototype_block_cipher(m_algoName))
++#else
++        if(const Botan::BlockCipher *bc = Botan::BlockCipher::create(m_algoName).release())
++#endif
+             kls = bc->key_spec();
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
+         else if(const Botan::StreamCipher *sc = af.prototype_stream_cipher(m_algoName))
++#else
++        else if(const Botan::StreamCipher *sc = Botan::StreamCipher::create(m_algoName).release())
++#endif
+             kls = sc->key_spec();
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
+         else if(const Botan::MessageAuthenticationCode *mac = af.prototype_mac(m_algoName))
++#else
++        else if(const Botan::MessageAuthenticationCode *mac = Botan::MessageAuthenticationCode::create(m_algoName).release())
++#endif
+             kls = mac->key_spec();
+         return QCA::KeyLength( kls.minimum_keylength(),
+                                kls.maximum_keylength(),
+                                kls.keylength_multiple() );
+-#endif
+     }
+ 
+ 
+@@ -379,7 +370,9 @@ class botanProvider : public QCA::Provider
+ public:
+     void init()
+     {
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
+ 	m_init = new Botan::LibraryInitializer;
++#endif
+     }
+ 
+     ~botanProvider()
+@@ -538,7 +531,9 @@ public:
+ 	    return 0;
+     }
+ private:
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0)
+     Botan::LibraryInitializer *m_init;
++#endif
+ 
+ };
+ 



More information about the arch-commits mailing list