From b3b7b5a2614c9e6a314a10bae9bfd2aa8cc91eb7 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Tue, 30 Jul 2024 08:52:39 +0300 Subject: [PATCH] Use libxml2/xmsec1 for XAdES signature parsing and validation IB-7948 Signed-off-by: Raul Metsma --- client/CMakeLists.txt | 8 ++------ client/Diagnostics_unix.cpp | 14 +++++++------- client/Diagnostics_win.cpp | 36 ++++++++++++++++++------------------ qdigidoc4.wxs | 4 ---- 4 files changed, 27 insertions(+), 35 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index eb86c86c3..62bd19eca 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -168,9 +168,9 @@ if( APPLE ) COMMAND rm $/Frameworks/digidocpp.framework/Resources/digidoc-tool COMMAND find $/Frameworks -name Headers | xargs rm -rf COMMAND install_name_tool -delete_rpath /Library/Frameworks $ - COMMAND ln -sf digidocpp.framework/Libraries/libcrypto.dylib + COMMAND ln -sf digidocpp.framework/Libraries/libcrypto.3.dylib $/Frameworks/libcrypto.3.dylib - COMMAND ln -sf digidocpp.framework/Libraries/libssl.dylib + COMMAND ln -sf digidocpp.framework/Libraries/libssl.3.dylib $/Frameworks/libssl.3.dylib ) @@ -262,10 +262,6 @@ elseif(WIN32) COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/libcrypto-3${OPENSSL_SUFFIX}.dll appx COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/libssl-3${OPENSSL_SUFFIX}.dll appx COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/zlib1.dll appx - COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/xerces-c_3_2.dll appx - COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/XalanMessages_1_12.dll appx - COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/Xalan-C_1_12.dll appx - COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/xsec_2_0.dll appx COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/libxml2.dll appx COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/libxmlsec1.dll appx COMMAND ${CMAKE_COMMAND} -E copy ${LIBS_PATH}/libxmlsec1-openssl.dll appx diff --git a/client/Diagnostics_unix.cpp b/client/Diagnostics_unix.cpp index 74055273f..25a2f797e 100644 --- a/client/Diagnostics_unix.cpp +++ b/client/Diagnostics_unix.cpp @@ -28,14 +28,14 @@ #include #include -#ifdef Q_OS_MAC +#ifdef Q_OS_DARWIN #include #endif QStringList Diagnostics::packages(const QStringList &names, bool withName) { QStringList packages; -#ifdef Q_OS_MAC +#ifdef Q_OS_DARWIN Q_UNUSED(withName); for (const QString &name: names) { CFStringRef id = QStringLiteral("ee.ria.%1").arg(name).toCFString(); @@ -88,7 +88,7 @@ void Diagnostics::run() emit update( info ); info.clear(); -#ifndef Q_OS_MAC +#ifndef Q_OS_DARWIN QStringList package = packages({"open-eid"}, false); if( !package.isEmpty() ) s << "" << tr("Base version:") << " " << package.first() << "
"; @@ -98,7 +98,7 @@ void Diagnostics::run() info.clear(); s << "" << tr("OS:") << " " << Common::applicationOs() << "
"; -#ifndef Q_OS_MAC +#ifndef Q_OS_DARWIN s << "" << tr("CPU:") << " "; QFile f( "/proc/cpuinfo" ); if( f.open( QFile::ReadOnly ) ) @@ -124,11 +124,11 @@ void Diagnostics::run() << "OpenSSL build (" << QSslSocket::sslLibraryBuildVersionString() << ")
" << "OpenSSL current (" << QSslSocket::sslLibraryVersionString() << ")
" << packages({ -#ifdef Q_OS_MAC +#ifdef Q_OS_DARWIN "digidocpp" #else "libdigidocpp1", "qdigidoc4", "firefox-pkcs11-loader", "chrome-token-signing", "web-eid", - "libxerces-c3.2", "libxml-security-c20", "libxalan-c111", "libxalan-c112", + "libxerces-c3.2", "libxml-security-c20", "libxalan-c111", "libxalan-c112", "libxml2", "libxmlsec1", "openssl", "libpcsclite1", "pcsc-lite", "opensc", "awp" #endif }).join(QStringLiteral("
")) << "

"; @@ -139,7 +139,7 @@ void Diagnostics::run() emit update( info ); info.clear(); -#ifndef Q_OS_MAC +#ifndef Q_OS_DARWIN QStringList browsers = packages({"chromium-browser", "firefox", "MozillaFirefox", "google-chrome-stable"}); if( !browsers.isEmpty() ) s << "

" << tr("Browsers:") << "
" << browsers.join(QStringLiteral("
")) << "

