1//========================================================================
2//
3// SignatureInfo.h
4//
5// This file is licensed under the GPLv2 or later
6//
7// Copyright 2015 André Guerreiro <aguerreiro1985@gmail.com>
8// Copyright 2015 André Esser <bepandre@hotmail.com>
9// Copyright 2015, 2017, 2018, 2020 Albert Astals Cid <aacid@kde.org>
10// Copyright 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.de>
11// Copyright 2018 Chinmoy Ranjan Pradhan <chinmoyrp65@protonmail.com>
12// Copyright 2018 Oliver Sander <oliver.sander@tu-dresden.de>
13// Copyright 2021 Georgiy Sgibnev <georgiy@sgibnev.com>. Work sponsored by lab50.net.
14// Copyright 2021 André Guerreiro <aguerreiro1985@gmail.com>
15// Copyright 2021 Marek Kasik <mkasik@redhat.com>
16// Copyright 2023, 2024 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk>
17//
18//========================================================================
19
20#ifndef SIGNATUREINFO_H
21#define SIGNATUREINFO_H
22
23#include <memory>
24#include <ctime>
25
26#include "poppler_private_export.h"
27#include "goo/GooString.h"
28#include "HashAlgorithm.h"
29
30enum SignatureValidationStatus
31{
32 SIGNATURE_VALID,
33 SIGNATURE_INVALID,
34 SIGNATURE_DIGEST_MISMATCH,
35 SIGNATURE_DECODING_ERROR,
36 SIGNATURE_GENERIC_ERROR,
37 SIGNATURE_NOT_FOUND,
38 SIGNATURE_NOT_VERIFIED
39};
40
41enum CertificateValidationStatus
42{
43 CERTIFICATE_TRUSTED,
44 CERTIFICATE_UNTRUSTED_ISSUER,
45 CERTIFICATE_UNKNOWN_ISSUER,
46 CERTIFICATE_REVOKED,
47 CERTIFICATE_EXPIRED,
48 CERTIFICATE_GENERIC_ERROR,
49 CERTIFICATE_NOT_VERIFIED
50};
51
52class X509CertificateInfo;
53
54class POPPLER_PRIVATE_EXPORT SignatureInfo
55{
56public:
57 SignatureInfo() = default;
58 ~SignatureInfo();
59
60 SignatureInfo(const SignatureInfo &) = delete;
61 SignatureInfo &operator=(const SignatureInfo &) = delete;
62
63 /* GETTERS */
64 SignatureValidationStatus getSignatureValStatus() const;
65 std::string getSignerName() const;
66 std::string getSubjectDN() const;
67 const GooString &getLocation() const;
68 const GooString &getReason() const;
69 HashAlgorithm getHashAlgorithm() const; // Returns the used HashAlgorithm, and unknown if compiled without signature support
70 time_t getSigningTime() const;
71 bool isSubfilterSupported() const { return sig_subfilter_supported; }
72 const X509CertificateInfo *getCertificateInfo() const;
73
74 /* SETTERS */
75 void setSignatureValStatus(enum SignatureValidationStatus);
76 void setSignerName(const std::string &);
77 void setSubjectDN(const std::string &);
78 void setLocation(const GooString *);
79 void setReason(const GooString *);
80 void setHashAlgorithm(HashAlgorithm);
81 void setSigningTime(time_t);
82 void setSubFilterSupport(bool isSupported) { sig_subfilter_supported = isSupported; }
83 void setCertificateInfo(std::unique_ptr<X509CertificateInfo>);
84
85private:
86 SignatureValidationStatus sig_status = SIGNATURE_NOT_VERIFIED;
87 std::unique_ptr<X509CertificateInfo> cert_info;
88 std::string signer_name;
89 std::string subject_dn;
90 GooString location;
91 GooString reason;
92 HashAlgorithm hash_type = HashAlgorithm::Unknown;
93 time_t signing_time = 0;
94 bool sig_subfilter_supported = false;
95};
96
97#endif
98

source code of poppler/poppler/SignatureInfo.h