Skip to content

Commit aba89db

Browse files
authored
Allow only qualified TimeStamp-s (#640)
IB-8250 Signed-off-by: Raul Metsma <[email protected]>
1 parent 47168f7 commit aba89db

19 files changed

+10100
-651
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
with:
6767
name: ${{ matrix.target }}
6868
path: |
69-
build/macos/libdigidocpp*.*
69+
build/*/libdigidocpp*.*
7070
libdigidocpp*.zip
7171
fedora:
7272
name: Build on Fedora ${{ matrix.container }}
@@ -79,7 +79,7 @@ jobs:
7979
- name: Install Deps
8080
run: |
8181
dnf install -y --setopt=install_weak_deps=False \
82-
${FEDORA_DEPS} doxygen boost-test swig python3-devel java-21-openjdk-devel rpm-build git
82+
${FEDORA_DEPS} doxygen boost-test swig python3-devel java-21-openjdk-devel rpm-build
8383
- name: Checkout
8484
uses: actions/checkout@v4
8585
- name: Build
@@ -105,7 +105,7 @@ jobs:
105105
106106
steps:
107107
- name: Install dependencies
108-
run: apt update -qq && apt install --no-install-recommends -y git lsb-release build-essential devscripts debhelper lintian pkg-config ${UBUNTU_DEPS} doxygen swig openjdk-11-jdk-headless libpython3-dev python3-setuptools libboost-test-dev
108+
run: apt update -qq && apt install --no-install-recommends -y lsb-release build-essential devscripts debhelper lintian pkg-config ${UBUNTU_DEPS} doxygen swig openjdk-11-jdk-headless libpython3-dev python3-setuptools libboost-test-dev
109109
- name: Checkout
110110
uses: actions/checkout@v4
111111
- name: Setup changelog

src/crypto/TSL.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,13 @@ constexpr array SERVICESTATUS_END {
8080

8181
constexpr array SERVICES_SUPPORTED {
8282
"http://uri.etsi.org/TrstSvc/Svctype/CA/QC",
83-
//"http://uri.etsi.org/TrstSvc/Svctype/CA/PKC", //???
84-
//"http://uri.etsi.org/TrstSvc/Svctype/NationalRootCA-QC", //???
8583
"http://uri.etsi.org/TrstSvc/Svctype/Certstatus/OCSP",
8684
"http://uri.etsi.org/TrstSvc/Svctype/Certstatus/OCSP/QC",
87-
"http://uri.etsi.org/TrstSvc/Svctype/TSA",
8885
"http://uri.etsi.org/TrstSvc/Svctype/TSA/QTST",
89-
"http://uri.etsi.org/TrstSvc/Svctype/TSA/TSS-QC", //???
90-
"http://uri.etsi.org/TrstSvc/Svctype/TSA/TSS-AdESQCandQES", //???
9186
};
9287

9388
template<typename C, typename T>
89+
[[nodiscard]]
9490
constexpr bool contains(const C &list, const T &value)
9591
{
9692
return find(list.begin(), list.end(), value) != list.end();

src/crypto/X509CertStore.cpp

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@
3535
using namespace digidoc;
3636
using namespace std;
3737

38+
template<typename C, typename T>
39+
[[nodiscard]]
40+
constexpr bool contains(const C &list, const T &value)
41+
{
42+
return find(list.begin(), list.end(), std::forward<decltype(value)>(value)) != list.end();
43+
};
44+
3845
const X509CertStore::Type X509CertStore::CA {
3946
"http://uri.etsi.org/TrstSvc/Svctype/CA/QC",
4047
};
4148

4249
const X509CertStore::Type X509CertStore::TSA {
43-
"http://uri.etsi.org/TrstSvc/Svctype/TSA",
4450
"http://uri.etsi.org/TrstSvc/Svctype/TSA/QTST",
45-
"http://uri.etsi.org/TrstSvc/Svctype/TSA/TSS-QC",
46-
"http://uri.etsi.org/TrstSvc/Svctype/TSA/TSS-AdESQCandQES",
4751
};
4852

4953
const X509CertStore::Type X509CertStore::OCSP {
@@ -240,29 +244,24 @@ bool X509CertStore::verify(const X509Cert &cert, bool noqscd) const
240244
const vector<string> policies = cert.certificatePolicies();
241245
const vector<string> qcstatement = cert.qcStatements();
242246
const vector<X509Cert::KeyUsage> keyUsage = cert.keyUsage();
243-
auto containsPolicy = [&policies](const string &policy) {
244-
return find(policies.cbegin(), policies.cend(), policy) != policies.cend();
245-
};
246-
auto containsQCStatement = [&qcstatement](const string &statement) {
247-
return find(qcstatement.cbegin(), qcstatement.cend(), statement) != qcstatement.cend();
248-
};
249-
250-
bool isQCCompliant = containsQCStatement(X509Cert::QC_COMPLIANT);
247+
bool isQCCompliant = contains(qcstatement, X509Cert::QC_COMPLIANT);
251248
bool isQSCD =
252-
containsPolicy(X509Cert::QCP_PUBLIC_WITH_SSCD) ||
253-
containsPolicy(X509Cert::QCP_LEGAL_QSCD) ||
254-
containsPolicy(X509Cert::QCP_NATURAL_QSCD) ||
255-
containsQCStatement(X509Cert::QC_SSCD);
249+
contains(policies, X509Cert::QCP_PUBLIC_WITH_SSCD) ||
250+
contains(policies, X509Cert::QCP_LEGAL_QSCD) ||
251+
contains(policies, X509Cert::QCP_NATURAL_QSCD) ||
252+
contains(qcstatement, X509Cert::QC_SSCD);
256253

257-
bool isESeal = // Special treamtent for E-Seals
258-
containsPolicy(X509Cert::QCP_LEGAL) ||
259-
containsQCStatement(X509Cert::QCT_ESEAL);
260-
auto matchPolicySet = [&containsPolicy](const vector<string> &policySet){
261-
return all_of(policySet.cbegin(), policySet.cend(), containsPolicy);
254+
bool isESeal = // Special treamtent for E-Seals
255+
contains(policies, X509Cert::QCP_LEGAL) ||
256+
contains(qcstatement, X509Cert::QCT_ESEAL);
257+
auto matchPolicySet = [&policies](const vector<string> &policySet){
258+
return all_of(policySet.cbegin(), policySet.cend(), [&policies](const string &policy) {
259+
return contains(policies, policy);
260+
});
262261
};
263262
auto matchKeyUsageSet = [&keyUsage](const map<X509Cert::KeyUsage,bool> &keyUsageSet){
264263
return all_of(keyUsageSet.cbegin(), keyUsageSet.cend(), [&keyUsage](pair<X509Cert::KeyUsage, bool> keyUsageBit){
265-
return (find(keyUsage.cbegin(), keyUsage.cend(), keyUsageBit.first) != keyUsage.cend()) == keyUsageBit.second;
264+
return contains(keyUsage, keyUsageBit.first) == keyUsageBit.second;
266265
});
267266
};
268267

test/data/EE_T-CA-invalid-type.xml

Lines changed: 635 additions & 36 deletions
Large diffs are not rendered by default.

test/data/EE_T-CA-non-qa.xml

Lines changed: 634 additions & 35 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)