"; diff --git a/client/Diagnostics_win.cpp b/client/Diagnostics_win.cpp index f5ea20157..2fe42eb4a 100644 --- a/client/Diagnostics_win.cpp +++ b/client/Diagnostics_win.cpp @@ -30,6 +30,8 @@ #include +using namespace Qt::StringLiterals; + static QString getUserRights() { HANDLE hToken {}; @@ -76,11 +78,11 @@ static QString getUserRights() QStringList Diagnostics::packages(const QStringList &names, bool withName) { QStringList packages; - for(const QString &group: {QStringLiteral("HKEY_LOCAL_MACHINE"), QStringLiteral("HKEY_CURRENT_USER")}) + for(const QString &group: {u"HKEY_LOCAL_MACHINE"_s, u"HKEY_CURRENT_USER"_s}) { - QString path = QStringLiteral("%1\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall").arg(group); + QString path = u"%1\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"_s.arg(group); static const QVector formats = []() -> QVector { - if(QSysInfo::currentCpuArchitecture().contains(QStringLiteral("64"))) + if(QSysInfo::currentCpuArchitecture().contains("64"_L1)) return {QSettings::Registry32Format, QSettings::Registry64Format}; return {QSettings::Registry32Format}; }(); @@ -90,11 +92,11 @@ QStringList Diagnostics::packages(const QStringList &names, bool withName) for(const QString &key: s.childGroups()) { s.beginGroup(key); - QString name = s.value(QStringLiteral("/DisplayName")).toString(); - QString version = s.value(QStringLiteral("/DisplayVersion")).toString(); - QString type = s.value(QStringLiteral("/ReleaseType")).toString(); - if(!type.contains(QStringLiteral("Update"), Qt::CaseInsensitive) && - !name.contains(QStringLiteral("Update"), Qt::CaseInsensitive) && + QString name = s.value("/DisplayName"_L1).toString(); + QString version = s.value("/DisplayVersion"_L1).toString(); + QString type = s.value("/ReleaseType"_L1).toString(); + if(!type.contains("Update"_L1, Qt::CaseInsensitive) && + !name.contains("Update"_L1, Qt::CaseInsensitive) && name.contains(QRegularExpression(names.join('|').prepend('^'), QRegularExpression::CaseInsensitiveOption))) packages.append(packageName(name, version, withName)); s.endGroup(); @@ -149,12 +151,10 @@ void Diagnostics::run() + ";C:\\Program Files (x86)\\EstIDMinidriver Minidriver"); SetDllDirectory(LPCWSTR(qApp->applicationDirPath().utf16())); static const QStringList dlls{ - "digidoc", "digidocpp", "qdigidoc4.exe", "qdigidocclient.exe", "qesteidutil.exe", "id-updater.exe", "qdigidoc_tera_gui.exe", - "esteidcm", "esteidcm64", "EstIDMinidriver", "EstIDMinidriver64", "onepin-opensc-pkcs11", "EsteidShellExtension", - "esteid-plugin-ie", "esteid-plugin-ie64", "chrome-token-signing.exe", "web-eid.exe", - "libcrypto-3", "libssl-3", "libcrypto-3-x64", "libssl-3-x64", "libcrypto-1_1", "libssl-1_1", "libcrypto-1_1-x64", "libssl-1_1-x64", - "zlib1", "xerces-c_3_1", "xerces-c_3_2", "xalan-c_1_12", "xalanmessages_1_12", "xsec_1_7", "xsec_2_0", "libxml2", - "advapi32", "crypt32", "winscard"}; + "digidocpp", "qdigidoc4.exe", "EsteidShellExtension", "id-updater.exe", + "EstIDMinidriver", "EstIDMinidriver64", "chrome-token-signing.exe", "web-eid.exe", + "libcrypto-3", "libssl-3", "libcrypto-3-x64", "libssl-3-x64", + "zlib1", "libxml2", "libxmlsec1", "libxmlsec1-openssl"}; for(const QString &lib: dlls) { DWORD infoHandle {}; @@ -168,7 +168,7 @@ void Diagnostics::run() UINT len {}; if( !VerQueryValueW( data.constData(), L"\\", (LPVOID*)&info, &len ) ) continue; - s << QStringLiteral("%1 (%2.%3.%4.%5)").arg(lib) + s << u"%1 (%2.%3.%4.%5)"_s.arg(lib) .arg( HIWORD(info->dwFileVersionMS) ) .arg( LOWORD(info->dwFileVersionMS) ) .arg( HIWORD(info->dwFileVersionLS) ) @@ -225,9 +225,9 @@ void Diagnostics::run() info.clear(); QStringList browsers = packages({"Mozilla Firefox", "Google Chrome", "Microsoft EDGE"}); - QSettings reg(QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer"), QSettings::NativeFormat); - browsers << QStringLiteral("Internet Explorer (%1)").arg(reg.value("svcVersion", reg.value("Version")).toString()); - s << "

" << tr("Browsers:") << "
" << browsers.join(QStringLiteral("
")) << "

"; + QSettings reg(u"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer"_s, QSettings::NativeFormat); + browsers << u"Internet Explorer (%1)"_s.arg(reg.value("svcVersion", reg.value("Version")).toString()); + s << "

" << tr("Browsers:") << "
" << browsers.join("
"_L1) << "

"; emit update( info ); info.clear(); } diff --git a/qdigidoc4.wxs b/qdigidoc4.wxs index 43d1708ef..d669a008b 100644 --- a/qdigidoc4.wxs +++ b/qdigidoc4.wxs @@ -96,10 +96,6 @@ - - - -