1 | //======================================================================== |
---|---|
2 | // |
3 | // CertificateInfo.cc |
4 | // |
5 | // This file is licensed under the GPLv2 or later |
6 | // |
7 | // Copyright 2018 Chinmoy Ranjan Pradhan <chinmoyrp65@gmail.com> |
8 | // Copyright 2018, 2019, 2022 Albert Astals Cid <aacid@kde.org> |
9 | // Copyright 2018 Oliver Sander <oliver.sander@tu-dresden.de> |
10 | // Copyright 2020 Thorsten Behrens <Thorsten.Behrens@CIB.de> |
11 | // Copyright 2023 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk> |
12 | // |
13 | //======================================================================== |
14 | |
15 | #include "CertificateInfo.h" |
16 | |
17 | #include <cstring> |
18 | #include <cstdlib> |
19 | |
20 | X509CertificateInfo::X509CertificateInfo() : ku_extensions(KU_NONE), cert_version(-1), is_self_signed(false), keyLocation(KeyLocation::Unknown) { } |
21 | |
22 | X509CertificateInfo::~X509CertificateInfo() = default; |
23 | |
24 | int X509CertificateInfo::getVersion() const |
25 | { |
26 | return cert_version; |
27 | } |
28 | |
29 | const GooString &X509CertificateInfo::getSerialNumber() const |
30 | { |
31 | return cert_serial; |
32 | } |
33 | |
34 | const GooString &X509CertificateInfo::getNickName() const |
35 | { |
36 | return cert_nick; |
37 | } |
38 | |
39 | const X509CertificateInfo::EntityInfo &X509CertificateInfo::getIssuerInfo() const |
40 | { |
41 | return issuer_info; |
42 | } |
43 | |
44 | const X509CertificateInfo::Validity &X509CertificateInfo::getValidity() const |
45 | { |
46 | return cert_validity; |
47 | } |
48 | |
49 | const X509CertificateInfo::EntityInfo &X509CertificateInfo::getSubjectInfo() const |
50 | { |
51 | return subject_info; |
52 | } |
53 | |
54 | const X509CertificateInfo::PublicKeyInfo &X509CertificateInfo::getPublicKeyInfo() const |
55 | { |
56 | return public_key_info; |
57 | } |
58 | |
59 | unsigned int X509CertificateInfo::getKeyUsageExtensions() const |
60 | { |
61 | return ku_extensions; |
62 | } |
63 | |
64 | const GooString &X509CertificateInfo::getCertificateDER() const |
65 | { |
66 | return cert_der; |
67 | } |
68 | |
69 | bool X509CertificateInfo::getIsSelfSigned() const |
70 | { |
71 | return is_self_signed; |
72 | } |
73 | |
74 | void X509CertificateInfo::setVersion(int version) |
75 | { |
76 | cert_version = version; |
77 | } |
78 | |
79 | void X509CertificateInfo::setSerialNumber(const GooString &serialNumber) |
80 | { |
81 | cert_serial.Set(&serialNumber); |
82 | } |
83 | |
84 | void X509CertificateInfo::setNickName(const GooString &nickName) |
85 | { |
86 | cert_nick.Set(&nickName); |
87 | } |
88 | |
89 | void X509CertificateInfo::setIssuerInfo(EntityInfo &&issuerInfo) |
90 | { |
91 | issuer_info = std::move(issuerInfo); |
92 | } |
93 | |
94 | void X509CertificateInfo::setValidity(Validity validity) |
95 | { |
96 | cert_validity = validity; |
97 | } |
98 | |
99 | void X509CertificateInfo::setSubjectInfo(EntityInfo &&subjectInfo) |
100 | { |
101 | subject_info = std::move(subjectInfo); |
102 | } |
103 | |
104 | void X509CertificateInfo::setPublicKeyInfo(PublicKeyInfo &&pkInfo) |
105 | { |
106 | public_key_info = std::move(pkInfo); |
107 | } |
108 | |
109 | void X509CertificateInfo::setKeyUsageExtensions(unsigned int keyUsages) |
110 | { |
111 | ku_extensions = keyUsages; |
112 | } |
113 | |
114 | void X509CertificateInfo::setCertificateDER(const GooString &certDer) |
115 | { |
116 | cert_der.Set(&certDer); |
117 | } |
118 | |
119 | void X509CertificateInfo::setIsSelfSigned(bool isSelfSigned) |
120 | { |
121 | is_self_signed = isSelfSigned; |
122 | } |
123 | KeyLocation X509CertificateInfo::getKeyLocation() const |
124 | { |
125 | return keyLocation; |
126 | } |
127 | |
128 | void X509CertificateInfo::setKeyLocation(KeyLocation location) |
129 | { |
130 | keyLocation = location; |
131 | } |
132 |