diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ef32eec..28b01690 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,486 +1,486 @@ # Checking for user explicity defined CMAKE_INSTALL_PREFIX # It must be done before project(...) if(NOT CMAKE_INSTALL_PREFIX) set(QCA_INSTALL_IN_QT_PREFIX ON) # If CMAKE_INSTALL_PREFIX is set in cmake arguments unset(CMAKE_INSTALL_PREFIX CACHE) endif(NOT CMAKE_INSTALL_PREFIX) project(qca) if(NOT APPLE) cmake_minimum_required(VERSION 2.8.12) else() cmake_minimum_required(VERSION 3.0) endif() set(QCA_LIB_MAJOR_VERSION "2") set(QCA_LIB_MINOR_VERSION "2") set(QCA_LIB_PATCH_VERSION "0") if(POLICY CMP0042) cmake_policy(SET CMP0042 OLD) endif() option(BUILD_TESTS "Create test" ON) option(BUILD_TOOLS "Compile mozcerts and qcatool" ON) set(BUILD_PLUGINS "auto" CACHE STRING "Plugins for building (also possible values: none, all and auto)") # BUILD_SHARED_LIBS is cmake variable. Need to change default value. option(BUILD_SHARED_LIBS "Build shared library" ON) option(DEVELOPER_MODE "Special developer mode" OFF) if(APPLE) option(OSX_FRAMEWORK "Build a Mac OS X Framework" ON) else() set(OSX_FRAMEWORK OFF) endif() find_package(Doxygen) string(TOLOWER "${BUILD_PLUGINS}" BUILD_PLUGINS) if(NOT BUILD_PLUGINS) set(BUILD_PLUGINS "none") endif(NOT BUILD_PLUGINS) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) option(QT4_BUILD "Force building with Qt4 even if Qt5 is found") if (NOT QT4_BUILD) # Do not automatically link Qt executables to qtmain target on Windows. # QCA exucatables use console mode only. Not need to link against qtmain.lib. set(Qt5_NO_LINK_QTMAIN ON) find_package(Qt5Core QUIET) mark_as_advanced(Qt5Core_DIR) endif() include(QcaMacro) if (Qt5Core_FOUND) message(STATUS "Building with Qt5 support") # Got from ECM # Distros have no ECM. So I just copied required cmake modules. find_package(Qt5Transitional REQUIRED Core Network) include(ECMQt4To5Porting) include(GNUInstallDirs) setup_qt5_dirs() set(QCA_QT_PC_VERSION "Qt5Core") set(QCA_SUFFIX "qt5") else() set(QT_MIN_VERSION "4.7.0") set(QT_USE_IMPORTED_TARGETS ON) # Do not automatically link Qt executables to qtmain target on Windows. # QCA exucatables use console mode only. Not need to link against qtmain.lib. set(QT4_NO_LINK_QTMAIN ON) if(BUILD_TESTS) find_package(Qt4 REQUIRED QtCore QtNetwork QtTest) else(BUILD_TESTS) find_package(Qt4 REQUIRED QtCore) endif(BUILD_TESTS) # WORKAROUND: Seems it must be done in Qt4 find module but didn't mark_as_advanced(QT_QMAKE_EXECUTABLE) # properly set up compile flags (QT_DEBUG/QT_NO_DEBUG, ...) include(${QT_USE_FILE}) setup_qt4_dirs() set(QCA_QT_PC_VERSION "QtCore") endif() # QCA can be shared but plugins will be static # if Qt is static. if(NOT BUILD_SHARED_LIBS OR QT_IS_STATIC) set(STATIC_PLUGINS ON) add_definitions(-DQT_STATICPLUGIN) set(PLUGIN_TYPE "STATIC") else(NOT BUILD_SHARED_LIBS OR QT_IS_STATIC) set(PLUGIN_TYPE "MODULE") endif(NOT BUILD_SHARED_LIBS OR QT_IS_STATIC) set(QCA_SUFFIX "${QCA_SUFFIX}" CACHE STRING "QCA common suffix") if(QCA_SUFFIX) set(QCA_LIB_NAME qca-${QCA_SUFFIX}) set(QCA_TOOL_NAME qcatool-${QCA_SUFFIX}) set(MOZCERTS_NAME mozcerts-${QCA_SUFFIX}) set(QCA_PC_NAME qca2-${QCA_SUFFIX}.pc) set(QCA_CONFIG_NAME_BASE "Qca-${QCA_SUFFIX}") else(QCA_SUFFIX) set(QCA_LIB_NAME qca) set(QCA_TOOL_NAME qcatool) set(MOZCERTS_NAME mozcerts) set(QCA_PC_NAME qca2.pc) set(QCA_CONFIG_NAME_BASE "Qca") endif(QCA_SUFFIX) set(QCA_LIB_VERSION_STRING "${QCA_LIB_MAJOR_VERSION}.${QCA_LIB_MINOR_VERSION}.${QCA_LIB_PATCH_VERSION}") configure_file("include/QtCrypto/qca_version.h.in" "${CMAKE_BINARY_DIR}/qca_version.h") if (WIN32) set(CMAKE_DEBUG_POSTFIX "d") add_definitions(-DWIN32_LEAN_AND_MEAN) elseif (APPLE) set(CMAKE_DEBUG_POSTFIX "_debug") endif (WIN32) if (CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_SYSTEM_NAME MATCHES Linux) add_definitions (-D_DEFAULT_SOURCE) # on arm -Wcast-align throws many internal qt warning if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-align") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align") endif() - set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") - set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-check-new -fno-common") + set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -Wundef -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") + set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-check-new -fno-common") endif (CMAKE_SYSTEM_NAME MATCHES Linux) endif (CMAKE_COMPILER_IS_GNUCXX) add_definitions (${QT_DEFINITIONS}) include_directories("include/QtCrypto/") # for generated files include_directories(${CMAKE_BINARY_DIR}) if(NOT DEVELOPER_MODE) # uninstall target configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) endif() # Always include srcdir and builddir in include path # This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in about every subdir set(CMAKE_INCLUDE_CURRENT_DIR ON) # put the include dirs which are in the source or build tree # before all other include dirs, so the headers in the sources # are prefered over the already installed ones set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) set(qca_INCLUDEDIR "${CMAKE_CURRENT_SOURCE_DIR}/include" ) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" ) # Use the same path for shared and static library set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) if( QCA_INSTALL_IN_QT_PREFIX ) set(QCA_PREFIX_INSTALL_DIR "${QT_PREFIX_DIR}" CACHE PATH "Directory where qca will install") set(QCA_PLUGINS_INSTALL_DIR "${QT_PLUGINS_DIR}" CACHE PATH "Directory where qca plugins will install") set(QCA_BINARY_INSTALL_DIR "${QT_BINARY_DIR}" CACHE PATH "Directory where qca plugins will install") set(QCA_LIBRARY_INSTALL_DIR "${QT_LIBRARY_DIR}" CACHE PATH "Directory where qca library will install") set(QCA_FEATURE_INSTALL_DIR "${QT_MKSPECS_DIR}/features" CACHE PATH "Directory where qca feature file will install") if(NOT QCA_SUFFIX) set(QCA_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}" CACHE PATH "Directory where qca public headers will install") set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}" CACHE PATH "Directory where qca headers will install") else() set(QCA_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca public headers will install") set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca headers will install") endif() set(QCA_DOC_INSTALL_DIR "${QT_DOC_DIR}/html/qca/" CACHE PATH "Directory where qca documentation will install") set(QCA_MAN_INSTALL_DIR "${QT_DATA_DIR}/man" CACHE PATH "Directory where qca man pages will install") else( QCA_INSTALL_IN_QT_PREFIX ) # Cmake says nothing about LIB_SUFFIX # de facto it is a standard way to specify lib suffix on many distros set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "Directory where lib will install") set(QCA_PREFIX_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Directory where qca will install") set(QCA_PLUGINS_INSTALL_DIR "${LIB_INSTALL_DIR}/${QCA_LIB_NAME}" CACHE PATH "Directory where qca plugins will install") set(QCA_BINARY_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Directory where qca plugins will install") set(QCA_LIBRARY_INSTALL_DIR "${LIB_INSTALL_DIR}" CACHE PATH "Directory where qca library will install") set(QCA_FEATURE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/mkspecs/features" CACHE PATH "Directory where qca feature file will install") if(NOT QCA_SUFFIX) set(QCA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Directory where qca public headers will install") set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Directory where qca headers will install") else() set(QCA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca public headers will install") set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca headers will install") endif() set(QCA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${QCA_LIB_NAME}/html" CACHE PATH "Directory where qca documentation will install") set(QCA_MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Directory where qca man pages will install") endif( QCA_INSTALL_IN_QT_PREFIX ) set(PKGCONFIG_INSTALL_PREFIX "${QCA_LIBRARY_INSTALL_DIR}/pkgconfig" CACHE PATH "Base directory for pkgconfig files") normalize_path(QCA_PREFIX_INSTALL_DIR) if(OSX_FRAMEWORK) set(QCA_FULL_INCLUDE_INSTALL_DIR "${QCA_LIBRARY_INSTALL_DIR}/${QCA_LIB_NAME}.framework/Headers") else() set(QCA_FULL_INCLUDE_INSTALL_DIR "${QCA_INCLUDE_INSTALL_DIR}/QtCrypto") endif() # check for oportunity to use relative paths option(USE_RELATIVE_PATHS "Try to make relocatable package") foreach(PATH QCA_PLUGINS_INSTALL_DIR QCA_BINARY_INSTALL_DIR QCA_LIBRARY_INSTALL_DIR QCA_FEATURE_INSTALL_DIR QCA_INCLUDE_INSTALL_DIR QCA_PRIVATE_INCLUDE_INSTALL_DIR QCA_DOC_INSTALL_DIR QCA_MAN_INSTALL_DIR PKGCONFIG_INSTALL_PREFIX) # Normalize path before comparsion normalize_path(${PATH}) # if all paths are subdirs of CMAKE_INSTALL_PREFIX it is possible to use relative paths string(FIND "${${PATH}}" "${QCA_PREFIX_INSTALL_DIR}/" POS) if(NOT "${POS}" STREQUAL "0") set(USE_RELATIVE_PATHS OFF) endif() endforeach() if(NOT WIN32) if(OSX_FRAMEWORK) set(PKGCONFIG_CFLAGS "-F\${libdir} -I\${includedir}") set(PKGCONFIG_LIBS "-F\${libdir} -framework ${QCA_LIB_NAME}") else() set(PKGCONFIG_CFLAGS "-I\${includedir}") set(PKGCONFIG_LIBS "-L\${libdir} -l${QCA_LIB_NAME}") endif() # qca2.pc uses absolute paths. So it must be there. Don't rellocate this. configure_file("qca2.pc.cmake" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pkgconfig/${QCA_PC_NAME}" @ONLY) if(NOT DEVELOPER_MODE) install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pkgconfig/${QCA_PC_NAME}" DESTINATION ${PKGCONFIG_INSTALL_PREFIX}) endif() endif(NOT WIN32) # strip CMAKE_INSTALL_PREFIX in all paths if(USE_RELATIVE_PATHS) message(STATUS "Installed package is relocatable") file(RELATIVE_PATH CRYPTO_PRF_RELATIVE_PATH "${QCA_FEATURE_INSTALL_DIR}" ${CMAKE_INSTALL_PREFIX}) set(CRYPTO_PRF_RELATIVE_PATH "$$PWD/${CRYPTO_PRF_RELATIVE_PATH}") foreach(PATH QCA_PLUGINS_INSTALL_DIR QCA_BINARY_INSTALL_DIR QCA_LIBRARY_INSTALL_DIR QCA_FEATURE_INSTALL_DIR QCA_INCLUDE_INSTALL_DIR QCA_PRIVATE_INCLUDE_INSTALL_DIR QCA_DOC_INSTALL_DIR QCA_MAN_INSTALL_DIR PKGCONFIG_INSTALL_PREFIX) file(RELATIVE_PATH ${PATH} ${CMAKE_INSTALL_PREFIX} "${${PATH}}") endforeach() else() message(STATUS "Installed package is NOT relocatable") set(CRYPTO_PRF_RELATIVE_PATH "") endif() if(DEVELOPER_MODE) add_definitions(-DDEVELOPER_MODE) # To prefer plugins from build tree when run qca from build tree file(WRITE ${CMAKE_BINARY_DIR}/bin/qt.conf "[Paths] Plugins=${CMAKE_BINARY_DIR}/lib/${QCA_LIB_NAME} ") endif() if (APPLE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) endif (APPLE) message(STATUS "Checking for certstore..") # fixme add OR mac if( WIN32 ) # USE BUILTIN else ( WIN32 ) if ( DEFINED ENV{QC_CERTSTORE_PATH} ) if(EXISTS $ENV{QC_CERTSTORE_PATH}) set( qca_CERTSTORE $ENV{QC_CERTSTORE_PATH}) else(EXISTS $ENV{QC_CERTSTORE_PATH}) # path to try endif(EXISTS $ENV{QC_CERTSTORE_PATH}) else( DEFINED ENV{QC_CERTSTORE_PATH} ) set( toTry "/etc/ssl/certs/ca-certificates.crt" "/usr/share/ssl/cert.pem" "/usr/share/ssl/certs/ca-bundle.crt" "/etc/pki/tls/cert.pem" "/etc/ssl/ca-bundle.pem" "/usr/share/curl/curl-ca-bundle.crt" ) foreach (_current_try ${toTry}) if(EXISTS ${_current_try}) set( qca_CERTSTORE ${_current_try}) endif(EXISTS ${_current_try}) endforeach (_current_try) endif( DEFINED ENV{QC_CERTSTORE_PATH} ) endif(WIN32) if (qca_CERTSTORE) message(STATUS "Found system certstore") else (qca_CERTSTORE) message(STATUS "Using built in certstore.") set( qca_CERTSTORE "${CMAKE_CURRENT_SOURCE_DIR}/certs/rootcerts.pem") # note that INSTALL_FILES targets are relative to the current installation prefix... if(NOT DEVELOPER_MODE) install(FILES "${qca_CERTSTORE}" DESTINATION "${QCA_PREFIX_INSTALL_DIR}/certs") endif() endif (qca_CERTSTORE) message(STATUS "certstore path: " ${qca_CERTSTORE}) add_definitions( -DQCA_SYSTEMSTORE_PATH="${qca_CERTSTORE}" ) set( private_HEADERS ${qca_INCLUDEDIR}/QtCrypto/qca_plugin.h ${qca_INCLUDEDIR}/QtCrypto/qca_systemstore.h ) set( public_HEADERS ${qca_INCLUDEDIR}/QtCrypto/qca.h ${qca_INCLUDEDIR}/QtCrypto/qcaprovider.h ${qca_INCLUDEDIR}/QtCrypto/QtCrypto ${qca_INCLUDEDIR}/QtCrypto/qca_export.h ${qca_INCLUDEDIR}/QtCrypto/qca_support.h ${qca_INCLUDEDIR}/QtCrypto/qca_tools.h ${qca_INCLUDEDIR}/QtCrypto/qca_core.h ${qca_INCLUDEDIR}/QtCrypto/qca_textfilter.h ${qca_INCLUDEDIR}/QtCrypto/qca_basic.h ${qca_INCLUDEDIR}/QtCrypto/qca_publickey.h ${qca_INCLUDEDIR}/QtCrypto/qca_cert.h ${qca_INCLUDEDIR}/QtCrypto/qca_keystore.h ${qca_INCLUDEDIR}/QtCrypto/qca_securelayer.h ${qca_INCLUDEDIR}/QtCrypto/qca_securemessage.h ${CMAKE_BINARY_DIR}/qca_version.h ${qca_INCLUDEDIR}/QtCrypto/qpipe.h ${qca_INCLUDEDIR}/QtCrypto/qca_safetimer.h) set( qca_HEADERS ${private_HEADERS} ${public_HEADERS} ) include_directories(${QT_QTCORE_INCLUDE_DIR} "${qca_INCLUDEDIR}/QtCrypto") configure_file("crypto.prf.cmake" "${CMAKE_BINARY_DIR}/mkspecs/features/crypto.prf" @ONLY) if(NOT DEVELOPER_MODE) install(FILES "${CMAKE_BINARY_DIR}/mkspecs/features/crypto.prf" DESTINATION "${QCA_FEATURE_INSTALL_DIR}") endif() configure_file(man/qcatool.1 "${CMAKE_BINARY_DIR}/share/man/man1/${QCA_TOOL_NAME}.1" COPYONLY) if(NOT DEVELOPER_MODE) install(FILES "${CMAKE_BINARY_DIR}/share/man/man1/${QCA_TOOL_NAME}.1" DESTINATION "${QCA_MAN_INSTALL_DIR}/man1") endif() set(QCA_CRYPTO_INSTALL_DIR "${QCA_PLUGINS_INSTALL_DIR}/crypto") add_subdirectory(src) add_subdirectory(plugins) if(STATIC_PLUGINS) # Generate header with static plugins list file(WRITE "${CMAKE_BINARY_DIR}/import_plugins.h" "#include \n") foreach(PLUGIN IN LISTS PLUGINS) if(WITH_${PLUGIN}_PLUGIN_INTERNAL) string(REPLACE "-" "_" IMPORT_NAME "qca-${PLUGIN}") file(APPEND "${CMAKE_BINARY_DIR}/import_plugins.h" "Q_IMPORT_PLUGIN(${IMPORT_NAME})\n") endif(WITH_${PLUGIN}_PLUGIN_INTERNAL) endforeach(PLUGIN IN LISTS PLUGINS) endif(STATIC_PLUGINS) if(BUILD_TESTS) enable_testing() add_subdirectory(unittest) add_subdirectory(examples) endif(BUILD_TESTS) if(BUILD_TOOLS) add_subdirectory(tools) endif(BUILD_TOOLS) if(DOXYGEN_FOUND) configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY) add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/images COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/images/qca-arch.eps ${CMAKE_BINARY_DIR}/images/qca-arch.eps COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/images/qca-arch.png ${CMAKE_BINARY_DIR}/images/qca-arch.png WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Generating API documentation with Doxygen" VERBATIM) endif(DOXYGEN_FOUND) include(CMakePackageConfigHelpers) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/QcaConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}Config.cmake" INSTALL_DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE} ) write_basic_config_version_file("${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}ConfigVersion.cmake" VERSION ${QCA_LIB_VERSION_STRING} COMPATIBILITY AnyNewerVersion) if(NOT DEVELOPER_MODE) # /usr/local is traditional path for installing apps on POSIX-systems. # I consciously break this. Qt by default looks plugins and features only in # own directory. So by default install libs in Qt prefix it is a best choice. # This can be unwanted behaviour for users who don't read INSTALL file or/and # not read cmake reports. I just try to warn their. # In really anybody who do cmake . && make && sudo make install do it for own risk. if(QCA_INSTALL_IN_QT_PREFIX) string(ASCII 27 ESCAPE) message("") message("${ESCAPE}[31m") message("!!!!!!!!!!!!!!!!!!!!!ATTENTION!!!!!!!!!!!!!!!!!!!!!!") message("!! QCA will be installed in Qt prefix !!") message("!! If you want to install in /usr/local !!") message("!! you MUST explicity define CMAKE_INSTALL_PREFIX !!") message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") message("${ESCAPE}[0m") endif(QCA_INSTALL_IN_QT_PREFIX) message("") if(USE_RELATIVE_PATHS) message("QCA prefix is " "${QCA_PREFIX_INSTALL_DIR}") message("Plugins will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_PLUGINS_INSTALL_DIR}") message("Binary will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_BINARY_INSTALL_DIR}") if(OSX_FRAMEWORK) message("Framework will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_LIBRARY_INSTALL_DIR}") else() message("Library will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_LIBRARY_INSTALL_DIR}") message("Public headers will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_INCLUDE_INSTALL_DIR}") message("Private headers will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_PRIVATE_INCLUDE_INSTALL_DIR}") endif() message("Feature file will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_FEATURE_INSTALL_DIR}") message("Documentation will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_DOC_INSTALL_DIR}") message("Man page will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_MAN_INSTALL_DIR}") message("Pkg-config file will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${PKGCONFIG_INSTALL_PREFIX}") else() message("QCA prefix is " "${QCA_PREFIX_INSTALL_DIR}") message("Plugins will be installed to " "${QCA_PLUGINS_INSTALL_DIR}") message("Binary will be installed to " "${QCA_BINARY_INSTALL_DIR}") if(OSX_FRAMEWORK) message("Framework will be installed to " "${QCA_LIBRARY_INSTALL_DIR}") else() message("Library will be installed to " "${QCA_LIBRARY_INSTALL_DIR}") message("Public headers will be installed to " "${QCA_INCLUDE_INSTALL_DIR}") message("Private headers will be installed to " "${QCA_PRIVATE_INCLUDE_INSTALL_DIR}") endif() message("Feature file will be installed to " "${QCA_FEATURE_INSTALL_DIR}") message("Documentation will be installed to " "${QCA_DOC_INSTALL_DIR}") message("Man page will be installed to " "${QCA_MAN_INSTALL_DIR}") message("Pkg-config file will be installed to " "${PKGCONFIG_INSTALL_PREFIX}") endif() message("") if(UNIX AND NOT APPLE) if(NOT QCA_SUFFIX AND NOT QT4_BUILD) message("${ESCAPE}[31mYou don't have QCA_SUFFIX set. Please note that the recommended way of") message("building Qt5 version of qca for Linux distributions is to set") message("QCA_SUFFIX to qt5 (-DQCA_SUFFIX=qt5).") message("${ESCAPE}[0m") endif() endif() install(EXPORT ${QCA_CONFIG_NAME_BASE}Targets DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE} FILE ${QCA_CONFIG_NAME_BASE}Targets.cmake) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}ConfigVersion.cmake" DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE} ) endif() diff --git a/cmake/modules/FindBotan.cmake b/cmake/modules/FindBotan.cmake index 0c4e24bb..ce92df52 100644 --- a/cmake/modules/FindBotan.cmake +++ b/cmake/modules/FindBotan.cmake @@ -1,49 +1,31 @@ # - Try to find the Gcrypt library # Once run this will define # # BOTAN_FOUND - set if the system has the gcrypt library # BOTAN_CFLAGS - the required gcrypt compilation flags # BOTAN_LIBRARIES - the linker libraries needed to use the gcrypt library # # Copyright (c) 2006 Brad Hards # # 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) message(STATUS "Found Botan: ${BOTAN_LIBRARIES}") endif (NOT Botan_FIND_QUIETLY) else (BOTAN_FOUND) if (Botan_FIND_REQUIRED) message(FATAL_ERROR "Could not find Botan libraries") endif (Botan_FIND_REQUIRED) endif (BOTAN_FOUND) diff --git a/plugins/qca-botan/qca-botan.cpp b/plugins/qca-botan/qca-botan.cpp index f3875758..8822ab54 100644 --- a/plugins/qca-botan/qca-botan.cpp +++ b/plugins/qca-botan/qca-botan.cpp @@ -1,560 +1,557 @@ /* * Copyright (C) 2004 Justin Karneges * Copyright (C) 2004-2006 Brad Hards * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * */ #include #include #include #include -#include #include -#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,0) -#include -#endif -#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,8,0) +#include +#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0) +#include #include +#else +#include +#include +#include +#include +#include +#include #endif #include #include //----------------------------------------------------------- class botanRandomContext : public QCA::RandomContext { public: botanRandomContext(QCA::Provider *p) : RandomContext(p) { } Context *clone() const { return new botanRandomContext( *this ); } 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(buf.data()), buf.size()); -#endif return buf; } }; //----------------------------------------------------------- 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() { delete m_hashObj; } Context *clone() const { return new BotanHashContext(*this); } void clear() { m_hashObj->clear(); } void update(const QCA::MemoryRegion &a) { m_hashObj->update( (const Botan::byte*)a.data(), a.size() ); } 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; } private: Botan::HashFunction *m_hashObj; }; //----------------------------------------------------------- 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; } } ~BotanHMACContext() { } void setup(const QCA::SymmetricKey &key) { // this often gets called with an empty key, because that is the default // in the QCA MessageAuthenticationCode constructor. Botan doesn't like // that happening. if (key.size() > 0) { m_hashObj->set_key( (const Botan::byte *)key.data(), key.size() ); } } Context *clone() const { return new BotanHMACContext(*this); } void clear() { m_hashObj->clear(); } QCA::KeyLength keyLength() const { return anyKeyLength(); } void update(const QCA::MemoryRegion &a) { m_hashObj->update( (const Botan::byte*)a.data(), a.size() ); } 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; } protected: Botan::HMAC *m_hashObj; }; //----------------------------------------------------------- class BotanPBKDFContext: public QCA::KDFContext { public: BotanPBKDFContext( const QString &kdfName, QCA::Provider *p, const QString &type) : QCA::KDFContext(p, type) { m_s2k = Botan::get_s2k(kdfName.toStdString()); } ~BotanPBKDFContext() { delete m_s2k; } Context *clone() const { return new BotanPBKDFContext( *this ); } 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); } QCA::SymmetricKey makeKey(const QCA::SecureArray &secret, const QCA::InitializationVector &salt, unsigned int keyLength, int msecInterval, unsigned int *iterationCount) { Q_ASSERT(iterationCount != NULL); Botan::OctetString key; QTime timer; 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, secretString, (const Botan::byte*)salt.data(), salt.size(), 1); ++(*iterationCount); } -#endif return makeKey(secret, salt, keyLength, *iterationCount); } protected: Botan::S2K* m_s2k; }; //----------------------------------------------------------- class BotanCipherContext : public QCA::CipherContext { public: BotanCipherContext( const QString &algo, const QString &mode, const QString &padding, QCA::Provider *p, const QString &type) : QCA::CipherContext(p, type) { m_algoName = algo.toStdString(); m_algoMode = mode.toStdString(); m_algoPadding = padding.toStdString(); } void setup(QCA::Direction dir, const QCA::SymmetricKey &key, const QCA::InitializationVector &iv, const QCA::AuthTag &tag) { Q_UNUSED(tag); try { m_dir = dir; Botan::SymmetricKey keyCopy((Botan::byte*)key.data(), key.size()); if (iv.size() == 0) { if (QCA::Encode == dir) { m_crypter = new Botan::Pipe(Botan::get_cipher(m_algoName+'/'+m_algoMode+'/'+m_algoPadding, keyCopy, Botan::ENCRYPTION)); } else { m_crypter = new Botan::Pipe(Botan::get_cipher(m_algoName+'/'+m_algoMode+'/'+m_algoPadding, keyCopy, Botan::DECRYPTION)); } } else { Botan::InitializationVector ivCopy((Botan::byte*)iv.data(), iv.size()); if (QCA::Encode == dir) { m_crypter = new Botan::Pipe(Botan::get_cipher(m_algoName+'/'+m_algoMode+'/'+m_algoPadding, keyCopy, ivCopy, Botan::ENCRYPTION)); } else { m_crypter = new Botan::Pipe(Botan::get_cipher(m_algoName+'/'+m_algoMode+'/'+m_algoPadding, keyCopy, ivCopy, Botan::DECRYPTION)); } } m_crypter->start_msg(); } catch (Botan::Exception& e) { std::cout << "caught: " << e.what() << std::endl; } } Context *clone() const { return new BotanCipherContext( *this ); } int blockSize() const { +#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0) return Botan::block_size_of(m_algoName); +#else + if(const std::unique_ptr bc = Botan::BlockCipher::create(m_algoName)) + return bc->block_size(); + + throw Botan::Algorithm_Not_Found(m_algoName); +#endif } QCA::AuthTag tag() const { // For future implementation return QCA::AuthTag(); } bool update(const QCA::SecureArray &in, QCA::SecureArray *out) { m_crypter->write((Botan::byte*)in.data(), in.size()); QCA::SecureArray result( m_crypter->remaining() ); // Perhaps bytes_read is redundant and can be dropped size_t bytes_read = m_crypter->read((Botan::byte*)result.data(), result.size()); result.resize(bytes_read); *out = result; return true; } bool final(QCA::SecureArray *out) { m_crypter->end_msg(); QCA::SecureArray result( m_crypter->remaining() ); // Perhaps bytes_read is redundant and can be dropped size_t bytes_read = m_crypter->read((Botan::byte*)result.data(), result.size()); result.resize(bytes_read); *out = result; return true; } 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 std::unique_ptr bc = Botan::BlockCipher::create(m_algoName)) +#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 std::unique_ptr sc = Botan::StreamCipher::create(m_algoName)) +#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 std::unique_ptr mac = Botan::MessageAuthenticationCode::create(m_algoName)) +#endif kls = mac->key_spec(); return QCA::KeyLength( kls.minimum_keylength(), kls.maximum_keylength(), kls.keylength_multiple() ); -#endif } ~BotanCipherContext() { delete m_crypter; } protected: QCA::Direction m_dir; std::string m_algoName; std::string m_algoMode; std::string m_algoPadding; Botan::Keyed_Filter *m_cipher; Botan::Pipe *m_crypter; }; //========================================================== 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() { // We should be cleaning up there, but // this causes the unit tests to segfault // delete m_init; } int qcaVersion() const { return QCA_VERSION; } QString name() const { return "qca-botan"; } QStringList features() const { QStringList list; list += "random"; list += "md2"; list += "md4"; list += "md5"; list += "sha1"; list += "sha256"; list += "sha384"; list += "sha512"; list += "ripemd160"; list += "hmac(md5)"; list += "hmac(sha1)"; // HMAC with SHA2 doesn't appear to work correctly in Botan. // list += "hmac(sha256)"; // list += "hmac(sha384)"; // list += "hmac(sha512)"; list += "hmac(ripemd160)"; list += "pbkdf1(sha1)"; list += "pbkdf1(md2)"; list += "pbkdf2(sha1)"; list += "aes128-ecb"; list += "aes128-cbc"; list += "aes128-cfb"; list += "aes128-ofb"; list += "aes192-ecb"; list += "aes192-cbc"; list += "aes192-cfb"; list += "aes192-ofb"; list += "aes256-ecb"; list += "aes256-cbc"; list += "aes256-cfb"; list += "aes256-ofb"; list += "des-ecb"; list += "des-ecb-pkcs7"; list += "des-cbc"; list += "des-cbc-pkcs7"; list += "des-cfb"; list += "des-ofb"; list += "tripledes-ecb"; list += "blowfish-ecb"; list += "blowfish-cbc"; list += "blowfish-cbc-pkcs7"; list += "blowfish-cfb"; list += "blowfish-ofb"; return list; } Context *createContext(const QString &type) { if ( type == "random" ) return new botanRandomContext( this ); else if ( type == "md2" ) return new BotanHashContext( QString("MD2"), this, type ); else if ( type == "md4" ) return new BotanHashContext( QString("MD4"), this, type ); else if ( type == "md5" ) return new BotanHashContext( QString("MD5"), this, type ); else if ( type == "sha1" ) return new BotanHashContext( QString("SHA-1"), this, type ); else if ( type == "sha256" ) return new BotanHashContext( QString("SHA-256"), this, type ); else if ( type == "sha384" ) return new BotanHashContext( QString("SHA-384"), this, type ); else if ( type == "sha512" ) return new BotanHashContext( QString("SHA-512"), this, type ); else if ( type == "ripemd160" ) return new BotanHashContext( QString("RIPEMD-160"), this, type ); else if ( type == "hmac(md5)" ) return new BotanHMACContext( QString("MD5"), this, type ); else if ( type == "hmac(sha1)" ) return new BotanHMACContext( QString("SHA-1"), this, type ); else if ( type == "hmac(sha256)" ) return new BotanHMACContext( QString("SHA-256"), this, type ); else if ( type == "hmac(sha384)" ) return new BotanHMACContext( QString("SHA-384"), this, type ); else if ( type == "hmac(sha512)" ) return new BotanHMACContext( QString("SHA-512"), this, type ); else if ( type == "hmac(ripemd160)" ) return new BotanHMACContext( QString("RIPEMD-160"), this, type ); else if ( type == "pbkdf1(sha1)" ) return new BotanPBKDFContext( QString("PBKDF1(SHA-1)"), this, type ); else if ( type == "pbkdf1(md2)" ) return new BotanPBKDFContext( QString("PBKDF1(MD2)"), this, type ); else if ( type == "pbkdf2(sha1)" ) return new BotanPBKDFContext( QString("PBKDF2(SHA-1)"), this, type ); else if ( type == "aes128-ecb" ) return new BotanCipherContext( QString("AES-128"), QString("ECB"), QString("NoPadding"), this, type ); else if ( type == "aes128-cbc" ) return new BotanCipherContext( QString("AES-128"), QString("CBC"), QString("NoPadding"), this, type ); else if ( type == "aes128-cfb" ) return new BotanCipherContext( QString("AES-128"), QString("CFB"), QString("NoPadding"), this, type ); else if ( type == "aes128-ofb" ) return new BotanCipherContext( QString("AES-128"), QString("OFB"), QString("NoPadding"), this, type ); else if ( type == "aes192-ecb" ) return new BotanCipherContext( QString("AES-192"), QString("ECB"), QString("NoPadding"), this, type ); else if ( type == "aes192-cbc" ) return new BotanCipherContext( QString("AES-192"), QString("CBC"), QString("NoPadding"), this, type ); else if ( type == "aes192-cfb" ) return new BotanCipherContext( QString("AES-192"), QString("CFB"), QString("NoPadding"), this, type ); else if ( type == "aes192-ofb" ) return new BotanCipherContext( QString("AES-192"), QString("OFB"), QString("NoPadding"), this, type ); else if ( type == "aes256-ecb" ) return new BotanCipherContext( QString("AES-256"), QString("ECB"), QString("NoPadding"), this, type ); else if ( type == "aes256-cbc" ) return new BotanCipherContext( QString("AES-256"), QString("CBC"), QString("NoPadding"), this, type ); else if ( type == "aes256-cfb" ) return new BotanCipherContext( QString("AES-256"), QString("CFB"), QString("NoPadding"), this, type ); else if ( type == "aes256-ofb" ) return new BotanCipherContext( QString("AES-256"), QString("OFB"), QString("NoPadding"), this, type ); else if ( type == "blowfish-ecb" ) return new BotanCipherContext( QString("Blowfish"), QString("ECB"), QString("NoPadding"), this, type ); else if ( type == "blowfish-cbc" ) return new BotanCipherContext( QString("Blowfish"), QString("CBC"), QString("NoPadding"), this, type ); else if ( type == "blowfish-cbc-pkcs7" ) return new BotanCipherContext( QString("Blowfish"), QString("CBC"), QString("PKCS7"), this, type ); else if ( type == "blowfish-cfb" ) return new BotanCipherContext( QString("Blowfish"), QString("CFB"), QString("NoPadding"), this, type ); else if ( type == "blowfish-ofb" ) return new BotanCipherContext( QString("Blowfish"), QString("OFB"), QString("NoPadding"), this, type ); else if ( type == "des-ecb" ) return new BotanCipherContext( QString("DES"), QString("ECB"), QString("NoPadding"), this, type ); else if ( type == "des-ecb-pkcs7" ) return new BotanCipherContext( QString("DES"), QString("ECB"), QString("PKCS7"), this, type ); else if ( type == "des-cbc" ) return new BotanCipherContext( QString("DES"), QString("CBC"), QString("NoPadding"), this, type ); else if ( type == "des-cbc-pkcs7" ) return new BotanCipherContext( QString("DES"), QString("CBC"), QString("PKCS7"), this, type ); else if ( type == "des-cfb" ) return new BotanCipherContext( QString("DES"), QString("CFB"), QString("NoPadding"), this, type ); else if ( type == "des-ofb" ) return new BotanCipherContext( QString("DES"), QString("OFB"), QString("NoPadding"), this, type ); else if ( type == "tripledes-ecb" ) return new BotanCipherContext( QString("TripleDES"), QString("ECB"), QString("NoPadding"), this, type ); else return 0; } private: +#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(2,0,0) Botan::LibraryInitializer *m_init; +#endif }; class botanPlugin : public QObject, public QCAPlugin { Q_OBJECT #if QT_VERSION >= 0x050000 Q_PLUGIN_METADATA(IID "com.affinix.qca.Plugin/1.0") #endif Q_INTERFACES(QCAPlugin) public: virtual QCA::Provider *createProvider() { return new botanProvider; } }; #include "qca-botan.moc" #if QT_VERSION < 0x050000 Q_EXPORT_PLUGIN2(qca_botan, botanPlugin); #endif