File indexing completed on 2025-12-10 10:23:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef CERTIFICATEINFO_H
0016 #define CERTIFICATEINFO_H
0017
0018 #include <memory>
0019 #include <ctime>
0020 #include "goo/GooString.h"
0021 #include "poppler_private_export.h"
0022
0023 enum CertificateKeyUsageExtension
0024 {
0025 KU_DIGITAL_SIGNATURE = 0x80,
0026 KU_NON_REPUDIATION = 0x40,
0027 KU_KEY_ENCIPHERMENT = 0x20,
0028 KU_DATA_ENCIPHERMENT = 0x10,
0029 KU_KEY_AGREEMENT = 0x08,
0030 KU_KEY_CERT_SIGN = 0x04,
0031 KU_CRL_SIGN = 0x02,
0032 KU_ENCIPHER_ONLY = 0x01,
0033 KU_NONE = 0x00
0034 };
0035
0036 enum PublicKeyType
0037 {
0038 RSAKEY,
0039 DSAKEY,
0040 ECKEY,
0041 OTHERKEY
0042 };
0043
0044 class POPPLER_PRIVATE_EXPORT X509CertificateInfo
0045 {
0046 public:
0047 X509CertificateInfo();
0048 ~X509CertificateInfo();
0049
0050 X509CertificateInfo(const X509CertificateInfo &) = delete;
0051 X509CertificateInfo &operator=(const X509CertificateInfo &) = delete;
0052
0053 struct PublicKeyInfo
0054 {
0055 PublicKeyInfo() = default;
0056
0057 PublicKeyInfo(PublicKeyInfo &&) noexcept = default;
0058 PublicKeyInfo &operator=(PublicKeyInfo &&) noexcept = default;
0059
0060 PublicKeyInfo(const PublicKeyInfo &) = delete;
0061 PublicKeyInfo &operator=(const PublicKeyInfo &) = delete;
0062
0063 GooString publicKey;
0064 PublicKeyType publicKeyType = OTHERKEY;
0065 unsigned int publicKeyStrength = 0;
0066 };
0067
0068 struct EntityInfo
0069 {
0070 EntityInfo() = default;
0071 ~EntityInfo() = default;
0072
0073 EntityInfo(EntityInfo &&) noexcept = default;
0074 EntityInfo &operator=(EntityInfo &&) noexcept = default;
0075
0076 EntityInfo(const EntityInfo &) = delete;
0077 EntityInfo &operator=(const EntityInfo &) = delete;
0078
0079 std::string commonName;
0080 std::string distinguishedName;
0081 std::string email;
0082 std::string organization;
0083 };
0084
0085 struct Validity
0086 {
0087 Validity() : notBefore(0), notAfter(0) { }
0088
0089 time_t notBefore;
0090 time_t notAfter;
0091 };
0092
0093
0094 int getVersion() const;
0095 const GooString &getSerialNumber() const;
0096 const GooString &getNickName() const;
0097 const EntityInfo &getIssuerInfo() const;
0098 const Validity &getValidity() const;
0099 const EntityInfo &getSubjectInfo() const;
0100 const PublicKeyInfo &getPublicKeyInfo() const;
0101 unsigned int getKeyUsageExtensions() const;
0102 const GooString &getCertificateDER() const;
0103 bool getIsSelfSigned() const;
0104
0105
0106 void setVersion(int);
0107 void setSerialNumber(const GooString &);
0108 void setNickName(const GooString &);
0109 void setIssuerInfo(EntityInfo &&);
0110 void setValidity(Validity);
0111 void setSubjectInfo(EntityInfo &&);
0112 void setPublicKeyInfo(PublicKeyInfo &&);
0113 void setKeyUsageExtensions(unsigned int);
0114 void setCertificateDER(const GooString &);
0115 void setIsSelfSigned(bool);
0116
0117 private:
0118 EntityInfo issuer_info;
0119 EntityInfo subject_info;
0120 PublicKeyInfo public_key_info;
0121 Validity cert_validity;
0122 GooString cert_serial;
0123 GooString cert_der;
0124 GooString cert_nick;
0125 unsigned int ku_extensions;
0126 int cert_version;
0127 bool is_self_signed;
0128 };
0129
0130 #endif