Debian Codegraph @

mlspp/lib/hpke/src/certificate.cpp

raw symbols SCIP
1 #cxx . . $ `<file>/mlspp/lib/hpke/src/certificate.cpp`/include "group.h"cxx . . $ `<file>/mlspp/lib/hpke/src/group.h`/
2 #include "openssl_common.h"cxx . . $ `<file>/mlspp/lib/hpke/src/openssl_common.h`/
3 #include "rsa.h"cxx . . $ `<file>/mlspp/lib/hpke/src/rsa.h`/
4 #include <hpke/certificate.h>cxx . . $ `<file>/mlspp/lib/hpke/include/hpke/certificate.h`/
5 #include <hpke/signature.h>cxx . . $ `<file>/mlspp/lib/hpke/include/hpke/signature.h`/
6 #include <memory>
7 #include <openssl/err.h>
8 #include <openssl/pem.h>
9 #include <openssl/x509.h>
10 #include <openssl/x509v3.h>
11 #include <tls/compat.h>cxx . . $ `<file>/mlspp/lib/bytes/include/tls/compat.h`/
12
13 namespace mlsppcxx . . $ mlspp/::hpkecxx . . $ mlspp/hpke/ {
14 ///
15 /// Utility functions
16 ///
17
18 static stdcxx . . $ std/::optionalcxx . . $ std/optional#<bytescxx . . $ mlspp/bytes_ns/bytes#>
19 asn1_octet_string_to_bytescxx . . $ mlspp/hpke/asn1_octet_string_to_bytes(8857c08fb026c9b8).(const ASN1_OCTET_STRING* octets)
20 {
21 if (octets == nullptr) {
22 return stdcxx . . $ std/optional#optional(eb2253fdec8870b5).::nulloptcxx . . $ std/nullopt.;
23 }
24 const auto* ptr = ASN1_STRING_get0_data(octets);
25 const auto len = ASN1_STRING_length(octets);
26 // NOLINTNEXTLINE (cppcoreguidelines-pro-bounds-pointer-arithmetic)
27 return stdcxx . . $ std/optional#optional(e3f0d6382bd52f24).::vectorcxx . . $ std/vector#<uint8_tcxx . . $ uint8_t#>(ptr, ptr + len);
28 }
29
30 static stdcxx . . $ std/::stringcxx . . $ std/string#
31 asn1_string_to_std_stringcxx . . $ mlspp/hpke/asn1_string_to_std_string(46b4d744648bec62).(const ASN1_STRING* asn1_string)
32 {
33 const auto* data = ASN1_STRING_get0_data(asn1_string);
34 const auto data_size = static_cast<size_t>(ASN1_STRING_length(asn1_string));
35 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
36 auto str = stdcxx . . $ std/::stringcxx . . $ std/string#(reinterpret_cast<const char*>(data));
37 if (str.sizecxx . . $ std/__cxx11/basic_string#size(6f8bd5c0ea8fb29a).() != data_size) {
38 throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#("Malformed ASN.1 string");
39 }
40 return strcxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).;
41 }
42
43 static stdcxx . . $ std/::chronocxx . . $ std/chrono/::system_clockcxx . . $ std/chrono/_V2/system_clock#::time_pointcxx . . $ std/chrono/_V2/system_clock#time_point#
44 asn1_time_to_chronocxx . . $ mlspp/hpke/asn1_time_to_chrono(c5d02527132d4039).(const ASN1_TIME* asn1_time)
45 {
46 auto epoch_chrono = stdcxx . . $ std/chrono/time_point#time_point(49f6e7a06ebc5aa8).::chronocxx . . $ std/chrono/::system_clockcxx . . $ std/chrono/_V2/system_clock#::time_pointcxx . . $ std/chrono/_V2/system_clock#time_point#();
47 auto epoch_time_t = stdcxx . . $ std/::chronocxx . . $ std/chrono/::system_clockcxx . . $ std/chrono/_V2/system_clock#::to_time_tcxx . . $ std/chrono/_V2/system_clock#to_time_t(88d50d0742db4f1).(epoch_chrono);
48 auto epoch_asn1 = make_typed_uniquecxx . . $ mlspp/hpke/make_typed_unique(f611cc58871fbeab).(ASN1_TIME_set(nullptr, epoch_time_t));
49 if (!epoch_asn1) {
50 throw openssl_errorcxx . . $ mlspp/hpke/openssl_error(d6ab8afd00dfc651).();
51 }
52
53 auto secs = int(0);
54 auto days = int(0);
55 if (ASN1_TIME_diff(&days, &secs, epoch_asn1.getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).(), asn1_time) != 1) {
56 throw openssl_errorcxx . . $ mlspp/hpke/openssl_error(d6ab8afd00dfc651).();
57 }
58
59 auto delta = stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(secs) +cxx . . $ std/chrono/operator+(5ecd5b85551fe1f2). stdcxx . . $ std/::chronocxx . . $ std/chrono/::hourscxx . . $ std/chrono/hours#(24 * days);
60 return stdcxx . . $ std/::chronocxx . . $ std/chrono/::system_clockcxx . . $ std/chrono/_V2/system_clock#::time_pointcxx . . $ std/chrono/_V2/system_clock#time_point#(deltacxx . . $ std/chrono/duration#duration(a833b3f73e1ac0ab).);
61 }
62
63 ///
64 /// ParsedCertificate
65 ///
66
67 const int Certificatecxx . . $ mlspp/hpke/Certificate#::NameTypecxx . . $ mlspp/hpke/Certificate#NameType#::organizationcxx . . $ mlspp/hpke/Certificate#NameType#organization. = NID_organizationNamecxx . . $ `<external>/18030087176251566933/obj_mac.h:2437:9`!;
68 const int Certificatecxx . . $ mlspp/hpke/Certificate#::NameTypecxx . . $ mlspp/hpke/Certificate#NameType#::common_namecxx . . $ mlspp/hpke/Certificate#NameType#common_name. = NID_commonNamecxx . . $ `<external>/18030087176251566933/obj_mac.h:2403:9`!;
69 const int Certificatecxx . . $ mlspp/hpke/Certificate#::NameTypecxx . . $ mlspp/hpke/Certificate#NameType#::organizational_unitcxx . . $ mlspp/hpke/Certificate#NameType#organizational_unit. =
70 NID_organizationalUnitNamecxx . . $ `<external>/18030087176251566933/obj_mac.h:2442:9`!;
71 const int Certificatecxx . . $ mlspp/hpke/Certificate#::NameTypecxx . . $ mlspp/hpke/Certificate#NameType#::countrycxx . . $ mlspp/hpke/Certificate#NameType#country. = NID_countryNamecxx . . $ `<external>/18030087176251566933/obj_mac.h:2417:9`!;
72 const int Certificatecxx . . $ mlspp/hpke/Certificate#::NameTypecxx . . $ mlspp/hpke/Certificate#NameType#::serial_numbercxx . . $ mlspp/hpke/Certificate#NameType#serial_number. = NID_serialNumbercxx . . $ `<external>/18030087176251566933/obj_mac.h:2412:9`!;
73 const int Certificatecxx . . $ mlspp/hpke/Certificate#::NameTypecxx . . $ mlspp/hpke/Certificate#NameType#::state_or_province_namecxx . . $ mlspp/hpke/Certificate#NameType#state_or_province_name. =
74 NID_stateOrProvinceNamecxx . . $ `<external>/18030087176251566933/obj_mac.h:2427:9`!;
75
76 struct RFC822Namecxx . . $ mlspp/hpke/RFC822Name#
77 {
78 stdcxx . . $ std/::stringcxx . . $ std/string# valuecxx . . $ mlspp/hpke/RFC822Name#value.;
79 };
80
81 struct DNSNamecxx . . $ mlspp/hpke/DNSName#
82 {
83 stdcxx . . $ std/::stringcxx . . $ std/string# valuecxx . . $ mlspp/hpke/DNSName#value.;
84 };
85
86 using GeneralNamecxx . . $ mlspp/hpke/GeneralName# = tlscxx . . $ mlspp/tls/::var::variantcxx . . $ std/variant#<RFC822Namecxx . . $ mlspp/hpke/RFC822Name#, DNSNamecxx . . $ mlspp/hpke/DNSName#>;
87
88 struct Certificatecxx . . $ mlspp/hpke/Certificate#::ParsedCertificatecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#
89 {
90
91 static stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ParsedCertificatecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#> parsecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse(3a6228dc0f4dd58a).(const bytescxx . . $ mlspp/bytes_ns/bytes#& der)
92 {
93 const auto* buf = der.datacxx . . $ mlspp/bytes_ns/bytes#data(7eb257f306f79f97).();
94 auto cert =
95 make_typed_uniquecxx . . $ mlspp/hpke/make_typed_unique(f611cc58871fbeab).(d2i_X509(nullptr, &buf, static_cast<int>(der.sizecxx . . $ mlspp/bytes_ns/bytes#size(fe4d2d262d4164a8).())));
96 if (cert ==cxx . . $ std/`operator==`(e445595a98297a59). nullptr) {
97 throw openssl_errorcxx . . $ mlspp/hpke/openssl_error(d6ab8afd00dfc651).();
98 }
99
100 return stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ParsedCertificatecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#>(cert.releasecxx . . $ std/unique_ptr#release(aad4c3669c5e940c).());
101 }
102
103 static bytescxx . . $ mlspp/bytes_ns/bytes# compute_digestcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#compute_digest(86c30c3f15c319a).(const X509* cert)
104 {
105 const auto* md = EVP_sha256();
106 auto digest = bytescxx . . $ mlspp/bytes_ns/bytes#(EVP_MD_sizecxx . . $ `<external>/2497497914425334111/evp.h:566:9`!(md));
107 unsigned int out_size = 0;
108 if (1 != X509_digest(cert, md, digest.datacxx . . $ mlspp/bytes_ns/bytes#data(37d8967d10cb1e7b).(), &out_size)) {
109 throw openssl_errorcxx . . $ mlspp/hpke/openssl_error(d6ab8afd00dfc651).();
110 }
111 return digestcxx . . $ mlspp/bytes_ns/bytes#bytes(628b76f52f2a67f).;
112 }
113
114 // Note: This method does not implement total general name parsing.
115 // Duplicate entries are not supported; if they are present, the last one
116 // presented by OpenSSL is chosen.
117 static ParsedNamecxx . . $ mlspp/hpke/Certificate#ParsedName# parse_namescxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_names(5752a977b7a315ad).(const X509_NAME* x509_name)
118 {
119 if (x509_name == nullptr) {
120 throw openssl_errorcxx . . $ mlspp/hpke/openssl_error(d6ab8afd00dfc651).();
121 }
122
123 ParsedNamecxx . . $ mlspp/hpke/Certificate#ParsedName# parsed_namecxx . . $ std/map#map(49f6e7a06ebc5aa8).;
124
125 for (int i = X509_NAME_entry_count(x509_name) - 1; i >= 0; i--) {
126 auto* entry = X509_NAME_get_entry(x509_name, i);
127 if (entry == nullptr) {
128 continue;
129 }
130
131 auto* oid = X509_NAME_ENTRY_get_object(entry);
132 auto* asn_str = X509_NAME_ENTRY_get_data(entry);
133 if (oid == nullptr || asn_str == nullptr) {
134 continue;
135 }
136
137 const int nid = OBJ_obj2nid(oid);
138 const stdcxx . . $ std/::stringcxx . . $ std/string# parsed_value = asn1_string_to_std_stringcxx . . $ mlspp/hpke/asn1_string_to_std_string(46b4d744648bec62).(asn_str);
139 parsed_name[cxx . . $ std/map#`operator[]`(bbd415b616967878).nid] =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). parsed_value;
140 }
141
142 return parsed_namecxx . . $ std/map#map(3d8f9cfb6064bed1).;
143 }
144
145 // Parse Subject Key Identifier Extension
146 static stdcxx . . $ std/::optionalcxx . . $ std/optional#<bytescxx . . $ mlspp/bytes_ns/bytes#> parse_skidcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_skid(a40660bddeda4280).(X509* cert)
147 {
148 return asn1_octet_string_to_bytescxx . . $ mlspp/hpke/asn1_octet_string_to_bytes(8857c08fb026c9b8).(X509_get0_subject_key_id(cert));
149 }
150
151 // Parse Authority Key Identifier
152 static stdcxx . . $ std/::optionalcxx . . $ std/optional#<bytescxx . . $ mlspp/bytes_ns/bytes#> parse_akidcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_akid(a40660bddeda4280).(X509* cert)
153 {
154 return asn1_octet_string_to_bytescxx . . $ mlspp/hpke/asn1_octet_string_to_bytes(8857c08fb026c9b8).(X509_get0_authority_key_id(cert));
155 }
156
157 static stdcxx . . $ std/::vectorcxx . . $ std/vector#<GeneralNamecxx . . $ mlspp/hpke/GeneralName#> parse_sancxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_san(be015bf81ba3e64b).(X509* cert)
158 {
159 stdcxx . . $ std/::vectorcxx . . $ std/vector#<GeneralNamecxx . . $ mlspp/hpke/GeneralName#> namescxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
160
161 #ifdef WITH_BORINGSSL
162 using san_names_nb_t = size_t;
163 #else
164 using san_names_nb_tcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_san(be015bf81ba3e64b).san_names_nb_t# = int;
165 #endif
166
167 san_names_nb_tcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_san(be015bf81ba3e64b).san_names_nb_t# san_names_nb = 0;
168
169 auto* ext_ptr =
170 X509_get_ext_d2i(cert, NID_subject_alt_namecxx . . $ `<external>/18030087176251566933/obj_mac.h:2695:9`!, nullptr, nullptr);
171 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
172 auto* san_ptr = reinterpret_cast<STACK_OFcxx . . $ `<external>/13247083851530363302/safestack.h:33:9`!(GENERAL_NAME)*>(ext_ptr);
173 const auto san_names = make_typed_uniquecxx . . $ mlspp/hpke/make_typed_unique(f611cc58871fbeab).(san_ptr);
174 san_names_nb = sk_GENERAL_NAME_numcxx . . $ `<external>/8547403039021081366/x509v3.h:242:9`!(san_names.get());
175
176 // Check each name within the extension
177 for (san_names_nb_tcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_san(be015bf81ba3e64b).san_names_nb_t# i = 0; i < san_names_nb; i++) {
178 auto* current_name = sk_GENERAL_NAME_valuecxx . . $ `<external>/8547403039021081366/x509v3.h:243:9`!(san_names.get(), i);
179 if (current_name->type == GEN_DNScxx . . $ `<external>/8547403039021081366/x509v3.h:178:9`!) {
180 const auto dns_name =
181 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access)
182 asn1_string_to_std_stringcxx . . $ mlspp/hpke/asn1_string_to_std_string(46b4d744648bec62).(current_name->d.dNSName);
183 names.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(DNSNamecxx . . $ mlspp/hpke/DNSName#{ dns_name });
184 } else if (current_name->type == GEN_EMAILcxx . . $ `<external>/8547403039021081366/x509v3.h:177:9`!) {
185 const auto email =
186 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access
187 asn1_string_to_std_stringcxx . . $ mlspp/hpke/asn1_string_to_std_string(46b4d744648bec62).(current_name->d.rfc822Name);
188 names.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(RFC822Namecxx . . $ mlspp/hpke/RFC822Name#{ email });
189 }
190 }
191
192 return namescxx . . $ std/vector#vector(6f559d22b039ccdb).;
193 }
194
195 explicit ParsedCertificatecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#ParsedCertificate(6d28345afe631eba).(X509* x509_in)
196 : x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509.(x509_in, typed_deletecxx . . $ mlspp/hpke/typed_delete(ebd0a1552f8ce24f).<X509>)
197 , pub_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#pub_key_id.(public_key_algorithmcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#public_key_algorithm(57144064b5dd6aaa).(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()))
198 , sig_algocxx . . $ mlspp/hpke/Certificate#ParsedCertificate#sig_algo.(signature_algorithmcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#signature_algorithm(57144064b5dd6aaa).(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()))
199 , issuer_hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#issuer_hash.(X509_issuer_name_hash(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()))
200 , subject_hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject_hash.(X509_subject_name_hash(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()))
201 , issuercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#issuer.(parse_namescxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_names(5752a977b7a315ad).(X509_get_issuer_name(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).())))
202 , subjectcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject.(parse_namescxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_names(5752a977b7a315ad).(X509_get_subject_name(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).())))
203 , subject_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject_key_id.(parse_skidcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_skid(a40660bddeda4280).(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()))
204 , authority_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#authority_key_id.(parse_akidcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_akid(a40660bddeda4280).(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()))
205 , sub_alt_namescxx . . $ mlspp/hpke/Certificate#ParsedCertificate#sub_alt_names.(parse_sancxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse_san(be015bf81ba3e64b).(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()))
206 , is_cacxx . . $ mlspp/hpke/Certificate#ParsedCertificate#is_ca.(X509_check_ca(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()) != 0)
207 , hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#hash.(compute_digestcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#compute_digest(86c30c3f15c319a).(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()))
208 , not_beforecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_before.(asn1_time_to_chronocxx . . $ mlspp/hpke/asn1_time_to_chrono(c5d02527132d4039).(X509_get0_notBefore(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).())))
209 , not_aftercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_after.(asn1_time_to_chronocxx . . $ mlspp/hpke/asn1_time_to_chrono(c5d02527132d4039).(X509_get0_notAfter(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).())))
210 {
211 }
212
213 ParsedCertificatecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#ParsedCertificate(36a4f9de699ab3b5).(const ParsedCertificatecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#& other)
214 : x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509.(nullptr, typed_deletecxx . . $ mlspp/hpke/typed_delete(ebd0a1552f8ce24f).<X509>)
215 , pub_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#pub_key_id.(public_key_algorithmcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#public_key_algorithm(57144064b5dd6aaa).(other.x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()))
216 , sig_algocxx . . $ mlspp/hpke/Certificate#ParsedCertificate#sig_algo.(signature_algorithmcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#signature_algorithm(57144064b5dd6aaa).(other.x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()))
217 , issuer_hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#issuer_hash.(other.issuer_hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#issuer_hash.)
218 , subject_hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject_hash.(other.subject_hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject_hash.)
219 , issuercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#issuer.(other.issuercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#issuer.)
220 , subjectcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject.(other.subjectcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject.)
221 , subject_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject_key_id.(other.subject_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject_key_id.)
222 , authority_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#authority_key_id.(other.authority_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#authority_key_id.)
223 , sub_alt_namescxx . . $ mlspp/hpke/Certificate#ParsedCertificate#sub_alt_names.(other.sub_alt_namescxx . . $ mlspp/hpke/Certificate#ParsedCertificate#sub_alt_names.)
224 , is_cacxx . . $ mlspp/hpke/Certificate#ParsedCertificate#is_ca.(other.is_cacxx . . $ mlspp/hpke/Certificate#ParsedCertificate#is_ca.)
225 , hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#hash.(other.hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#hash.)
226 , not_beforecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_before.(other.not_beforecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_before.)
227 , not_aftercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_after.(other.not_aftercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_after.)
228 {
229 if (1 != X509_up_ref(other.x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).())) {
230 throw openssl_errorcxx . . $ mlspp/hpke/openssl_error(d6ab8afd00dfc651).();
231 }
232 x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..resetcxx . . $ std/unique_ptr#reset(c8c3025d73122d7d).(other.x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).());
233 }
234
235 static Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID# public_key_algorithmcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#public_key_algorithm(57144064b5dd6aaa).(X509* x509)
236 {
237 #if WITH_BORINGSSL
238 const auto pub = make_typed_unique(X509_get_pubkey(x509));
239 const auto* pub_ptr = pub.get();
240 #else
241 const auto* pub_ptr = X509_get0_pubkey(x509);
242 #endif
243
244 switch (EVP_PKEY_base_idcxx . . $ `<external>/2497497914425334111/evp.h:1367:9`!(pub_ptr)) {
245 case EVP_PKEY_ED25519cxx . . $ `<external>/2497497914425334111/evp.h:83:9`!:
246 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::Ed25519cxx . . $ mlspp/hpke/Signature#ID#Ed25519.;
247 #if !defined(WITH_BORINGSSL)
248 case EVP_PKEY_ED448cxx . . $ `<external>/2497497914425334111/evp.h:85:9`!:
249 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::Ed448cxx . . $ mlspp/hpke/Signature#ID#Ed448.;
250 #endif
251 case EVP_PKEY_ECcxx . . $ `<external>/2497497914425334111/evp.h:73:9`!: {
252 auto key_size = EVP_PKEY_bitscxx . . $ `<external>/2497497914425334111/evp.h:1369:9`!(pub_ptr);
253 switch (key_size) {
254 case 256:
255 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P256_SHA256cxx . . $ mlspp/hpke/Signature#ID#P256_SHA256.;
256 case 384:
257 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P384_SHA384cxx . . $ mlspp/hpke/Signature#ID#P384_SHA384.;
258 case 521:
259 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P521_SHA512cxx . . $ mlspp/hpke/Signature#ID#P521_SHA512.;
260 default:
261 throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#("Unknown curve");
262 }
263 }
264 case EVP_PKEY_RSAcxx . . $ `<external>/2497497914425334111/evp.h:63:9`!:
265 // RSA public keys are not specific to an algorithm
266 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::RSA_SHA256cxx . . $ mlspp/hpke/Signature#ID#RSA_SHA256.;
267 default:
268 break;
269 }
270 throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#("Unsupported public key algorithm");
271 }
272
273 static Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID# signature_algorithmcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#signature_algorithm(57144064b5dd6aaa).(X509* cert)
274 {
275 auto nid = X509_get_signature_nid(cert);
276 switch (nid) {
277 case EVP_PKEY_ED25519cxx . . $ `<external>/2497497914425334111/evp.h:83:9`!:
278 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::Ed25519cxx . . $ mlspp/hpke/Signature#ID#Ed25519.;
279 #if !defined(WITH_BORINGSSL)
280 case EVP_PKEY_ED448cxx . . $ `<external>/2497497914425334111/evp.h:85:9`!:
281 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::Ed448cxx . . $ mlspp/hpke/Signature#ID#Ed448.;
282 #endif
283 case NID_ecdsa_with_SHA256cxx . . $ `<external>/18030087176251566933/obj_mac.h:314:9`!:
284 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P256_SHA256cxx . . $ mlspp/hpke/Signature#ID#P256_SHA256.;
285 case NID_ecdsa_with_SHA384cxx . . $ `<external>/18030087176251566933/obj_mac.h:318:9`!:
286 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P384_SHA384cxx . . $ mlspp/hpke/Signature#ID#P384_SHA384.;
287 case NID_ecdsa_with_SHA512cxx . . $ `<external>/18030087176251566933/obj_mac.h:322:9`!:
288 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P521_SHA512cxx . . $ mlspp/hpke/Signature#ID#P521_SHA512.;
289 case NID_sha1WithRSAEncryptioncxx . . $ `<external>/18030087176251566933/obj_mac.h:563:9`!:
290 // We fall through to SHA256 for SHA1 because we do not implement SHA-1.
291 case NID_sha256WithRSAEncryptioncxx . . $ `<external>/18030087176251566933/obj_mac.h:588:9`!:
292 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::RSA_SHA256cxx . . $ mlspp/hpke/Signature#ID#RSA_SHA256.;
293 case NID_sha384WithRSAEncryptioncxx . . $ `<external>/18030087176251566933/obj_mac.h:593:9`!:
294 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::RSA_SHA384cxx . . $ mlspp/hpke/Signature#ID#RSA_SHA384.;
295 case NID_sha512WithRSAEncryptioncxx . . $ `<external>/18030087176251566933/obj_mac.h:598:9`!:
296 return Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::RSA_SHA512cxx . . $ mlspp/hpke/Signature#ID#RSA_SHA512.;
297 default:
298 break;
299 }
300
301 throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#("Unsupported signature algorithm");
302 }
303
304 typed_unique_ptrcxx . . $ mlspp/hpke/typed_unique_ptr#<EVP_PKEY> public_keycxx . . $ mlspp/hpke/Certificate#ParsedCertificate#public_key(b65397426bec7d79).() const
305 {
306 return make_typed_uniquecxx . . $ mlspp/hpke/make_typed_unique(f611cc58871fbeab).<EVP_PKEY>(X509_get_pubkey(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()));
307 }
308
309 Certificatecxx . . $ mlspp/hpke/Certificate#::ExpirationStatuscxx . . $ mlspp/hpke/Certificate#ExpirationStatus# expiration_statuscxx . . $ mlspp/hpke/Certificate#ParsedCertificate#expiration_status(4d3e57c7ff1a39a).() const
310 {
311 auto now = stdcxx . . $ std/::chronocxx . . $ std/chrono/::system_clockcxx . . $ std/chrono/_V2/system_clock#::nowcxx . . $ std/chrono/_V2/system_clock#now(3657dacbd9b4f607).();
312
313 if (now <cxx . . $ std/chrono/`operator<`(b733d9f18a96a496). not_beforecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_before.) {
314 return Certificatecxx . . $ mlspp/hpke/Certificate#::ExpirationStatuscxx . . $ mlspp/hpke/Certificate#ExpirationStatus#::inactivecxx . . $ mlspp/hpke/Certificate#ExpirationStatus#inactive.;
315 }
316
317 if (now >cxx . . $ std/chrono/`operator>`(b733d9f18a96a496). not_aftercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_after.) {
318 return Certificatecxx . . $ mlspp/hpke/Certificate#::ExpirationStatuscxx . . $ mlspp/hpke/Certificate#ExpirationStatus#::expiredcxx . . $ mlspp/hpke/Certificate#ExpirationStatus#expired.;
319 }
320
321 return Certificatecxx . . $ mlspp/hpke/Certificate#::ExpirationStatuscxx . . $ mlspp/hpke/Certificate#ExpirationStatus#::activecxx . . $ mlspp/hpke/Certificate#ExpirationStatus#active.;
322 }
323
324 bytescxx . . $ mlspp/bytes_ns/bytes# rawcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#raw(d7392ba79aa35767).() const
325 {
326 auto out = bytescxx . . $ mlspp/bytes_ns/bytes#(i2d_X509(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).(), nullptr));
327 auto* ptr = out.datacxx . . $ mlspp/bytes_ns/bytes#data(37d8967d10cb1e7b).();
328 i2d_X509(x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).(), &ptr);
329 return outcxx . . $ mlspp/bytes_ns/bytes#bytes(628b76f52f2a67f).;
330 }
331
332 typed_unique_ptrcxx . . $ mlspp/hpke/typed_unique_ptr#<X509> x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509.;
333 const Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID# pub_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#pub_key_id.;
334 const Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID# sig_algocxx . . $ mlspp/hpke/Certificate#ParsedCertificate#sig_algo.;
335 const uint64_tcxx . . $ uint64_t# issuer_hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#issuer_hash.;
336 const uint64_tcxx . . $ uint64_t# subject_hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject_hash.;
337 const ParsedNamecxx . . $ mlspp/hpke/Certificate#ParsedName# issuercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#issuer.;
338 const ParsedNamecxx . . $ mlspp/hpke/Certificate#ParsedName# subjectcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject.;
339 const stdcxx . . $ std/::optionalcxx . . $ std/optional#<bytescxx . . $ mlspp/bytes_ns/bytes#> subject_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject_key_id.;
340 const stdcxx . . $ std/::optionalcxx . . $ std/optional#<bytescxx . . $ mlspp/bytes_ns/bytes#> authority_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#authority_key_id.;
341 const stdcxx . . $ std/::vectorcxx . . $ std/vector#<GeneralNamecxx . . $ mlspp/hpke/GeneralName#> sub_alt_namescxx . . $ mlspp/hpke/Certificate#ParsedCertificate#sub_alt_names.;
342 const bool is_cacxx . . $ mlspp/hpke/Certificate#ParsedCertificate#is_ca.;
343 const bytescxx . . $ mlspp/bytes_ns/bytes# hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#hash.;
344 const stdcxx . . $ std/::chronocxx . . $ std/chrono/::system_clockcxx . . $ std/chrono/_V2/system_clock#::time_pointcxx . . $ std/chrono/_V2/system_clock#time_point# not_beforecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_before.;
345 const stdcxx . . $ std/::chronocxx . . $ std/chrono/::system_clockcxx . . $ std/chrono/_V2/system_clock#::time_pointcxx . . $ std/chrono/_V2/system_clock#time_point# not_aftercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_after.;
346 };
347
348 ///
349 /// Certificate
350 ///
351
352 static stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Signaturecxx . . $ mlspp/hpke/Signature#::PublicKeycxx . . $ mlspp/hpke/Signature#PublicKey#>
353 signature_keycxx . . $ mlspp/hpke/signature_key(caff21eed11bdf0b).(EVP_PKEY* pkey)
354 {
355 switch (EVP_PKEY_base_idcxx . . $ `<external>/2497497914425334111/evp.h:1367:9`!(pkey)) {
356 case EVP_PKEY_RSAcxx . . $ `<external>/2497497914425334111/evp.h:63:9`!:
357 return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<RSASignaturecxx . . $ mlspp/hpke/RSASignature#::PublicKeycxx . . $ mlspp/hpke/RSASignature#PublicKey#>(pkey);
358
359 case EVP_PKEY_ED448cxx . . $ `<external>/2497497914425334111/evp.h:85:9`!:
360 case EVP_PKEY_ED25519cxx . . $ `<external>/2497497914425334111/evp.h:83:9`!:
361 case EVP_PKEY_ECcxx . . $ `<external>/2497497914425334111/evp.h:73:9`!:
362 return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<EVPGroupcxx . . $ mlspp/hpke/EVPGroup#::PublicKeycxx . . $ mlspp/hpke/EVPGroup#PublicKey#>(pkey);
363
364 default:
365 throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#("Unsupported algorithm");
366 }
367 }
368
369 Certificatecxx . . $ mlspp/hpke/Certificate#::Certificatecxx . . $ mlspp/hpke/Certificate#Certificate(ca28ddfc6963e92c).(stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ParsedCertificatecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#>&& parsed_cert_in)
370 : parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(parsed_cert_in))
371 , public_keycxx . . $ mlspp/hpke/Certificate#public_key.(signature_keycxx . . $ mlspp/hpke/signature_key(caff21eed11bdf0b).(parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).public_keycxx . . $ mlspp/hpke/Certificate#ParsedCertificate#public_key(b65397426bec7d79).().releasecxx . . $ std/unique_ptr#release(aad4c3669c5e940c).()))
372 , rawcxx . . $ mlspp/hpke/Certificate#raw.(parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).rawcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#raw(d7392ba79aa35767).())
373 {
374 }
375
376 Certificatecxx . . $ mlspp/hpke/Certificate#::Certificatecxx . . $ mlspp/hpke/Certificate#Certificate(68ca607eebb5be3e).(const bytescxx . . $ mlspp/bytes_ns/bytes#& der)
377 : parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.(ParsedCertificatecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#::parsecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#parse(3a6228dc0f4dd58a).(der))
378 , public_keycxx . . $ mlspp/hpke/Certificate#public_key.(signature_keycxx . . $ mlspp/hpke/signature_key(caff21eed11bdf0b).(parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).public_keycxx . . $ mlspp/hpke/Certificate#ParsedCertificate#public_key(b65397426bec7d79).().releasecxx . . $ std/unique_ptr#release(aad4c3669c5e940c).()))
379 , rawcxx . . $ mlspp/hpke/Certificate#raw.(der)
380 {
381 }
382
383 Certificatecxx . . $ mlspp/hpke/Certificate#::Certificatecxx . . $ mlspp/hpke/Certificate#Certificate(aa5f6ab2c253cfe).(const Certificatecxx . . $ mlspp/hpke/Certificate#& other)
384 : parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.(stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ParsedCertificatecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#>(*cxx . . $ std/unique_ptr#`operator*`(26c95836c1e8ca05).other.parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.))
385 , public_keycxx . . $ mlspp/hpke/Certificate#public_key.(signature_keycxx . . $ mlspp/hpke/signature_key(caff21eed11bdf0b).(parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).public_keycxx . . $ mlspp/hpke/Certificate#ParsedCertificate#public_key(b65397426bec7d79).().releasecxx . . $ std/unique_ptr#release(aad4c3669c5e940c).()))
386 , rawcxx . . $ mlspp/hpke/Certificate#raw.(other.rawcxx . . $ mlspp/hpke/Certificate#raw.)
387 {
388 }
389
390 Certificatecxx . . $ mlspp/hpke/Certificate#::~cxx . . $ mlspp/hpke/Certificate#`~Certificate`(ced63f7c635d850d).Certificatecxx . . $ mlspp/hpke/Certificate#() = default;
391
392 stdcxx . . $ std/::vectorcxx . . $ std/vector#<Certificatecxx . . $ mlspp/hpke/Certificate#>
393 Certificatecxx . . $ mlspp/hpke/Certificate#::parse_pemcxx . . $ mlspp/hpke/Certificate#parse_pem(abc66be3d6704f5d).(const bytescxx . . $ mlspp/bytes_ns/bytes#& pem)
394 {
395 auto size_int = static_cast<int>(pem.sizecxx . . $ mlspp/bytes_ns/bytes#size(fe4d2d262d4164a8).());
396 auto bio = make_typed_uniquecxx . . $ mlspp/hpke/make_typed_unique(f611cc58871fbeab).<BIO>(BIO_new_mem_buf(pem.datacxx . . $ mlspp/bytes_ns/bytes#data(7eb257f306f79f97).(), size_int));
397 if (!bio) {
398 throw openssl_errorcxx . . $ mlspp/hpke/openssl_error(d6ab8afd00dfc651).();
399 }
400
401 auto certs = stdcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).::vectorcxx . . $ std/vector#<Certificatecxx . . $ mlspp/hpke/Certificate#>();
402 while (true) {
403 auto x509 = make_typed_uniquecxx . . $ mlspp/hpke/make_typed_unique(f611cc58871fbeab).<X509>(
404 PEM_read_bio_X509(bio.getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).(), nullptr, nullptr, nullptr));
405 if (!x509) {
406 // NOLINTNEXTLINE(hicpp-signed-bitwise)
407 auto err = ERR_GET_REASON(ERR_peek_last_error());
408 if (err == PEM_R_NO_START_LINEcxx . . $ `<external>/4786226268131619264/pemerr.h:44:9`!) {
409 // No more objects to read
410 break;
411 }
412
413 throw openssl_errorcxx . . $ mlspp/hpke/openssl_error(d6ab8afd00dfc651).();
414 }
415
416 auto parsed = stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ParsedCertificatecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#>(x509.releasecxx . . $ std/unique_ptr#release(aad4c3669c5e940c).());
417 certs.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(parsed));
418 }
419
420 return certscxx . . $ std/vector#vector(6f559d22b039ccdb).;
421 }
422
423 bool
424 Certificatecxx . . $ mlspp/hpke/Certificate#::valid_fromcxx . . $ mlspp/hpke/Certificate#valid_from(f27b537b6bc2a77e).(const Certificatecxx . . $ mlspp/hpke/Certificate#& parent) const
425 {
426 auto pub = parent.parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).public_keycxx . . $ mlspp/hpke/Certificate#ParsedCertificate#public_key(b65397426bec7d79).();
427 return (1 == X509_verify(parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).x509cxx . . $ mlspp/hpke/Certificate#ParsedCertificate#x509..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).(), pub.getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()));
428 }
429
430 uint64_tcxx . . $ uint64_t#
431 Certificatecxx . . $ mlspp/hpke/Certificate#::issuer_hashcxx . . $ mlspp/hpke/Certificate#issuer_hash(fe4d2d262d4164a8).() const
432 {
433 return parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).issuer_hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#issuer_hash.;
434 }
435
436 uint64_tcxx . . $ uint64_t#
437 Certificatecxx . . $ mlspp/hpke/Certificate#::subject_hashcxx . . $ mlspp/hpke/Certificate#subject_hash(fe4d2d262d4164a8).() const
438 {
439 return parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).subject_hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject_hash.;
440 }
441
442 Certificatecxx . . $ mlspp/hpke/Certificate#::ParsedNamecxx . . $ mlspp/hpke/Certificate#ParsedName#
443 Certificatecxx . . $ mlspp/hpke/Certificate#::subjectcxx . . $ mlspp/hpke/Certificate#subject(2975e2891c946501).() const
444 {
445 return parsed_certcxx . . $ std/map#map(46e52724c94dff27).->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).subjectcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject.;
446 }
447
448 Certificatecxx . . $ mlspp/hpke/Certificate#::ParsedNamecxx . . $ mlspp/hpke/Certificate#ParsedName#
449 Certificatecxx . . $ mlspp/hpke/Certificate#::issuercxx . . $ mlspp/hpke/Certificate#issuer(2975e2891c946501).() const
450 {
451 return parsed_certcxx . . $ std/map#map(46e52724c94dff27).->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).issuercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#issuer.;
452 }
453
454 bool
455 Certificatecxx . . $ mlspp/hpke/Certificate#::is_cacxx . . $ mlspp/hpke/Certificate#is_ca(50ce9a9e25b4a850).() const
456 {
457 return parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).is_cacxx . . $ mlspp/hpke/Certificate#ParsedCertificate#is_ca.;
458 }
459
460 Certificatecxx . . $ mlspp/hpke/Certificate#::ExpirationStatuscxx . . $ mlspp/hpke/Certificate#ExpirationStatus#
461 Certificatecxx . . $ mlspp/hpke/Certificate#::expiration_statuscxx . . $ mlspp/hpke/Certificate#expiration_status(4d3e57c7ff1a39a).() const
462 {
463 return parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).expiration_statuscxx . . $ mlspp/hpke/Certificate#ParsedCertificate#expiration_status(4d3e57c7ff1a39a).();
464 }
465
466 stdcxx . . $ std/::optionalcxx . . $ std/optional#<bytescxx . . $ mlspp/bytes_ns/bytes#>
467 Certificatecxx . . $ mlspp/hpke/Certificate#::subject_key_idcxx . . $ mlspp/hpke/Certificate#subject_key_id(82a679487d1deb04).() const
468 {
469 return parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).subject_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#subject_key_id.;
470 }
471
472 stdcxx . . $ std/::optionalcxx . . $ std/optional#<bytescxx . . $ mlspp/bytes_ns/bytes#>
473 Certificatecxx . . $ mlspp/hpke/Certificate#::authority_key_idcxx . . $ mlspp/hpke/Certificate#authority_key_id(82a679487d1deb04).() const
474 {
475 return parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).authority_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#authority_key_id.;
476 }
477
478 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>
479 Certificatecxx . . $ mlspp/hpke/Certificate#::email_addressescxx . . $ mlspp/hpke/Certificate#email_addresses(491c255a7e496038).() const
480 {
481 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> emailscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
482 for (const auto& name : parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).sub_alt_namescxx . . $ mlspp/hpke/Certificate#ParsedCertificate#sub_alt_names.) {
483 if (tlscxx . . $ mlspp/tls/::var::holds_alternativecxx . . $ std/holds_alternative(4d382a1a2d74a3ce).<RFC822Namecxx . . $ mlspp/hpke/RFC822Name#>(name)) {
484 emails.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(tlscxx . . $ mlspp/tls/::var::getcxx . . $ std/get(ca5bafa5a3bcea9d).<RFC822Namecxx . . $ mlspp/hpke/RFC822Name#>(name).valuecxx . . $ mlspp/hpke/RFC822Name#value.);
485 }
486 }
487 return emailscxx . . $ std/vector#vector(6f559d22b039ccdb).;
488 }
489
490 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>
491 Certificatecxx . . $ mlspp/hpke/Certificate#::dns_namescxx . . $ mlspp/hpke/Certificate#dns_names(491c255a7e496038).() const
492 {
493 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> domainscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
494 for (const auto& name : parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).sub_alt_namescxx . . $ mlspp/hpke/Certificate#ParsedCertificate#sub_alt_names.) {
495 if (tlscxx . . $ mlspp/tls/::var::holds_alternativecxx . . $ std/holds_alternative(4d382a1a2d74a3ce).<DNSNamecxx . . $ mlspp/hpke/DNSName#>(name)) {
496 domains.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(tlscxx . . $ mlspp/tls/::var::getcxx . . $ std/get(ca5bafa5a3bcea9d).<DNSNamecxx . . $ mlspp/hpke/DNSName#>(name).valuecxx . . $ mlspp/hpke/DNSName#value.);
497 }
498 }
499
500 return domainscxx . . $ std/vector#vector(6f559d22b039ccdb).;
501 }
502
503 bytescxx . . $ mlspp/bytes_ns/bytes#
504 Certificatecxx . . $ mlspp/hpke/Certificate#::hashcxx . . $ mlspp/hpke/Certificate#hash(d7392ba79aa35767).() const
505 {
506 return parsed_certcxx . . $ mlspp/bytes_ns/bytes#bytes(68ca607eebb5be3e).->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).hashcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#hash.;
507 }
508
509 stdcxx . . $ std/::chronocxx . . $ std/chrono/::system_clockcxx . . $ std/chrono/_V2/system_clock#::time_pointcxx . . $ std/chrono/_V2/system_clock#time_point#
510 Certificatecxx . . $ mlspp/hpke/Certificate#::not_beforecxx . . $ mlspp/hpke/Certificate#not_before(f0cd7e640ad675c3).() const
511 {
512 return parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).not_beforecxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_before.;
513 }
514
515 stdcxx . . $ std/::chronocxx . . $ std/chrono/::system_clockcxx . . $ std/chrono/_V2/system_clock#::time_pointcxx . . $ std/chrono/_V2/system_clock#time_point#
516 Certificatecxx . . $ mlspp/hpke/Certificate#::not_aftercxx . . $ mlspp/hpke/Certificate#not_after(f0cd7e640ad675c3).() const
517 {
518 return parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).not_aftercxx . . $ mlspp/hpke/Certificate#ParsedCertificate#not_after.;
519 }
520
521 Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#
522 Certificatecxx . . $ mlspp/hpke/Certificate#::public_key_algorithmcxx . . $ mlspp/hpke/Certificate#public_key_algorithm(b408284008ef55c).() const
523 {
524 return parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).pub_key_idcxx . . $ mlspp/hpke/Certificate#ParsedCertificate#pub_key_id.;
525 }
526
527 Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#
528 Certificatecxx . . $ mlspp/hpke/Certificate#::signature_algorithmcxx . . $ mlspp/hpke/Certificate#signature_algorithm(b408284008ef55c).() const
529 {
530 return parsed_certcxx . . $ mlspp/hpke/Certificate#parsed_cert.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).sig_algocxx . . $ mlspp/hpke/Certificate#ParsedCertificate#sig_algo.;
531 }
532
533 bool
534 operatorcxx . . $ mlspp/hpke/`operator==`(8350b7663eb3a8bd).==(const Certificatecxx . . $ mlspp/hpke/Certificate#& lhs, const Certificatecxx . . $ mlspp/hpke/Certificate#& rhs)
535 {
536 return lhs.rawcxx . . $ mlspp/hpke/Certificate#raw. ==cxx . . $ mlspp/bytes_ns/bytes#`operator==`(efd4f3c976ab92ce). rhs.rawcxx . . $ mlspp/hpke/Certificate#raw.;
537 }
538
539 } // namespace mlspp::hpke