Commit ef761bfe authored by Volker Krause's avatar Volker Krause
Browse files

Depend unconditionally on OpenSSL

The reasons this was optional were the early Android build and the static
extractor build for Nextcloud, both of which long since have OpenSSL as
well.
parent 242d17c7
......@@ -57,8 +57,7 @@ find_package(LibXml2 MODULE)
set_package_properties("LibXml2" PROPERTIES PURPOSE "Support for extraction from HTML booking confirmations." URL "http://libxml.org")
find_package(PhoneNumber OPTIONAL_COMPONENTS PhoneNumber QUIET)
set_package_properties("PhoneNumber" PROPERTIES PURPOSE "Parsing and geo-coding of phone numbers.")
find_package(OpenSSL 1.1)
set_package_properties("OpenSSL" PROPERTIES TYPE OPTIONAL PURPOSE "VDV ticket decoding." URL "https://openssl.org")
find_package(OpenSSL 1.1 REQUIRED)
find_package(OsmTools)
set_package_properties(OsmTools PROPERTIES TYPE OPTIONAL PURPOSE "Needed only for regenereating the airport database (ie. you most likely don't need this)")
......@@ -101,9 +100,6 @@ endif()
if (TARGET PhoneNumber::PhoneNumber)
set(HAVE_PHONENUMBER ON)
endif()
if (TARGET OpenSSL::Crypto)
set(HAVE_OPENSSL_RSA ON)
endif()
add_definitions(-DTRANSLATION_DOMAIN=\"kitinerary\")
......
......@@ -174,6 +174,7 @@ target_link_libraries(KPimItinerary
KF5::I18n
KF5::Contacts
KPim::PkPass
OpenSSL::Crypto
ZLIB::ZLIB
)
if (HAVE_POPPLER)
......@@ -197,9 +198,6 @@ endif()
if (HAVE_PHONENUMBER)
target_link_libraries(KPimItinerary PRIVATE PhoneNumber::PhoneNumber)
endif()
if (HAVE_OPENSSL_RSA)
target_link_libraries(KPimItinerary PRIVATE OpenSSL::Crypto)
endif()
ecm_generate_headers(KItinerary_FORWARDING_HEADERS
HEADER_NAMES
......
......@@ -35,7 +35,6 @@
#cmakedefine HAVE_KCAL
#cmakedefine HAVE_LIBXML2
#cmakedefine HAVE_PHONENUMBER
#cmakedefine HAVE_OPENSSL_RSA
#define CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "${CMAKE_INSTALL_FULL_LIBEXECDIR_KF5}"
......
......@@ -61,14 +61,6 @@ QString ExtractorCapabilities::capabilitiesString()
#endif
"\n"
"RSA support : "
#ifdef HAVE_OPENSSL_RSA
"openssl"
#else
"not available"
#endif
"\n"
"Extractors : ";
auto caps = QString::fromLatin1(s);
......
# SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
# SPDX-License-Identifier: BSD-3-Clause
if (NOT HAVE_OPENSSL_RSA)
return()
endif()
add_executable(vdv-cert-downloader
cert-downloader.cpp
../vdvcertificate.cpp
......
......@@ -8,17 +8,13 @@
#include <QDebug>
#ifdef HAVE_OPENSSL_RSA
#include <openssl/bn.h>
#include <openssl/err.h>
#endif
using namespace KItinerary;
Iso9796_2Decoder::Iso9796_2Decoder()
#ifdef HAVE_OPENSSL_RSA
: m_rsa(RSA_new(), RSA_free)
#endif
{
}
......@@ -26,21 +22,13 @@ Iso9796_2Decoder::~Iso9796_2Decoder() = default;
void Iso9796_2Decoder::setRsaParameters(const uint8_t *modulus, uint16_t modulusSize, const uint8_t *exponent, uint16_t exponentSize)
{
#ifdef HAVE_OPENSSL_RSA
const auto n = BN_bin2bn(modulus, modulusSize, nullptr);
const auto e = BN_bin2bn(exponent, exponentSize, nullptr);
RSA_set0_key(m_rsa.get(), n, e, nullptr); // takes ownership of n and e
#else
Q_UNUSED(modulus)
Q_UNUSED(modulusSize)
Q_UNUSED(exponent)
Q_UNUSED(exponentSize)
#endif
}
void Iso9796_2Decoder::addWithRecoveredMessage(const uint8_t *data, int size)
{
#ifdef HAVE_OPENSSL_RSA
QByteArray out;
out.resize(RSA_size(m_rsa.get()));
const auto outSize = RSA_public_decrypt(size, data, (uint8_t*)out.data(), m_rsa.get(), RSA_NO_PADDING);
......@@ -56,10 +44,6 @@ void Iso9796_2Decoder::addWithRecoveredMessage(const uint8_t *data, int size)
}
m_recoveredMsg.append(out.constData() + 1, out.size() - 22);
#else
Q_UNUSED(data)
Q_UNUSED(size)
#endif
}
void Iso9796_2Decoder::add(const uint8_t *data, int size)
......
......@@ -6,13 +6,9 @@
#pragma once
#include "config-kitinerary.h"
#include <QByteArray>
#ifdef HAVE_OPENSSL_RSA
#include <openssl/rsa.h>
#endif
#include <cstdint>
#include <memory>
......@@ -44,9 +40,7 @@ public:
QByteArray recoveredMessage() const;
private:
#ifdef HAVE_OPENSSL_RSA
std::unique_ptr<RSA, void(*)(RSA*)> m_rsa;
#endif
QByteArray m_recoveredMsg;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment