Skip to content

Commit

Permalink
Use libxml2/xmsec1 for XAdES signature parsing and validation
Browse files Browse the repository at this point in the history
IB-7948

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Jul 30, 2024
1 parent c7c86b8 commit 6562fb9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
8 changes: 2 additions & 6 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ if( APPLE )
COMMAND rm $<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Frameworks/digidocpp.framework/Resources/digidoc-tool
COMMAND find $<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Frameworks -name Headers | xargs rm -rf
COMMAND install_name_tool -delete_rpath /Library/Frameworks $<TARGET_FILE:${PROJECT_NAME}>
COMMAND ln -sf digidocpp.framework/Libraries/libcrypto.dylib
COMMAND ln -sf digidocpp.framework/Libraries/libcrypto.3.dylib
$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Frameworks/libcrypto.3.dylib
COMMAND ln -sf digidocpp.framework/Libraries/libssl.dylib
COMMAND ln -sf digidocpp.framework/Libraries/libssl.3.dylib
$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Frameworks/libssl.3.dylib
)

Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions client/Diagnostics_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
#include <QtNetwork/QSslSocket>

#include <sys/utsname.h>
#ifdef Q_OS_MAC
#ifdef Q_OS_DARWIN
#include <CoreFoundation/CFBundle.h>
#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();
Expand Down Expand Up @@ -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 << "<b>" << tr("Base version:") << "</b> " << package.first() << "<br />";
Expand All @@ -98,7 +98,7 @@ void Diagnostics::run()
info.clear();

s << "<b>" << tr("OS:") << "</b> " << Common::applicationOs() << "<br />";
#ifndef Q_OS_MAC
#ifndef Q_OS_DARWIN
s << "<b>" << tr("CPU:") << "</b> ";
QFile f( "/proc/cpuinfo" );
if( f.open( QFile::ReadOnly ) )
Expand All @@ -124,11 +124,11 @@ void Diagnostics::run()
<< "OpenSSL build (" << QSslSocket::sslLibraryBuildVersionString() << ")<br />"
<< "OpenSSL current (" << QSslSocket::sslLibraryVersionString() << ")<br />"
<< 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("<br />")) << "<br /><br />";
Expand All @@ -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 << "<br /><br /><b>" << tr("Browsers:") << "</b><br />" << browsers.join(QStringLiteral("<br />")) << "<br /><br />";
Expand Down
28 changes: 15 additions & 13 deletions client/Diagnostics_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include <qt_windows.h>

using namespace Qt::StringLiterals;

static QString getUserRights()
{
HANDLE hToken {};
Expand Down Expand Up @@ -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<QSettings::Format> formats = []() -> QVector<QSettings::Format> {
if(QSysInfo::currentCpuArchitecture().contains(QStringLiteral("64")))
if(QSysInfo::currentCpuArchitecture().contains("64"_L1))
return {QSettings::Registry32Format, QSettings::Registry64Format};
return {QSettings::Registry32Format};
}();
Expand All @@ -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();
Expand Down Expand Up @@ -153,7 +155,7 @@ void Diagnostics::run()
"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",
"zlib1", "xerces-c_3_1", "xerces-c_3_2", "xalan-c_1_12", "xalanmessages_1_12", "xsec_1_7", "xsec_2_0", "libxml2", "libxmlsec1", "libxmlsec1-openssl",
"advapi32", "crypt32", "winscard"};
for(const QString &lib: dlls)
{
Expand All @@ -168,7 +170,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) )
Expand Down Expand Up @@ -225,9 +227,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 << "<br /><br /><b>" << tr("Browsers:") << "</b><br />" << browsers.join(QStringLiteral("<br />")) << "<br /><br />";
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 << "<br /><br /><b>" << tr("Browsers:") << "</b><br />" << browsers.join("<br />"_L1) << "<br /><br />";
emit update( info );
info.clear();
}
4 changes: 0 additions & 4 deletions qdigidoc4.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@
</ProgId>
</Component>
<File Name="zlib$(var.qt_suffix)1.dll" />
<File Name="xerces-c_3_2$(var.qt_suffix).dll" />
<File Name="XalanMessages_1_12$(var.qt_suffix).dll" />
<File Name="Xalan-C_1_12$(var.qt_suffix).dll" />
<File Name="xsec_2_0$(var.qt_suffix).dll" />
<File Name="libxml2.dll" />
<File Name="libxmlsec1.dll" />
<File Name="libxmlsec1-openssl.dll" />
Expand Down

0 comments on commit 6562fb9

Please sign in to comment.