1 | /** @file
|
---|
2 | * IPRT - Crypto - X.509, Public Key and Privilege Management Infrastructure.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2014-2020 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef IPRT_INCLUDED_crypto_x509_h
|
---|
27 | #define IPRT_INCLUDED_crypto_x509_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include <iprt/asn1.h>
|
---|
33 | #include <iprt/crypto/pem.h>
|
---|
34 |
|
---|
35 |
|
---|
36 | RT_C_DECLS_BEGIN
|
---|
37 |
|
---|
38 | struct RTCRPKCS7SETOFCERTS;
|
---|
39 |
|
---|
40 |
|
---|
41 | /** @defgroup grp_rt_crypto Crypto
|
---|
42 | * @ingroup grp_rt
|
---|
43 | * @{
|
---|
44 | */
|
---|
45 |
|
---|
46 | /** @defgroup grp_rt_crx509 RTCrX509 - Public Key and Privilege Management Infrastructure.
|
---|
47 | * @{
|
---|
48 | */
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * X.509 algorithm identifier (IPRT representation).
|
---|
52 | */
|
---|
53 | typedef struct RTCRX509ALGORITHMIDENTIFIER
|
---|
54 | {
|
---|
55 | /** The sequence making up this algorithm identifier. */
|
---|
56 | RTASN1SEQUENCECORE SeqCore;
|
---|
57 | /** The algorithm object ID. */
|
---|
58 | RTASN1OBJID Algorithm;
|
---|
59 | /** Optional parameters specified by the algorithm. */
|
---|
60 | RTASN1DYNTYPE Parameters;
|
---|
61 | } RTCRX509ALGORITHMIDENTIFIER;
|
---|
62 | /** Poitner to the IPRT representation of a X.509 algorithm identifier. */
|
---|
63 | typedef RTCRX509ALGORITHMIDENTIFIER *PRTCRX509ALGORITHMIDENTIFIER;
|
---|
64 | /** Poitner to the const IPRT representation of a X.509 algorithm identifier. */
|
---|
65 | typedef RTCRX509ALGORITHMIDENTIFIER const *PCRTCRX509ALGORITHMIDENTIFIER;
|
---|
66 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509ALGORITHMIDENTIFIER, RTDECL, RTCrX509AlgorithmIdentifier, SeqCore.Asn1Core);
|
---|
67 | RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTCRX509ALGORITHMIDENTIFIERS, RTCRX509ALGORITHMIDENTIFIER, RTDECL, RTCrX509AlgorithmIdentifiers);
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Tries to convert an X.509 digest algorithm ID into a RTDIGESTTYPE value.
|
---|
71 | *
|
---|
72 | * @returns Valid RTDIGESTTYPE on success, RTDIGESTTYPE_INVALID on failure.
|
---|
73 | * @param pThis The IPRT representation of a X.509 algorithm
|
---|
74 | * identifier object.
|
---|
75 | */
|
---|
76 | RTDECL(RTDIGESTTYPE) RTCrX509AlgorithmIdentifier_QueryDigestType(PCRTCRX509ALGORITHMIDENTIFIER pThis);
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Tries to figure the digest size of an X.509 digest algorithm ID.
|
---|
80 | *
|
---|
81 | * @returns The digest size in bytes, UINT32_MAX if unknown digest.
|
---|
82 | * @param pThis The IPRT representation of a X.509 algorithm
|
---|
83 | * identifier object.
|
---|
84 | */
|
---|
85 | RTDECL(uint32_t) RTCrX509AlgorithmIdentifier_QueryDigestSize(PCRTCRX509ALGORITHMIDENTIFIER pThis);
|
---|
86 |
|
---|
87 | RTDECL(int) RTCrX509AlgorithmIdentifier_CompareWithString(PCRTCRX509ALGORITHMIDENTIFIER pThis, const char *pszObjId);
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Compares a digest with an encrypted digest algorithm, checking if they
|
---|
91 | * specify the same digest.
|
---|
92 | *
|
---|
93 | * @returns 0 if same digest, -1 if the digest is unknown, 1 if the encrypted
|
---|
94 | * digest does not match.
|
---|
95 | * @param pDigest The digest algorithm.
|
---|
96 | * @param pEncryptedDigest The encrypted digest algorithm.
|
---|
97 | */
|
---|
98 | RTDECL(int) RTCrX509AlgorithmIdentifier_CompareDigestAndEncryptedDigest(PCRTCRX509ALGORITHMIDENTIFIER pDigest,
|
---|
99 | PCRTCRX509ALGORITHMIDENTIFIER pEncryptedDigest);
|
---|
100 | /**
|
---|
101 | * Compares a digest OID with an encrypted digest algorithm OID, checking if
|
---|
102 | * they specify the same digest.
|
---|
103 | *
|
---|
104 | * @returns 0 if same digest, -1 if the digest is unknown, 1 if the encrypted
|
---|
105 | * digest does not match.
|
---|
106 | * @param pszDigestOid The digest algorithm OID.
|
---|
107 | * @param pszEncryptedDigestOid The encrypted digest algorithm OID.
|
---|
108 | */
|
---|
109 | RTDECL(int) RTCrX509AlgorithmIdentifier_CompareDigestOidAndEncryptedDigestOid(const char *pszDigestOid,
|
---|
110 | const char *pszEncryptedDigestOid);
|
---|
111 |
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Combine the encryption algorithm with the digest algorithm.
|
---|
115 | *
|
---|
116 | * @returns OID of encrypted digest algorithm.
|
---|
117 | * @param pEncryption The encryption algorithm. Will work if this is
|
---|
118 | * the OID of an encrypted digest algorithm too, as
|
---|
119 | * long as it matches @a pDigest.
|
---|
120 | * @param pDigest The digest algorithm. Will work if this is the
|
---|
121 | * OID of an encrypted digest algorithm too, as
|
---|
122 | * long as it matches @a pEncryption.
|
---|
123 | */
|
---|
124 | RTDECL(const char *) RTCrX509AlgorithmIdentifier_CombineEncryptionAndDigest(PCRTCRX509ALGORITHMIDENTIFIER pEncryption,
|
---|
125 | PCRTCRX509ALGORITHMIDENTIFIER pDigest);
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * Combine the encryption algorithm OID with the digest algorithm OID.
|
---|
129 | *
|
---|
130 | * @returns OID of encrypted digest algorithm.
|
---|
131 | * @param pszEncryptionOid The encryption algorithm. Will work if this is
|
---|
132 | * the OID of an encrypted digest algorithm too, as
|
---|
133 | * long as it matches @a pszDigestOid.
|
---|
134 | * @param pszDigestOid The digest algorithm. Will work if this is the
|
---|
135 | * OID of an encrypted digest algorithm too, as
|
---|
136 | * long as it matches @a pszEncryptionOid.
|
---|
137 | */
|
---|
138 | RTDECL(const char *) RTCrX509AlgorithmIdentifier_CombineEncryptionOidAndDigestOid(const char *pszEncryptionOid,
|
---|
139 | const char *pszDigestOid);
|
---|
140 |
|
---|
141 |
|
---|
142 | /** @name Typical Digest Algorithm OIDs.
|
---|
143 | * @{ */
|
---|
144 | #define RTCRX509ALGORITHMIDENTIFIERID_MD2 "1.2.840.113549.2.2"
|
---|
145 | #define RTCRX509ALGORITHMIDENTIFIERID_MD4 "1.2.840.113549.2.4"
|
---|
146 | #define RTCRX509ALGORITHMIDENTIFIERID_MD5 "1.2.840.113549.2.5"
|
---|
147 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA1 "1.3.14.3.2.26"
|
---|
148 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA256 "2.16.840.1.101.3.4.2.1"
|
---|
149 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA384 "2.16.840.1.101.3.4.2.2"
|
---|
150 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA512 "2.16.840.1.101.3.4.2.3"
|
---|
151 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA224 "2.16.840.1.101.3.4.2.4"
|
---|
152 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA512T224 "2.16.840.1.101.3.4.2.5"
|
---|
153 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA512T256 "2.16.840.1.101.3.4.2.6"
|
---|
154 | #define RTCRX509ALGORITHMIDENTIFIERID_WHIRLPOOL "1.0.10118.3.0.55"
|
---|
155 | /** @} */
|
---|
156 |
|
---|
157 | /** @name Encrypted Digest Algorithm OIDs.
|
---|
158 | * @remarks The PKCS variants are the default ones, alternative OID are marked
|
---|
159 | * as such.
|
---|
160 | * @{ */
|
---|
161 | #define RTCRX509ALGORITHMIDENTIFIERID_RSA "1.2.840.113549.1.1.1"
|
---|
162 | #define RTCRX509ALGORITHMIDENTIFIERID_MD2_WITH_RSA "1.2.840.113549.1.1.2"
|
---|
163 | #define RTCRX509ALGORITHMIDENTIFIERID_MD4_WITH_RSA "1.2.840.113549.1.1.3"
|
---|
164 | #define RTCRX509ALGORITHMIDENTIFIERID_MD5_WITH_RSA "1.2.840.113549.1.1.4"
|
---|
165 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA1_WITH_RSA "1.2.840.113549.1.1.5"
|
---|
166 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA256_WITH_RSA "1.2.840.113549.1.1.11"
|
---|
167 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA384_WITH_RSA "1.2.840.113549.1.1.12"
|
---|
168 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA512_WITH_RSA "1.2.840.113549.1.1.13"
|
---|
169 | #define RTCRX509ALGORITHMIDENTIFIERID_SHA224_WITH_RSA "1.2.840.113549.1.1.14"
|
---|
170 | /** @} */
|
---|
171 |
|
---|
172 |
|
---|
173 |
|
---|
174 |
|
---|
175 | /**
|
---|
176 | * One X.509 AttributeTypeAndValue (IPRT representation).
|
---|
177 | */
|
---|
178 | typedef struct RTCRX509ATTRIBUTETYPEANDVALUE
|
---|
179 | {
|
---|
180 | /** Sequence core. */
|
---|
181 | RTASN1SEQUENCECORE SeqCore;
|
---|
182 | /** The attribute type (object ID). */
|
---|
183 | RTASN1OBJID Type;
|
---|
184 | /** The attribute value (what it is is defined by Type). */
|
---|
185 | RTASN1DYNTYPE Value;
|
---|
186 | } RTCRX509ATTRIBUTETYPEANDVALUE;
|
---|
187 | /** Pointer to a X.509 AttributeTypeAndValue (IPRT representation). */
|
---|
188 | typedef RTCRX509ATTRIBUTETYPEANDVALUE *PRTCRX509ATTRIBUTETYPEANDVALUE;
|
---|
189 | /** Pointer to a const X.509 AttributeTypeAndValue (IPRT representation). */
|
---|
190 | typedef RTCRX509ATTRIBUTETYPEANDVALUE const *PCRTCRX509ATTRIBUTETYPEANDVALUE;
|
---|
191 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509ATTRIBUTETYPEANDVALUE, RTDECL, RTCrX509AttributeTypeAndValue, SeqCore.Asn1Core);
|
---|
192 | RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTCRX509ATTRIBUTETYPEANDVALUES, RTCRX509ATTRIBUTETYPEANDVALUE, RTDECL, RTCrX509AttributeTypeAndValues);
|
---|
193 |
|
---|
194 | RTASN1TYPE_ALIAS(RTCRX509RELATIVEDISTINGUISHEDNAME, RTCRX509ATTRIBUTETYPEANDVALUES, RTCrX509RelativeDistinguishedName, RTCrX509AttributeTypeAndValues);
|
---|
195 |
|
---|
196 |
|
---|
197 | RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTCRX509NAME, RTCRX509RELATIVEDISTINGUISHEDNAME, RTDECL, RTCrX509Name);
|
---|
198 | RTDECL(int) RTCrX509Name_CheckSanity(PCRTCRX509NAME pName, uint32_t fFlags, PRTERRINFO pErrInfo, const char *pszErrorTag);
|
---|
199 | RTDECL(bool) RTCrX509Name_MatchByRfc5280(PCRTCRX509NAME pLeft, PCRTCRX509NAME pRight);
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Name constraint matching (RFC-5280).
|
---|
203 | *
|
---|
204 | * @returns true on match, false on mismatch.
|
---|
205 | * @param pConstraint The constraint name.
|
---|
206 | * @param pName The name to match against the constraint.
|
---|
207 | * @sa RTCrX509GeneralName_ConstraintMatch,
|
---|
208 | * RTCrX509RelativeDistinguishedName_ConstraintMatch
|
---|
209 | */
|
---|
210 | RTDECL(bool) RTCrX509Name_ConstraintMatch(PCRTCRX509NAME pConstraint, PCRTCRX509NAME pName);
|
---|
211 | RTDECL(int) RTCrX509Name_RecodeAsUtf8(PRTCRX509NAME pThis, PCRTASN1ALLOCATORVTABLE pAllocator);
|
---|
212 |
|
---|
213 | /**
|
---|
214 | * Matches the directory name against a comma separated list of the component
|
---|
215 | * strings (case sensitive).
|
---|
216 | *
|
---|
217 | * @returns true if match, false if mismatch.
|
---|
218 | * @param pThis The name object.
|
---|
219 | * @param pszString The string to match against. For example:
|
---|
220 | * "C=US, ST=California, L=Redwood Shores, O=Oracle Corporation"
|
---|
221 | *
|
---|
222 | * @remarks This is doing a straight compare, no extra effort is expended in
|
---|
223 | * dealing with different component order. If the component order
|
---|
224 | * differs, there won't be any match.
|
---|
225 | */
|
---|
226 | RTDECL(bool) RTCrX509Name_MatchWithString(PCRTCRX509NAME pThis, const char *pszString);
|
---|
227 |
|
---|
228 | /**
|
---|
229 | * Formats the name as a command separated list of components with type
|
---|
230 | * prefixes.
|
---|
231 | *
|
---|
232 | * The output of this function is suitable for use with
|
---|
233 | * RTCrX509Name_MatchWithString.
|
---|
234 | *
|
---|
235 | * @returns IPRT status code.
|
---|
236 | * @param pThis The name object.
|
---|
237 | * @param pszBuf The output buffer.
|
---|
238 | * @param cbBuf The size of the output buffer.
|
---|
239 | * @param pcbActual Where to return the number of bytes required for the
|
---|
240 | * output, including the null terminator character.
|
---|
241 | * Optional.
|
---|
242 | */
|
---|
243 | RTDECL(int) RTCrX509Name_FormatAsString(PCRTCRX509NAME pThis, char *pszBuf, size_t cbBuf, size_t *pcbActual);
|
---|
244 |
|
---|
245 |
|
---|
246 | /**
|
---|
247 | * Looks up the RDN ID and returns the short name for it, if found.
|
---|
248 | *
|
---|
249 | * @returns Short name (e.g. 'CN') or NULL.
|
---|
250 | * @param pRdnId The RDN ID to look up.
|
---|
251 | */
|
---|
252 | RTDECL(const char *) RTCrX509Name_GetShortRdn(PCRTASN1OBJID pRdnId);
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * One X.509 OtherName (IPRT representation).
|
---|
256 | */
|
---|
257 | typedef struct RTCRX509OTHERNAME
|
---|
258 | {
|
---|
259 | /** The sequence core. */
|
---|
260 | RTASN1SEQUENCECORE SeqCore;
|
---|
261 | /** The name type identifier. */
|
---|
262 | RTASN1OBJID TypeId;
|
---|
263 | /** The name value (explicit tag 0). */
|
---|
264 | RTASN1DYNTYPE Value;
|
---|
265 | } RTCRX509OTHERNAME;
|
---|
266 | /** Pointer to a X.509 OtherName (IPRT representation). */
|
---|
267 | typedef RTCRX509OTHERNAME *PRTCRX509OTHERNAME;
|
---|
268 | /** Pointer to a const X.509 OtherName (IPRT representation). */
|
---|
269 | typedef RTCRX509OTHERNAME const *PCRTCRX509OTHERNAME;
|
---|
270 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509OTHERNAME, RTDECL, RTCrX509OtherName, SeqCore.Asn1Core);
|
---|
271 |
|
---|
272 |
|
---|
273 | typedef enum RTCRX509GENERALNAMECHOICE
|
---|
274 | {
|
---|
275 | RTCRX509GENERALNAMECHOICE_INVALID = 0,
|
---|
276 | RTCRX509GENERALNAMECHOICE_OTHER_NAME,
|
---|
277 | RTCRX509GENERALNAMECHOICE_RFC822_NAME,
|
---|
278 | RTCRX509GENERALNAMECHOICE_DNS_NAME,
|
---|
279 | RTCRX509GENERALNAMECHOICE_X400_ADDRESS,
|
---|
280 | RTCRX509GENERALNAMECHOICE_DIRECTORY_NAME,
|
---|
281 | RTCRX509GENERALNAMECHOICE_EDI_PARTY_NAME,
|
---|
282 | RTCRX509GENERALNAMECHOICE_URI,
|
---|
283 | RTCRX509GENERALNAMECHOICE_IP_ADDRESS,
|
---|
284 | RTCRX509GENERALNAMECHOICE_REGISTERED_ID,
|
---|
285 | RTCRX509GENERALNAMECHOICE_END,
|
---|
286 | RTCRX509GENERALNAMECHOICE_32BIT_HACK = 0x7fffffff
|
---|
287 | } RTCRX509GENERALNAMECHOICE;
|
---|
288 |
|
---|
289 | /**
|
---|
290 | * One X.509 GeneralName (IPRT representation).
|
---|
291 | *
|
---|
292 | * This is represented as a union. Use the RTCRX509GENERALNAME_IS_XXX predicate
|
---|
293 | * macros to figure out which member is valid (Asn1Core is always valid).
|
---|
294 | */
|
---|
295 | typedef struct RTCRX509GENERALNAME
|
---|
296 | {
|
---|
297 | /** Dummy ASN.1 record, not encoded. */
|
---|
298 | RTASN1DUMMY Dummy;
|
---|
299 | /** The value allocation. */
|
---|
300 | RTASN1ALLOCATION Allocation;
|
---|
301 | /** The choice of value. */
|
---|
302 | RTCRX509GENERALNAMECHOICE enmChoice;
|
---|
303 | /** The value union. */
|
---|
304 | union
|
---|
305 | {
|
---|
306 | /** Tag 0: Other Name. */
|
---|
307 | PRTCRX509OTHERNAME pT0_OtherName;
|
---|
308 | /** Tag 1: RFC-822 Name. */
|
---|
309 | PRTASN1STRING pT1_Rfc822;
|
---|
310 | /** Tag 2: DNS name. */
|
---|
311 | PRTASN1STRING pT2_DnsName;
|
---|
312 | /** Tag 3: X.400 Address. */
|
---|
313 | struct
|
---|
314 | {
|
---|
315 | /** Context tag 3. */
|
---|
316 | RTASN1CONTEXTTAG3 CtxTag3;
|
---|
317 | /** Later. */
|
---|
318 | RTASN1DYNTYPE X400Address;
|
---|
319 | } *pT3;
|
---|
320 | /** Tag 4: Directory Name. */
|
---|
321 | struct
|
---|
322 | {
|
---|
323 | /** Context tag 4. */
|
---|
324 | RTASN1CONTEXTTAG4 CtxTag4;
|
---|
325 | /** Directory name. */
|
---|
326 | RTCRX509NAME DirectoryName;
|
---|
327 | } *pT4;
|
---|
328 | /** Tag 5: EDI Party Name. */
|
---|
329 | struct
|
---|
330 | {
|
---|
331 | /** Context tag 5. */
|
---|
332 | RTASN1CONTEXTTAG5 CtxTag5;
|
---|
333 | /** Later. */
|
---|
334 | RTASN1DYNTYPE EdiPartyName;
|
---|
335 | } *pT5;
|
---|
336 | /** Tag 6: URI. */
|
---|
337 | PRTASN1STRING pT6_Uri;
|
---|
338 | /** Tag 7: IP address. Either 4/8 (IPv4) or 16/32 (IPv16) octets long. */
|
---|
339 | PRTASN1OCTETSTRING pT7_IpAddress;
|
---|
340 | /** Tag 8: Registered ID. */
|
---|
341 | PRTASN1OBJID pT8_RegisteredId;
|
---|
342 | } u;
|
---|
343 | } RTCRX509GENERALNAME;
|
---|
344 | /** Pointer to the IPRT representation of an X.509 general name. */
|
---|
345 | typedef RTCRX509GENERALNAME *PRTCRX509GENERALNAME;
|
---|
346 | /** Pointer to the const IPRT representation of an X.509 general name. */
|
---|
347 | typedef RTCRX509GENERALNAME const *PCRTCRX509GENERALNAME;
|
---|
348 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509GENERALNAME, RTDECL, RTCrX509GeneralName, Dummy.Asn1Core);
|
---|
349 |
|
---|
350 | /** @name RTCRX509GENERALNAME tag predicates.
|
---|
351 | * @{ */
|
---|
352 | #define RTCRX509GENERALNAME_IS_OTHER_NAME(a_GenName) ((a_GenName)->enmChoice == RTCRX509GENERALNAMECHOICE_OTHER_NAME)
|
---|
353 | #define RTCRX509GENERALNAME_IS_RFC822_NAME(a_GenName) ((a_GenName)->enmChoice == RTCRX509GENERALNAMECHOICE_RFC822_NAME)
|
---|
354 | #define RTCRX509GENERALNAME_IS_DNS_NAME(a_GenName) ((a_GenName)->enmChoice == RTCRX509GENERALNAMECHOICE_DNS_NAME)
|
---|
355 | #define RTCRX509GENERALNAME_IS_X400_ADDRESS(a_GenName) ((a_GenName)->enmChoice == RTCRX509GENERALNAMECHOICE_X400_ADDRESS)
|
---|
356 | #define RTCRX509GENERALNAME_IS_DIRECTORY_NAME(a_GenName) ((a_GenName)->enmChoice == RTCRX509GENERALNAMECHOICE_DIRECTORY_NAME)
|
---|
357 | #define RTCRX509GENERALNAME_IS_EDI_PARTY_NAME(a_GenName) ((a_GenName)->enmChoice == RTCRX509GENERALNAMECHOICE_EDI_PARTY_NAME)
|
---|
358 | #define RTCRX509GENERALNAME_IS_URI(a_GenName) ((a_GenName)->enmChoice == RTCRX509GENERALNAMECHOICE_URI)
|
---|
359 | #define RTCRX509GENERALNAME_IS_IP_ADDRESS(a_GenName) ((a_GenName)->enmChoice == RTCRX509GENERALNAMECHOICE_IP_ADDRESS)
|
---|
360 | #define RTCRX509GENERALNAME_IS_REGISTERED_ID(a_GenName) ((a_GenName)->enmChoice == RTCRX509GENERALNAMECHOICE_REGISTERED_ID)
|
---|
361 | /** @} */
|
---|
362 |
|
---|
363 |
|
---|
364 | RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTCRX509GENERALNAMES, RTCRX509GENERALNAME, RTDECL, RTCrX509GeneralNames);
|
---|
365 | RTDECL(bool) RTCrX509GeneralName_ConstraintMatch(PCRTCRX509GENERALNAME pConstraint, PCRTCRX509GENERALNAME pName);
|
---|
366 |
|
---|
367 |
|
---|
368 | /**
|
---|
369 | * X.509 Validity (IPRT representation).
|
---|
370 | */
|
---|
371 | typedef struct RTCRX509VALIDITY
|
---|
372 | {
|
---|
373 | /** Core sequence bits. */
|
---|
374 | RTASN1SEQUENCECORE SeqCore;
|
---|
375 | /** Effective starting. */
|
---|
376 | RTASN1TIME NotBefore;
|
---|
377 | /** Expires after. */
|
---|
378 | RTASN1TIME NotAfter;
|
---|
379 | } RTCRX509VALIDITY;
|
---|
380 | /** Pointer to the IPRT representation of an X.509 validity sequence. */
|
---|
381 | typedef RTCRX509VALIDITY *PRTCRX509VALIDITY;
|
---|
382 | /** Pointer ot the const IPRT representation of an X.509 validity sequence. */
|
---|
383 | typedef RTCRX509VALIDITY const *PCRTCRX509VALIDITY;
|
---|
384 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509VALIDITY, RTDECL, RTCrX509Validity, SeqCore.Asn1Core);
|
---|
385 |
|
---|
386 | RTDECL(bool) RTCrX509Validity_IsValidAtTimeSpec(PCRTCRX509VALIDITY pThis, PCRTTIMESPEC pTimeSpec);
|
---|
387 |
|
---|
388 |
|
---|
389 | #if 0
|
---|
390 | /**
|
---|
391 | * X.509 UniqueIdentifier (IPRT representation).
|
---|
392 | */
|
---|
393 | typedef struct RTCRX509UNIQUEIDENTIFIER
|
---|
394 | {
|
---|
395 | /** Representation is a bit string. */
|
---|
396 | RTASN1BITSTRING BitString;
|
---|
397 | } RTCRX509UNIQUEIDENTIFIER;
|
---|
398 | /** Pointer to the IPRT representation of an X.509 unique identifier. */
|
---|
399 | typedef RTCRX509UNIQUEIDENTIFIER *PRTCRX509UNIQUEIDENTIFIER;
|
---|
400 | /** Pointer to the const IPRT representation of an X.509 unique identifier. */
|
---|
401 | typedef RTCRX509UNIQUEIDENTIFIER const *PCRTCRX509UNIQUEIDENTIFIER;
|
---|
402 | RTASN1TYPE_STANDARD_PROTOTYPES_NO_GET_CORE(RTCRX509UNIQUEIDENTIFIER, RTDECL, RTCrX509UniqueIdentifier);
|
---|
403 | #endif
|
---|
404 | RTASN1TYPE_ALIAS(RTCRX509UNIQUEIDENTIFIER, RTASN1BITSTRING, RTCrX509UniqueIdentifier, RTAsn1BitString);
|
---|
405 |
|
---|
406 |
|
---|
407 | /**
|
---|
408 | * X.509 SubjectPublicKeyInfo (IPRT representation).
|
---|
409 | */
|
---|
410 | typedef struct RTCRX509SUBJECTPUBLICKEYINFO
|
---|
411 | {
|
---|
412 | /** Core sequence bits. */
|
---|
413 | RTASN1SEQUENCECORE SeqCore;
|
---|
414 | /** The algorithm used with the public key. */
|
---|
415 | RTCRX509ALGORITHMIDENTIFIER Algorithm;
|
---|
416 | /** A bit string containing the public key.
|
---|
417 | *
|
---|
418 | * For algorithms like rsaEncryption this is generally a sequence of two
|
---|
419 | * integers, where the first one has lots of bits, and the second one being a
|
---|
420 | * modulous value. These are details specific to the algorithm and not relevant
|
---|
421 | * when validating the certificate chain. */
|
---|
422 | RTASN1BITSTRING SubjectPublicKey;
|
---|
423 | } RTCRX509SUBJECTPUBLICKEYINFO;
|
---|
424 | /** Pointer to the IPRT representation of an X.509 subject public key info
|
---|
425 | * sequence. */
|
---|
426 | typedef RTCRX509SUBJECTPUBLICKEYINFO *PRTCRX509SUBJECTPUBLICKEYINFO;
|
---|
427 | /** Pointer to the const IPRT representation of an X.509 subject public key info
|
---|
428 | * sequence. */
|
---|
429 | typedef RTCRX509SUBJECTPUBLICKEYINFO const *PCRTCRX509SUBJECTPUBLICKEYINFO;
|
---|
430 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509SUBJECTPUBLICKEYINFO, RTDECL, RTCrX509SubjectPublicKeyInfo, SeqCore.Asn1Core);
|
---|
431 |
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * One X.509 AuthorityKeyIdentifier (IPRT representation).
|
---|
435 | */
|
---|
436 | typedef struct RTCRX509AUTHORITYKEYIDENTIFIER
|
---|
437 | {
|
---|
438 | /** Sequence core. */
|
---|
439 | RTASN1SEQUENCECORE SeqCore;
|
---|
440 | /** Tag 0, optional, implicit: Key identifier. */
|
---|
441 | RTASN1OCTETSTRING KeyIdentifier;
|
---|
442 | /** Tag 1, optional, implicit: Issuer name. */
|
---|
443 | RTCRX509GENERALNAMES AuthorityCertIssuer;
|
---|
444 | /** Tag 2, optional, implicit: Serial number of issuer. */
|
---|
445 | RTASN1INTEGER AuthorityCertSerialNumber;
|
---|
446 | } RTCRX509AUTHORITYKEYIDENTIFIER;
|
---|
447 | /** Pointer to the IPRT representation of an X.509 AuthorityKeyIdentifier
|
---|
448 | * sequence. */
|
---|
449 | typedef RTCRX509AUTHORITYKEYIDENTIFIER *PRTCRX509AUTHORITYKEYIDENTIFIER;
|
---|
450 | /** Pointer to the const IPRT representation of an X.509 AuthorityKeyIdentifier
|
---|
451 | * sequence. */
|
---|
452 | typedef RTCRX509AUTHORITYKEYIDENTIFIER const *PCRTCRX509AUTHORITYKEYIDENTIFIER;
|
---|
453 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509AUTHORITYKEYIDENTIFIER, RTDECL, RTCrX509AuthorityKeyIdentifier, SeqCore.Asn1Core);
|
---|
454 |
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * One X.509 OldAuthorityKeyIdentifier (IPRT representation).
|
---|
458 | */
|
---|
459 | typedef struct RTCRX509OLDAUTHORITYKEYIDENTIFIER
|
---|
460 | {
|
---|
461 | /** Sequence core. */
|
---|
462 | RTASN1SEQUENCECORE SeqCore;
|
---|
463 | /** Tag 0, optional, implicit: Key identifier. */
|
---|
464 | RTASN1OCTETSTRING KeyIdentifier;
|
---|
465 | struct
|
---|
466 | {
|
---|
467 | RTASN1CONTEXTTAG1 CtxTag1;
|
---|
468 | /** Tag 1, optional, implicit: Issuer name. */
|
---|
469 | RTCRX509NAME AuthorityCertIssuer;
|
---|
470 | } T1;
|
---|
471 | /** Tag 2, optional, implicit: Serial number of issuer. */
|
---|
472 | RTASN1INTEGER AuthorityCertSerialNumber;
|
---|
473 | } RTCRX509OLDAUTHORITYKEYIDENTIFIER;
|
---|
474 | /** Pointer to the IPRT representation of an X.509 AuthorityKeyIdentifier
|
---|
475 | * sequence. */
|
---|
476 | typedef RTCRX509OLDAUTHORITYKEYIDENTIFIER *PRTCRX509OLDAUTHORITYKEYIDENTIFIER;
|
---|
477 | /** Pointer to the const IPRT representation of an X.509 AuthorityKeyIdentifier
|
---|
478 | * sequence. */
|
---|
479 | typedef RTCRX509OLDAUTHORITYKEYIDENTIFIER const *PCRTCRX509OLDAUTHORITYKEYIDENTIFIER;
|
---|
480 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509OLDAUTHORITYKEYIDENTIFIER, RTDECL, RTCrX509OldAuthorityKeyIdentifier, SeqCore.Asn1Core);
|
---|
481 |
|
---|
482 |
|
---|
483 | /**
|
---|
484 | * One X.509 PolicyQualifierInfo (IPRT representation).
|
---|
485 | */
|
---|
486 | typedef struct RTCRX509POLICYQUALIFIERINFO
|
---|
487 | {
|
---|
488 | /** Core sequence bits. */
|
---|
489 | RTASN1SEQUENCECORE SeqCore;
|
---|
490 | /** The policy object ID. */
|
---|
491 | RTASN1OBJID PolicyQualifierId;
|
---|
492 | /** Anything defined by the policy qualifier id. */
|
---|
493 | RTASN1DYNTYPE Qualifier;
|
---|
494 | } RTCRX509POLICYQUALIFIERINFO;
|
---|
495 | /** Pointer to the IPRT representation of an X.509 PolicyQualifierInfo
|
---|
496 | * sequence. */
|
---|
497 | typedef RTCRX509POLICYQUALIFIERINFO *PRTCRX509POLICYQUALIFIERINFO;
|
---|
498 | /** Pointer to the const IPRT representation of an X.509 PolicyQualifierInfo
|
---|
499 | * sequence. */
|
---|
500 | typedef RTCRX509POLICYQUALIFIERINFO const *PCRTCRX509POLICYQUALIFIERINFO;
|
---|
501 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509POLICYQUALIFIERINFO, RTDECL, RTCrX509PolicyQualifierInfo, SeqCore.Asn1Core);
|
---|
502 | RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTCRX509POLICYQUALIFIERINFOS, RTCRX509POLICYQUALIFIERINFO, RTDECL, RTCrX509PolicyQualifierInfos);
|
---|
503 |
|
---|
504 |
|
---|
505 | /**
|
---|
506 | * One X.509 PolicyInformation (IPRT representation).
|
---|
507 | */
|
---|
508 | typedef struct RTCRX509POLICYINFORMATION
|
---|
509 | {
|
---|
510 | /** Core sequence bits. */
|
---|
511 | RTASN1SEQUENCECORE SeqCore;
|
---|
512 | /** The policy object ID. */
|
---|
513 | RTASN1OBJID PolicyIdentifier;
|
---|
514 | /** Optional sequence of policy qualifiers. */
|
---|
515 | RTCRX509POLICYQUALIFIERINFOS PolicyQualifiers;
|
---|
516 | } RTCRX509POLICYINFORMATION;
|
---|
517 | /** Pointer to the IPRT representation of an X.509 PolicyInformation
|
---|
518 | * sequence. */
|
---|
519 | typedef RTCRX509POLICYINFORMATION *PRTCRX509POLICYINFORMATION;
|
---|
520 | /** Pointer to the const IPRT representation of an X.509 PolicyInformation
|
---|
521 | * sequence. */
|
---|
522 | typedef RTCRX509POLICYINFORMATION const *PCRTCRX509POLICYINFORMATION;
|
---|
523 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509POLICYINFORMATION, RTDECL, RTCrX509PolicyInformation, SeqCore.Asn1Core);
|
---|
524 | RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTCRX509CERTIFICATEPOLICIES, RTCRX509POLICYINFORMATION, RTDECL, RTCrX509CertificatePolicies);
|
---|
525 |
|
---|
526 | /** Sepcial policy object ID that matches any policy. */
|
---|
527 | #define RTCRX509_ID_CE_CP_ANY_POLICY_OID "2.5.29.32.0"
|
---|
528 |
|
---|
529 |
|
---|
530 | /**
|
---|
531 | * One X.509 PolicyMapping (IPRT representation).
|
---|
532 | */
|
---|
533 | typedef struct RTCRX509POLICYMAPPING
|
---|
534 | {
|
---|
535 | /** Core sequence bits. */
|
---|
536 | RTASN1SEQUENCECORE SeqCore;
|
---|
537 | /** Issuer policy ID. */
|
---|
538 | RTASN1OBJID IssuerDomainPolicy;
|
---|
539 | /** Subject policy ID. */
|
---|
540 | RTASN1OBJID SubjectDomainPolicy;
|
---|
541 | } RTCRX509POLICYMAPPING;
|
---|
542 | /** Pointer to the IPRT representation of a sequence of X.509 PolicyMapping. */
|
---|
543 | typedef RTCRX509POLICYMAPPING *PRTCRX509POLICYMAPPING;
|
---|
544 | /** Pointer to the const IPRT representation of a sequence of X.509
|
---|
545 | * PolicyMapping. */
|
---|
546 | typedef RTCRX509POLICYMAPPING const *PCRTCRX509POLICYMAPPING;
|
---|
547 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509POLICYMAPPING, RTDECL, RTCrX509PolicyMapping, SeqCore.Asn1Core);
|
---|
548 | RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTCRX509POLICYMAPPINGS, RTCRX509POLICYMAPPING, RTDECL, RTCrX509PolicyMappings);
|
---|
549 |
|
---|
550 |
|
---|
551 | /**
|
---|
552 | * X.509 BasicConstraints (IPRT representation).
|
---|
553 | */
|
---|
554 | typedef struct RTCRX509BASICCONSTRAINTS
|
---|
555 | {
|
---|
556 | /** Core sequence bits. */
|
---|
557 | RTASN1SEQUENCECORE SeqCore;
|
---|
558 | /** Is this ia certficiate authority? Default to false. */
|
---|
559 | RTASN1BOOLEAN CA;
|
---|
560 | /** Path length constraint. */
|
---|
561 | RTASN1INTEGER PathLenConstraint;
|
---|
562 | } RTCRX509BASICCONSTRAINTS;
|
---|
563 | /** Pointer to the IPRT representation of a sequence of X.509
|
---|
564 | * BasicConstraints. */
|
---|
565 | typedef RTCRX509BASICCONSTRAINTS *PRTCRX509BASICCONSTRAINTS;
|
---|
566 | /** Pointer to the const IPRT representation of a sequence of X.509
|
---|
567 | * BasicConstraints. */
|
---|
568 | typedef RTCRX509BASICCONSTRAINTS const *PCRTCRX509BASICCONSTRAINTS;
|
---|
569 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509BASICCONSTRAINTS, RTDECL, RTCrX509BasicConstraints, SeqCore.Asn1Core);
|
---|
570 |
|
---|
571 |
|
---|
572 | /**
|
---|
573 | * X.509 GeneralSubtree (IPRT representation).
|
---|
574 | */
|
---|
575 | typedef struct RTCRX509GENERALSUBTREE
|
---|
576 | {
|
---|
577 | /** Core sequence bits. */
|
---|
578 | RTASN1SEQUENCECORE SeqCore;
|
---|
579 | /** Base name. */
|
---|
580 | RTCRX509GENERALNAME Base;
|
---|
581 | /** Tag 0, optional: Minimum, default 0. Fixed at 0 by RFC-5280. */
|
---|
582 | RTASN1INTEGER Minimum;
|
---|
583 | /** Tag 1, optional: Maximum. Fixed as not-present by RFC-5280. */
|
---|
584 | RTASN1INTEGER Maximum;
|
---|
585 | } RTCRX509GENERALSUBTREE;
|
---|
586 | /** Pointer to the IPRT representation of a sequence of X.509 GeneralSubtree. */
|
---|
587 | typedef RTCRX509GENERALSUBTREE *PRTCRX509GENERALSUBTREE;
|
---|
588 | /** Pointer to the const IPRT representation of a sequence of X.509
|
---|
589 | * GeneralSubtree. */
|
---|
590 | typedef RTCRX509GENERALSUBTREE const *PCRTCRX509GENERALSUBTREE;
|
---|
591 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509GENERALSUBTREE, RTDECL, RTCrX509GeneralSubtree, SeqCore.Asn1Core);
|
---|
592 |
|
---|
593 | RTDECL(bool) RTCrX509GeneralSubtree_ConstraintMatch(PCRTCRX509GENERALSUBTREE pConstraint, PCRTCRX509GENERALSUBTREE pName);
|
---|
594 |
|
---|
595 | RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTCRX509GENERALSUBTREES, RTCRX509GENERALSUBTREE, RTDECL, RTCrX509GeneralSubtrees);
|
---|
596 |
|
---|
597 |
|
---|
598 | /**
|
---|
599 | * X.509 NameConstraints (IPRT representation).
|
---|
600 | */
|
---|
601 | typedef struct RTCRX509NAMECONSTRAINTS
|
---|
602 | {
|
---|
603 | /** Core sequence bits. */
|
---|
604 | RTASN1SEQUENCECORE SeqCore;
|
---|
605 | /** Tag 0, optional: Permitted subtrees. */
|
---|
606 | struct
|
---|
607 | {
|
---|
608 | /** Context tag. */
|
---|
609 | RTASN1CONTEXTTAG0 CtxTag0;
|
---|
610 | /** The permitted subtrees. */
|
---|
611 | RTCRX509GENERALSUBTREES PermittedSubtrees;
|
---|
612 | } T0;
|
---|
613 | /** Tag 1, optional: Excluded subtrees. */
|
---|
614 | struct
|
---|
615 | {
|
---|
616 | /** Context tag. */
|
---|
617 | RTASN1CONTEXTTAG1 CtxTag1;
|
---|
618 | /** The excluded subtrees. */
|
---|
619 | RTCRX509GENERALSUBTREES ExcludedSubtrees;
|
---|
620 | } T1;
|
---|
621 | } RTCRX509NAMECONSTRAINTS;
|
---|
622 | /** Pointer to the IPRT representation of a sequence of X.509
|
---|
623 | * NameConstraints. */
|
---|
624 | typedef RTCRX509NAMECONSTRAINTS *PRTCRX509NAMECONSTRAINTS;
|
---|
625 | /** Pointer to the const IPRT representation of a sequence of X.509
|
---|
626 | * NameConstraints. */
|
---|
627 | typedef RTCRX509NAMECONSTRAINTS const *PCRTCRX509NAMECONSTRAINTS;
|
---|
628 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509NAMECONSTRAINTS, RTDECL, RTCrX509NameConstraints, SeqCore.Asn1Core);
|
---|
629 |
|
---|
630 |
|
---|
631 | /**
|
---|
632 | * X.509 PolicyConstraints (IPRT representation).
|
---|
633 | */
|
---|
634 | typedef struct RTCRX509POLICYCONSTRAINTS
|
---|
635 | {
|
---|
636 | /** Core sequence bits. */
|
---|
637 | RTASN1SEQUENCECORE SeqCore;
|
---|
638 | /** Tag 0, optional: Certificates before an explicit policy is required. */
|
---|
639 | RTASN1INTEGER RequireExplicitPolicy;
|
---|
640 | /** Tag 1, optional: Certificates before policy mapping is inhibited. */
|
---|
641 | RTASN1INTEGER InhibitPolicyMapping;
|
---|
642 | } RTCRX509POLICYCONSTRAINTS;
|
---|
643 | /** Pointer to the IPRT representation of a sequence of X.509
|
---|
644 | * PolicyConstraints. */
|
---|
645 | typedef RTCRX509POLICYCONSTRAINTS *PRTCRX509POLICYCONSTRAINTS;
|
---|
646 | /** Pointer to the const IPRT representation of a sequence of X.509
|
---|
647 | * PolicyConstraints. */
|
---|
648 | typedef RTCRX509POLICYCONSTRAINTS const *PCRTCRX509POLICYCONSTRAINTS;
|
---|
649 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509POLICYCONSTRAINTS, RTDECL, RTCrX509PolicyConstraints, SeqCore.Asn1Core);
|
---|
650 |
|
---|
651 |
|
---|
652 | /**
|
---|
653 | * Indicates what an X.509 extension value encapsulates.
|
---|
654 | */
|
---|
655 | typedef enum RTCRX509EXTENSIONVALUE
|
---|
656 | {
|
---|
657 | RTCRX509EXTENSIONVALUE_INVALID = 0,
|
---|
658 | /** Unknown, no decoding available just the octet string. */
|
---|
659 | RTCRX509EXTENSIONVALUE_UNKNOWN,
|
---|
660 | /** Unencapsulated (i.e. octet string). */
|
---|
661 | RTCRX509EXTENSIONVALUE_NOT_ENCAPSULATED,
|
---|
662 |
|
---|
663 | /** Bit string (RTASN1BITSTRING). */
|
---|
664 | RTCRX509EXTENSIONVALUE_BIT_STRING,
|
---|
665 | /** Octet string (RTASN1OCTETSTRING). */
|
---|
666 | RTCRX509EXTENSIONVALUE_OCTET_STRING,
|
---|
667 | /** Integer string (RTASN1INTEGER). */
|
---|
668 | RTCRX509EXTENSIONVALUE_INTEGER,
|
---|
669 | /** Sequence of object identifiers (RTASN1SEQOFOBJIDS). */
|
---|
670 | RTCRX509EXTENSIONVALUE_SEQ_OF_OBJ_IDS,
|
---|
671 |
|
---|
672 | /** Authority key identifier (RTCRX509AUTHORITYKEYIDENTIFIER). */
|
---|
673 | RTCRX509EXTENSIONVALUE_AUTHORITY_KEY_IDENTIFIER,
|
---|
674 | /** Old Authority key identifier (RTCRX509OLDAUTHORITYKEYIDENTIFIER). */
|
---|
675 | RTCRX509EXTENSIONVALUE_OLD_AUTHORITY_KEY_IDENTIFIER,
|
---|
676 | /** Certificate policies (RTCRX509CERTIFICATEPOLICIES). */
|
---|
677 | RTCRX509EXTENSIONVALUE_CERTIFICATE_POLICIES,
|
---|
678 | /** Sequence of policy mappings (RTCRX509POLICYMAPPINGS). */
|
---|
679 | RTCRX509EXTENSIONVALUE_POLICY_MAPPINGS,
|
---|
680 | /** Basic constraints (RTCRX509BASICCONSTRAINTS). */
|
---|
681 | RTCRX509EXTENSIONVALUE_BASIC_CONSTRAINTS,
|
---|
682 | /** Name constraints (RTCRX509NAMECONSTRAINTS). */
|
---|
683 | RTCRX509EXTENSIONVALUE_NAME_CONSTRAINTS,
|
---|
684 | /** Policy constraints (RTCRX509POLICYCONSTRAINTS). */
|
---|
685 | RTCRX509EXTENSIONVALUE_POLICY_CONSTRAINTS,
|
---|
686 | /** Sequence of general names (RTCRX509GENERALNAMES). */
|
---|
687 | RTCRX509EXTENSIONVALUE_GENERAL_NAMES,
|
---|
688 |
|
---|
689 | /** Blow the type up to 32-bits. */
|
---|
690 | RTCRX509EXTENSIONVALUE_32BIT_HACK = 0x7fffffff
|
---|
691 | } RTCRX509EXTENSIONVALUE;
|
---|
692 |
|
---|
693 | /**
|
---|
694 | * One X.509 Extension (IPRT representation).
|
---|
695 | */
|
---|
696 | typedef struct RTCRX509EXTENSION
|
---|
697 | {
|
---|
698 | /** Core sequence bits. */
|
---|
699 | RTASN1SEQUENCECORE SeqCore;
|
---|
700 | /** Extension ID. */
|
---|
701 | RTASN1OBJID ExtnId;
|
---|
702 | /** Whether this is critical (default @c false). */
|
---|
703 | RTASN1BOOLEAN Critical;
|
---|
704 | /** Indicates what ExtnValue.pEncapsulated points at. */
|
---|
705 | RTCRX509EXTENSIONVALUE enmValue;
|
---|
706 | /** The value.
|
---|
707 | * Contains extension specific data that we don't yet parse. */
|
---|
708 | RTASN1OCTETSTRING ExtnValue;
|
---|
709 | } RTCRX509EXTENSION;
|
---|
710 | /** Pointer to the IPRT representation of one X.509 extensions. */
|
---|
711 | typedef RTCRX509EXTENSION *PRTCRX509EXTENSION;
|
---|
712 | /** Pointer to the const IPRT representation of one X.509 extension. */
|
---|
713 | typedef RTCRX509EXTENSION const *PCRTCRX509EXTENSION;
|
---|
714 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509EXTENSION, RTDECL, RTCrX509Extension, SeqCore.Asn1Core);
|
---|
715 | RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTCRX509EXTENSIONS, RTCRX509EXTENSION, RTDECL, RTCrX509Extensions);
|
---|
716 |
|
---|
717 | RTDECL(int) RTCrX509Extension_ExtnValue_DecodeAsn1(PRTASN1CURSOR pCursor, uint32_t fFlags,
|
---|
718 | PRTCRX509EXTENSION pThis, const char *pszErrorTag);
|
---|
719 |
|
---|
720 |
|
---|
721 | /**
|
---|
722 | * X.509 To-be-signed certificate information (IPRT representation).
|
---|
723 | */
|
---|
724 | typedef struct RTCRX509TBSCERTIFICATE
|
---|
725 | {
|
---|
726 | /** Sequence core. */
|
---|
727 | RTASN1SEQUENCECORE SeqCore;
|
---|
728 | /** Structure version. */
|
---|
729 | struct
|
---|
730 | {
|
---|
731 | /** Context tag with value 0. */
|
---|
732 | RTASN1CONTEXTTAG0 CtxTag0;
|
---|
733 | /** The actual value (RTCRX509TBSCERTIFICATE_V1, ...). */
|
---|
734 | RTASN1INTEGER Version;
|
---|
735 | } T0;
|
---|
736 | /** The serial number of the certificate. */
|
---|
737 | RTASN1INTEGER SerialNumber;
|
---|
738 | /** The signature algorithm. */
|
---|
739 | RTCRX509ALGORITHMIDENTIFIER Signature;
|
---|
740 | /** The issuer name. */
|
---|
741 | RTCRX509NAME Issuer;
|
---|
742 | /** The certificate validity period. */
|
---|
743 | RTCRX509VALIDITY Validity;
|
---|
744 | /** The subject name. */
|
---|
745 | RTCRX509NAME Subject;
|
---|
746 | /** The public key for this certificate. */
|
---|
747 | RTCRX509SUBJECTPUBLICKEYINFO SubjectPublicKeyInfo;
|
---|
748 | /** Issuer unique identifier (optional, version >= v2). */
|
---|
749 | struct
|
---|
750 | {
|
---|
751 | /** Context tag with value 1. */
|
---|
752 | RTASN1CONTEXTTAG1 CtxTag1;
|
---|
753 | /** The unique identifier value. */
|
---|
754 | RTCRX509UNIQUEIDENTIFIER IssuerUniqueId;
|
---|
755 | } T1;
|
---|
756 | /** Subject unique identifier (optional, version >= v2). */
|
---|
757 | struct
|
---|
758 | {
|
---|
759 | /** Context tag with value 2. */
|
---|
760 | RTASN1CONTEXTTAG2 CtxTag2;
|
---|
761 | /** The unique identifier value. */
|
---|
762 | RTCRX509UNIQUEIDENTIFIER SubjectUniqueId;
|
---|
763 | } T2;
|
---|
764 | /** Extensions (optional, version >= v3). */
|
---|
765 | struct
|
---|
766 | {
|
---|
767 | /** Context tag with value 3. */
|
---|
768 | RTASN1CONTEXTTAG3 CtxTag3;
|
---|
769 | /** The unique identifier value. */
|
---|
770 | RTCRX509EXTENSIONS Extensions;
|
---|
771 | /** Extensions summary flags. */
|
---|
772 | uint32_t fFlags;
|
---|
773 | /** Key usage flags. */
|
---|
774 | uint32_t fKeyUsage;
|
---|
775 | /** Extended key usage flags. */
|
---|
776 | uint32_t fExtKeyUsage;
|
---|
777 |
|
---|
778 | /** Pointer to the authority key ID extension if present. */
|
---|
779 | PCRTCRX509AUTHORITYKEYIDENTIFIER pAuthorityKeyIdentifier;
|
---|
780 | /** Pointer to the OLD authority key ID extension if present. */
|
---|
781 | PCRTCRX509OLDAUTHORITYKEYIDENTIFIER pOldAuthorityKeyIdentifier;
|
---|
782 | /** Pointer to the subject key ID extension if present. */
|
---|
783 | PCRTASN1OCTETSTRING pSubjectKeyIdentifier;
|
---|
784 | /** Pointer to the alternative subject name extension if present. */
|
---|
785 | PCRTCRX509GENERALNAMES pAltSubjectName;
|
---|
786 | /** Pointer to the alternative issuer name extension if present. */
|
---|
787 | PCRTCRX509GENERALNAMES pAltIssuerName;
|
---|
788 | /** Pointer to the certificate policies extension if present. */
|
---|
789 | PCRTCRX509CERTIFICATEPOLICIES pCertificatePolicies;
|
---|
790 | /** Pointer to the policy mappings extension if present. */
|
---|
791 | PCRTCRX509POLICYMAPPINGS pPolicyMappings;
|
---|
792 | /** Pointer to the basic constraints extension if present. */
|
---|
793 | PCRTCRX509BASICCONSTRAINTS pBasicConstraints;
|
---|
794 | /** Pointer to the name constraints extension if present. */
|
---|
795 | PCRTCRX509NAMECONSTRAINTS pNameConstraints;
|
---|
796 | /** Pointer to the policy constraints extension if present. */
|
---|
797 | PCRTCRX509POLICYCONSTRAINTS pPolicyConstraints;
|
---|
798 | /** Pointer to the inhibit anyPolicy extension if present. */
|
---|
799 | PCRTASN1INTEGER pInhibitAnyPolicy;
|
---|
800 | } T3;
|
---|
801 | } RTCRX509TBSCERTIFICATE;
|
---|
802 | /** Pointer to the IPRT representation of a X.509 TBSCertificate. */
|
---|
803 | typedef RTCRX509TBSCERTIFICATE *PRTCRX509TBSCERTIFICATE;
|
---|
804 | /** Pointer to the const IPRT representation of a X.509 TBSCertificate. */
|
---|
805 | typedef RTCRX509TBSCERTIFICATE const *PCRTCRX509TBSCERTIFICATE;
|
---|
806 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509TBSCERTIFICATE, RTDECL, RTCrX509TbsCertificate, SeqCore.Asn1Core);
|
---|
807 |
|
---|
808 | /** @name RTCRX509TBSCERTIFICATE::T0.Version values.
|
---|
809 | * @{ */
|
---|
810 | #define RTCRX509TBSCERTIFICATE_V1 0
|
---|
811 | #define RTCRX509TBSCERTIFICATE_V2 1
|
---|
812 | #define RTCRX509TBSCERTIFICATE_V3 2
|
---|
813 | /** @} */
|
---|
814 |
|
---|
815 | /** @name RTCRX509TBSCERTIFICATE::T3.fFlags values.
|
---|
816 | * @{ */
|
---|
817 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_KEY_USAGE RT_BIT_32(0)
|
---|
818 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_EXT_KEY_USAGE RT_BIT_32(1)
|
---|
819 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_SUBJECT_KEY_IDENTIFIER RT_BIT_32(2)
|
---|
820 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_SUBJECT_ALT_NAME RT_BIT_32(3)
|
---|
821 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_ISSUER_ALT_NAME RT_BIT_32(4)
|
---|
822 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_CERTIFICATE_POLICIES RT_BIT_32(5)
|
---|
823 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_POLICY_MAPPINGS RT_BIT_32(6)
|
---|
824 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_BASIC_CONSTRAINTS RT_BIT_32(7)
|
---|
825 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_NAME_CONSTRAINTS RT_BIT_32(8)
|
---|
826 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_POLICY_CONSTRAINTS RT_BIT_32(9)
|
---|
827 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_AUTHORITY_KEY_IDENTIFIER RT_BIT_32(10)
|
---|
828 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_OLD_AUTHORITY_KEY_IDENTIFIER RT_BIT_32(11)
|
---|
829 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_ACCEPTABLE_CERT_POLICIES RT_BIT_32(12)
|
---|
830 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_INHIBIT_ANY_POLICY RT_BIT_32(13)
|
---|
831 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_OTHER RT_BIT_32(22) /**< Other unknown extension present. */
|
---|
832 | #define RTCRX509TBSCERTIFICATE_F_PRESENT_NONE RT_BIT_32(23) /**< No extensions present. */
|
---|
833 | /** @} */
|
---|
834 |
|
---|
835 | /** @name X.509 Key Usage flags. (RFC-5280 section 4.2.1.3.)
|
---|
836 | * @{ */
|
---|
837 | #define RTCRX509CERT_KEY_USAGE_F_DIGITAL_SIGNATURE_BIT 0
|
---|
838 | #define RTCRX509CERT_KEY_USAGE_F_DIGITAL_SIGNATURE RT_BIT_32(0)
|
---|
839 | #define RTCRX509CERT_KEY_USAGE_F_CONTENT_COMMITTMENT_BIT 1
|
---|
840 | #define RTCRX509CERT_KEY_USAGE_F_CONTENT_COMMITTMENT RT_BIT_32(1)
|
---|
841 | #define RTCRX509CERT_KEY_USAGE_F_KEY_ENCIPHERMENT_BIT 2
|
---|
842 | #define RTCRX509CERT_KEY_USAGE_F_KEY_ENCIPHERMENT RT_BIT_32(2)
|
---|
843 | #define RTCRX509CERT_KEY_USAGE_F_DATA_ENCIPHERMENT_BIT 3
|
---|
844 | #define RTCRX509CERT_KEY_USAGE_F_DATA_ENCIPHERMENT RT_BIT_32(3)
|
---|
845 | #define RTCRX509CERT_KEY_USAGE_F_KEY_AGREEMENT_BIT 4
|
---|
846 | #define RTCRX509CERT_KEY_USAGE_F_KEY_AGREEMENT RT_BIT_32(4)
|
---|
847 | #define RTCRX509CERT_KEY_USAGE_F_KEY_CERT_SIGN_BIT 5
|
---|
848 | #define RTCRX509CERT_KEY_USAGE_F_KEY_CERT_SIGN RT_BIT_32(5)
|
---|
849 | #define RTCRX509CERT_KEY_USAGE_F_CRL_SIGN_BIT 6
|
---|
850 | #define RTCRX509CERT_KEY_USAGE_F_CRL_SIGN RT_BIT_32(6)
|
---|
851 | #define RTCRX509CERT_KEY_USAGE_F_ENCIPHERMENT_ONLY_BIT 7
|
---|
852 | #define RTCRX509CERT_KEY_USAGE_F_ENCIPHERMENT_ONLY RT_BIT_32(7)
|
---|
853 | #define RTCRX509CERT_KEY_USAGE_F_DECIPHERMENT_ONLY_BIT 8
|
---|
854 | #define RTCRX509CERT_KEY_USAGE_F_DECIPHERMENT_ONLY RT_BIT_32(8)
|
---|
855 | /** @} */
|
---|
856 |
|
---|
857 | /** @name X.509 Extended Key Usage flags. (RFC-5280 section 4.2.1.12, ++.)
|
---|
858 | * @remarks Needless to say, these flags doesn't cover all possible extended key
|
---|
859 | * usages, because there is a potential unlimited number of them. Only
|
---|
860 | * ones relevant to IPRT and it's users are covered.
|
---|
861 | * @{ */
|
---|
862 | #define RTCRX509CERT_EKU_F_ANY RT_BIT_64(0)
|
---|
863 | #define RTCRX509CERT_EKU_F_SERVER_AUTH RT_BIT_64(1)
|
---|
864 | #define RTCRX509CERT_EKU_F_CLIENT_AUTH RT_BIT_64(2)
|
---|
865 | #define RTCRX509CERT_EKU_F_CODE_SIGNING RT_BIT_64(3)
|
---|
866 | #define RTCRX509CERT_EKU_F_EMAIL_PROTECTION RT_BIT_64(4)
|
---|
867 | #define RTCRX509CERT_EKU_F_IPSEC_END_SYSTEM RT_BIT_64(5)
|
---|
868 | #define RTCRX509CERT_EKU_F_IPSEC_TUNNEL RT_BIT_64(6)
|
---|
869 | #define RTCRX509CERT_EKU_F_IPSEC_USER RT_BIT_64(7)
|
---|
870 | #define RTCRX509CERT_EKU_F_TIMESTAMPING RT_BIT_64(8)
|
---|
871 | #define RTCRX509CERT_EKU_F_OCSP_SIGNING RT_BIT_64(9)
|
---|
872 | #define RTCRX509CERT_EKU_F_DVCS RT_BIT_64(10)
|
---|
873 | #define RTCRX509CERT_EKU_F_SBGP_CERT_AA_SERVICE_AUTH RT_BIT_64(11)
|
---|
874 | #define RTCRX509CERT_EKU_F_EAP_OVER_PPP RT_BIT_64(12)
|
---|
875 | #define RTCRX509CERT_EKU_F_EAP_OVER_LAN RT_BIT_64(13)
|
---|
876 | #define RTCRX509CERT_EKU_F_OTHER RT_BIT_64(16) /**< Other unknown extended key usage present. */
|
---|
877 | #define RTCRX509CERT_EKU_F_APPLE_CODE_SIGNING RT_BIT_64(24)
|
---|
878 | #define RTCRX509CERT_EKU_F_APPLE_CODE_SIGNING_DEVELOPMENT RT_BIT_64(25)
|
---|
879 | #define RTCRX509CERT_EKU_F_APPLE_SOFTWARE_UPDATE_SIGNING RT_BIT_64(26)
|
---|
880 | #define RTCRX509CERT_EKU_F_APPLE_CODE_SIGNING_THIRD_PARTY RT_BIT_64(27)
|
---|
881 | #define RTCRX509CERT_EKU_F_APPLE_RESOURCE_SIGNING RT_BIT_64(28)
|
---|
882 | #define RTCRX509CERT_EKU_F_APPLE_SYSTEM_IDENTITY RT_BIT_64(29)
|
---|
883 | #define RTCRX509CERT_EKU_F_MS_TIMESTAMP_SIGNING RT_BIT_64(32)
|
---|
884 | #define RTCRX509CERT_EKU_F_MS_NT5_CRYPTO RT_BIT_64(33)
|
---|
885 | #define RTCRX509CERT_EKU_F_MS_OEM_WHQL_CRYPTO RT_BIT_64(34)
|
---|
886 | #define RTCRX509CERT_EKU_F_MS_EMBEDDED_NT_CRYPTO RT_BIT_64(35)
|
---|
887 | #define RTCRX509CERT_EKU_F_MS_KERNEL_MODE_CODE_SIGNING RT_BIT_64(36)
|
---|
888 | #define RTCRX509CERT_EKU_F_MS_LIFETIME_SIGNING RT_BIT_64(37)
|
---|
889 | #define RTCRX509CERT_EKU_F_MS_DRM RT_BIT_64(38)
|
---|
890 | #define RTCRX509CERT_EKU_F_MS_DRM_INDIVIDUALIZATION RT_BIT_64(39)
|
---|
891 | /** @} */
|
---|
892 |
|
---|
893 | /** @name Key purpose OIDs (extKeyUsage)
|
---|
894 | * @{ */
|
---|
895 | #define RTCRX509_ANY_EXTENDED_KEY_USAGE_OID "2.5.29.37.0"
|
---|
896 | #define RTCRX509_ID_KP_OID "1.3.6.1.5.5.7.3"
|
---|
897 | #define RTCRX509_ID_KP_SERVER_AUTH_OID "1.3.6.1.5.5.7.3.1"
|
---|
898 | #define RTCRX509_ID_KP_CLIENT_AUTH_OID "1.3.6.1.5.5.7.3.2"
|
---|
899 | #define RTCRX509_ID_KP_CODE_SIGNING_OID "1.3.6.1.5.5.7.3.3"
|
---|
900 | #define RTCRX509_ID_KP_EMAIL_PROTECTION_OID "1.3.6.1.5.5.7.3.4"
|
---|
901 | #define RTCRX509_ID_KP_IPSEC_END_SYSTEM_OID "1.3.6.1.5.5.7.3.5"
|
---|
902 | #define RTCRX509_ID_KP_IPSEC_TUNNEL_OID "1.3.6.1.5.5.7.3.6"
|
---|
903 | #define RTCRX509_ID_KP_IPSEC_USER_OID "1.3.6.1.5.5.7.3.7"
|
---|
904 | #define RTCRX509_ID_KP_TIMESTAMPING_OID "1.3.6.1.5.5.7.3.8"
|
---|
905 | #define RTCRX509_ID_KP_OCSP_SIGNING_OID "1.3.6.1.5.5.7.3.9"
|
---|
906 | #define RTCRX509_ID_KP_DVCS_OID "1.3.6.1.5.5.7.3.10"
|
---|
907 | #define RTCRX509_ID_KP_SBGP_CERT_AA_SERVICE_AUTH_OID "1.3.6.1.5.5.7.3.11"
|
---|
908 | #define RTCRX509_ID_KP_EAP_OVER_PPP_OID "1.3.6.1.5.5.7.3.13"
|
---|
909 | #define RTCRX509_ID_KP_EAP_OVER_LAN_OID "1.3.6.1.5.5.7.3.14"
|
---|
910 | /** @} */
|
---|
911 |
|
---|
912 | /** @name Microsoft extended key usage OIDs
|
---|
913 | * @{ */
|
---|
914 | #define RTCRX509_MS_EKU_CERT_TRUST_LIST_SIGNING_OID "1.3.6.1.4.1.311.10.3.1"
|
---|
915 | #define RTCRX509_MS_EKU_TIMESTAMP_SIGNING_OID "1.3.6.1.4.1.311.10.3.2"
|
---|
916 | #define RTCRX509_MS_EKU_SERVER_GATED_CRYPTO_OID "1.3.6.1.4.1.311.10.3.3"
|
---|
917 | #define RTCRX509_MS_EKU_SGC_SERIALIZED_OID "1.3.6.1.4.1.311.10.3.3.1"
|
---|
918 | #define RTCRX509_MS_EKU_ENCRYPTED_FILE_SYSTEM_OID "1.3.6.1.4.1.311.10.3.4"
|
---|
919 | #define RTCRX509_MS_EKU_WHQL_CRYPTO_OID "1.3.6.1.4.1.311.10.3.5"
|
---|
920 | #define RTCRX509_MS_EKU_NT5_CRYPTO_OID "1.3.6.1.4.1.311.10.3.6"
|
---|
921 | #define RTCRX509_MS_EKU_OEM_WHQL_CRYPTO_OID "1.3.6.1.4.1.311.10.3.7"
|
---|
922 | #define RTCRX509_MS_EKU_EMBEDDED_NT_CRYPTO_OID "1.3.6.1.4.1.311.10.3.8"
|
---|
923 | #define RTCRX509_MS_EKU_ROOT_LIST_SIGNER_OID "1.3.6.1.4.1.311.10.3.9"
|
---|
924 | #define RTCRX509_MS_EKU_QUALIFIED_SUBORDINATE_OID "1.3.6.1.4.1.311.10.3.10"
|
---|
925 | #define RTCRX509_MS_EKU_KEY_RECOVERY_3_OID "1.3.6.1.4.1.311.10.3.11"
|
---|
926 | #define RTCRX509_MS_EKU_DOCUMENT_SIGNING_OID "1.3.6.1.4.1.311.10.3.12"
|
---|
927 | #define RTCRX509_MS_EKU_LIFETIME_SIGNING_OID "1.3.6.1.4.1.311.10.3.13"
|
---|
928 | #define RTCRX509_MS_EKU_MOBILE_DEVICE_SOFTWARE_OID "1.3.6.1.4.1.311.10.3.14"
|
---|
929 | #define RTCRX509_MS_EKU_SMART_DISPLAY_OID "1.3.6.1.4.1.311.10.3.15"
|
---|
930 | #define RTCRX509_MS_EKU_CSP_SIGNATURE_OID "1.3.6.1.4.1.311.10.3.16"
|
---|
931 | #define RTCRX509_MS_EKU_EFS_RECOVERY_OID "1.3.6.1.4.1.311.10.3.4.1"
|
---|
932 | #define RTCRX509_MS_EKU_DRM_OID "1.3.6.1.4.1.311.10.5.1"
|
---|
933 | #define RTCRX509_MS_EKU_DRM_INDIVIDUALIZATION_OID "1.3.6.1.4.1.311.10.5.2"
|
---|
934 | #define RTCRX509_MS_EKU_LICENSES_OID "1.3.6.1.4.1.311.10.5.3"
|
---|
935 | #define RTCRX509_MS_EKU_LICENSE_SERVER_OID "1.3.6.1.4.1.311.10.5.4"
|
---|
936 | #define RTCRX509_MS_EKU_ENROLLMENT_AGENT_OID "1.3.6.1.4.1.311.20.2.1"
|
---|
937 | #define RTCRX509_MS_EKU_SMARTCARD_LOGON_OID "1.3.6.1.4.1.311.20.2.2"
|
---|
938 | #define RTCRX509_MS_EKU_CA_EXCHANGE_OID "1.3.6.1.4.1.311.21.5"
|
---|
939 | #define RTCRX509_MS_EKU_KEY_RECOVERY_21_OID "1.3.6.1.4.1.311.21.6"
|
---|
940 | #define RTCRX509_MS_EKU_SYSTEM_HEALTH_OID "1.3.6.1.4.1.311.47.1.1"
|
---|
941 | #define RTCRX509_MS_EKU_SYSTEM_HEALTH_LOOPHOLE_OID "1.3.6.1.4.1.311.47.1.3"
|
---|
942 | #define RTCRX509_MS_EKU_KERNEL_MODE_CODE_SIGNING_OID "1.3.6.1.4.1.311.61.1.1"
|
---|
943 | /** @} */
|
---|
944 |
|
---|
945 | /** @name Apple extended key usage OIDs
|
---|
946 | * @{ */
|
---|
947 | #define RTCRX509_APPLE_EKU_APPLE_EXTENDED_KEY_USAGE_OID "1.2.840.113635.100.4"
|
---|
948 | #define RTCRX509_APPLE_EKU_CODE_SIGNING_OID "1.2.840.113635.100.4.1"
|
---|
949 | #define RTCRX509_APPLE_EKU_CODE_SIGNING_DEVELOPMENT_OID "1.2.840.113635.100.4.1.1"
|
---|
950 | #define RTCRX509_APPLE_EKU_SOFTWARE_UPDATE_SIGNING_OID "1.2.840.113635.100.4.1.2"
|
---|
951 | #define RTCRX509_APPLE_EKU_CODE_SIGNING_THRID_PARTY_OID "1.2.840.113635.100.4.1.3"
|
---|
952 | #define RTCRX509_APPLE_EKU_RESOURCE_SIGNING_OID "1.2.840.113635.100.4.1.4"
|
---|
953 | #define RTCRX509_APPLE_EKU_ICHAT_SIGNING_OID "1.2.840.113635.100.4.2"
|
---|
954 | #define RTCRX509_APPLE_EKU_ICHAT_ENCRYPTION_OID "1.2.840.113635.100.4.3"
|
---|
955 | #define RTCRX509_APPLE_EKU_SYSTEM_IDENTITY_OID "1.2.840.113635.100.4.4"
|
---|
956 | #define RTCRX509_APPLE_EKU_CRYPTO_ENV_OID "1.2.840.113635.100.4.5"
|
---|
957 | #define RTCRX509_APPLE_EKU_CRYPTO_PRODUCTION_ENV_OID "1.2.840.113635.100.4.5.1"
|
---|
958 | #define RTCRX509_APPLE_EKU_CRYPTO_MAINTENANCE_ENV_OID "1.2.840.113635.100.4.5.2"
|
---|
959 | #define RTCRX509_APPLE_EKU_CRYPTO_TEST_ENV_OID "1.2.840.113635.100.4.5.3"
|
---|
960 | #define RTCRX509_APPLE_EKU_CRYPTO_DEVELOPMENT_ENV_OID "1.2.840.113635.100.4.5.4"
|
---|
961 | #define RTCRX509_APPLE_EKU_CRYPTO_QOS_OID "1.2.840.113635.100.4.6"
|
---|
962 | #define RTCRX509_APPLE_EKU_CRYPTO_TIER0_QOS_OID "1.2.840.113635.100.4.6.1"
|
---|
963 | #define RTCRX509_APPLE_EKU_CRYPTO_TIER1_QOS_OID "1.2.840.113635.100.4.6.2"
|
---|
964 | #define RTCRX509_APPLE_EKU_CRYPTO_TIER2_QOS_OID "1.2.840.113635.100.4.6.3"
|
---|
965 | #define RTCRX509_APPLE_EKU_CRYPTO_TIER3_QOS_OID "1.2.840.113635.100.4.6.4"
|
---|
966 | /** @} */
|
---|
967 |
|
---|
968 | /**
|
---|
969 | * Use this to update derived values after changing the certificate
|
---|
970 | * extensions.
|
---|
971 | *
|
---|
972 | * @returns IPRT status code
|
---|
973 | * @param pThis The certificate.
|
---|
974 | * @param pErrInfo Where to return additional error information. Optional.
|
---|
975 | */
|
---|
976 | RTDECL(int) RTCrX509TbsCertificate_ReprocessExtensions(PRTCRX509TBSCERTIFICATE pThis, PRTERRINFO pErrInfo);
|
---|
977 |
|
---|
978 |
|
---|
979 | /**
|
---|
980 | * One X.509 Certificate (IPRT representation).
|
---|
981 | */
|
---|
982 | typedef struct RTCRX509CERTIFICATE
|
---|
983 | {
|
---|
984 | /** Sequence core. */
|
---|
985 | RTASN1SEQUENCECORE SeqCore;
|
---|
986 | /** The to-be-signed certificate information. */
|
---|
987 | RTCRX509TBSCERTIFICATE TbsCertificate;
|
---|
988 | /** The signature algorithm (must match TbsCertificate.Signature). */
|
---|
989 | RTCRX509ALGORITHMIDENTIFIER SignatureAlgorithm;
|
---|
990 | /** The signature value. */
|
---|
991 | RTASN1BITSTRING SignatureValue;
|
---|
992 | } RTCRX509CERTIFICATE;
|
---|
993 | /** Pointer to the IPRT representation of one X.509 certificate. */
|
---|
994 | typedef RTCRX509CERTIFICATE *PRTCRX509CERTIFICATE;
|
---|
995 | /** Pointer to the const IPRT representation of one X.509 certificate. */
|
---|
996 | typedef RTCRX509CERTIFICATE const *PCRTCRX509CERTIFICATE;
|
---|
997 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRX509CERTIFICATE, RTDECL, RTCrX509Certificate, SeqCore.Asn1Core);
|
---|
998 |
|
---|
999 | /**
|
---|
1000 | * Checks if a certificate matches a given issuer name and serial number.
|
---|
1001 | *
|
---|
1002 | * @returns True / false.
|
---|
1003 | * @param pCertificate The X.509 certificat.
|
---|
1004 | * @param pIssuer The issuer name to match against.
|
---|
1005 | * @param pSerialNumber The serial number to match against.
|
---|
1006 | */
|
---|
1007 | RTDECL(bool) RTCrX509Certificate_MatchIssuerAndSerialNumber(PCRTCRX509CERTIFICATE pCertificate,
|
---|
1008 | PCRTCRX509NAME pIssuer, PCRTASN1INTEGER pSerialNumber);
|
---|
1009 |
|
---|
1010 | RTDECL(bool) RTCrX509Certificate_MatchSubjectOrAltSubjectByRfc5280(PCRTCRX509CERTIFICATE pThis, PCRTCRX509NAME pName);
|
---|
1011 | RTDECL(bool) RTCrX509Certificate_IsSelfSigned(PCRTCRX509CERTIFICATE pCertificate);
|
---|
1012 |
|
---|
1013 | RTDECL(int) RTCrX509Certificate_VerifySignature(PCRTCRX509CERTIFICATE pThis, PCRTASN1OBJID pAlgorithm,
|
---|
1014 | PCRTASN1DYNTYPE pParameters, PCRTASN1BITSTRING pPublicKey,
|
---|
1015 | PRTERRINFO pErrInfo);
|
---|
1016 | RTDECL(int) RTCrX509Certificate_VerifySignatureSelfSigned(PCRTCRX509CERTIFICATE pThis, PRTERRINFO pErrInfo);
|
---|
1017 | RTDECL(int) RTCrX509Certificate_ReadFromFile(PRTCRX509CERTIFICATE pCertificate, const char *pszFilename, uint32_t fFlags,
|
---|
1018 | PCRTASN1ALLOCATORVTABLE pAllocator, PRTERRINFO pErrInfo);
|
---|
1019 | RTDECL(int) RTCrX509Certificate_ReadFromBuffer(PRTCRX509CERTIFICATE pCertificate, const void *pvBuf, size_t cbBuf,
|
---|
1020 | uint32_t fFlags, PCRTASN1ALLOCATORVTABLE pAllocator,
|
---|
1021 | PRTERRINFO pErrInfo, const char *pszErrorTag);
|
---|
1022 | /** @name Flags for RTCrX509Certificate_ReadFromFile and
|
---|
1023 | * RTCrX509Certificate_ReadFromBuffer
|
---|
1024 | * @{ */
|
---|
1025 | /** Only allow PEM certificates, not binary ones.
|
---|
1026 | * @sa RTCRPEMREADFILE_F_ONLY_PEM */
|
---|
1027 | #define RTCRX509CERT_READ_F_PEM_ONLY RT_BIT(1)
|
---|
1028 | /** @} */
|
---|
1029 |
|
---|
1030 | /** X509 Certificate markers for RTCrPemFindFirstSectionInContent et al. */
|
---|
1031 | extern RTDATADECL(RTCRPEMMARKER const) g_aRTCrX509CertificateMarkers[];
|
---|
1032 | /** Number of entries in g_aRTCrX509CertificateMarkers. */
|
---|
1033 | extern RTDATADECL(uint32_t const) g_cRTCrX509CertificateMarkers;
|
---|
1034 |
|
---|
1035 |
|
---|
1036 |
|
---|
1037 | /** @name X.509 Certificate Extensions
|
---|
1038 | * @{ */
|
---|
1039 | /** Old AuthorityKeyIdentifier OID. */
|
---|
1040 | #define RTCRX509_ID_CE_OLD_AUTHORITY_KEY_IDENTIFIER_OID "2.5.29.1"
|
---|
1041 | /** Old CertificatePolicies extension OID. */
|
---|
1042 | #define RTCRX509_ID_CE_OLD_CERTIFICATE_POLICIES_OID "2.5.29.3"
|
---|
1043 | /** Old SubjectAltName extension OID. */
|
---|
1044 | #define RTCRX509_ID_CE_OLD_SUBJECT_ALT_NAME_OID "2.5.29.7"
|
---|
1045 | /** Old IssuerAltName extension OID. */
|
---|
1046 | #define RTCRX509_ID_CE_OLD_ISSUER_ALT_NAME_OID "2.5.29.8"
|
---|
1047 | /** Old BasicContraints extension OID. */
|
---|
1048 | #define RTCRX509_ID_CE_OLD_BASIC_CONSTRAINTS_OID "2.5.29.10"
|
---|
1049 | /** SubjectKeyIdentifier OID. */
|
---|
1050 | #define RTCRX509_ID_CE_SUBJECT_KEY_IDENTIFIER_OID "2.5.29.14"
|
---|
1051 | /** KeyUsage OID. */
|
---|
1052 | #define RTCRX509_ID_CE_KEY_USAGE_OID "2.5.29.15"
|
---|
1053 | /** PrivateKeyUsagePeriod OID. */
|
---|
1054 | #define RTCRX509_ID_CE_PRIVATE_KEY_USAGE_PERIOD_OID "2.5.29.16"
|
---|
1055 | /** SubjectAltName extension OID. */
|
---|
1056 | #define RTCRX509_ID_CE_SUBJECT_ALT_NAME_OID "2.5.29.17"
|
---|
1057 | /** IssuerAltName extension OID. */
|
---|
1058 | #define RTCRX509_ID_CE_ISSUER_ALT_NAME_OID "2.5.29.18"
|
---|
1059 | /** BasicContraints extension OID. */
|
---|
1060 | #define RTCRX509_ID_CE_BASIC_CONSTRAINTS_OID "2.5.29.19"
|
---|
1061 | /** NameContraints extension OID. */
|
---|
1062 | #define RTCRX509_ID_CE_NAME_CONSTRAINTS_OID "2.5.29.30"
|
---|
1063 | /** CertificatePolicies extension OID. */
|
---|
1064 | #define RTCRX509_ID_CE_CERTIFICATE_POLICIES_OID "2.5.29.32"
|
---|
1065 | /** PolicyMappings extension OID. */
|
---|
1066 | #define RTCRX509_ID_CE_POLICY_MAPPINGS_OID "2.5.29.33"
|
---|
1067 | /** AuthorityKeyIdentifier OID. */
|
---|
1068 | #define RTCRX509_ID_CE_AUTHORITY_KEY_IDENTIFIER_OID "2.5.29.35"
|
---|
1069 | /** PolicyContraints extension OID. */
|
---|
1070 | #define RTCRX509_ID_CE_POLICY_CONSTRAINTS_OID "2.5.29.36"
|
---|
1071 | /** ExtKeyUsage (extended key usage) extension OID. */
|
---|
1072 | #define RTCRX509_ID_CE_EXT_KEY_USAGE_OID "2.5.29.37"
|
---|
1073 | /** ExtKeyUsage: OID for permitting any unspecified key usage. */
|
---|
1074 | #define RTCRX509_ID_CE_ANY_EXTENDED_KEY_USAGE_OID "2.5.29.37.0"
|
---|
1075 | /** AuthorityAttributeIdentifier OID. */
|
---|
1076 | #define RTCRX509_ID_CE_AUTHORITY_ATTRIBUTE_IDENTIFIER_OID "2.5.29.38"
|
---|
1077 | /** AcceptableCertPolicies OID. */
|
---|
1078 | #define RTCRX509_ID_CE_ACCEPTABLE_CERT_POLICIES_OID "2.5.29.52"
|
---|
1079 | /** InhibitAnyPolicy OID. */
|
---|
1080 | #define RTCRX509_ID_CE_INHIBIT_ANY_POLICY_OID "2.5.29.54"
|
---|
1081 | /** @} */
|
---|
1082 |
|
---|
1083 |
|
---|
1084 | /*
|
---|
1085 | * Sequence of X.509 Certifcates (IPRT representation).
|
---|
1086 | */
|
---|
1087 | RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTCRX509CERTIFICATES, RTCRX509CERTIFICATE, RTDECL, RTCrX509Certificates);
|
---|
1088 |
|
---|
1089 | /**
|
---|
1090 | * Looks up a certificate by issuer name and serial number.
|
---|
1091 | *
|
---|
1092 | * @returns Pointer to the given certificate if found, NULL if not.
|
---|
1093 | * @param pCertificates The X.509 certificate set to search.
|
---|
1094 | * @param pIssuer The issuer name of the wanted certificate.
|
---|
1095 | * @param pSerialNumber The serial number of the wanted certificate.
|
---|
1096 | */
|
---|
1097 | RTDECL(PCRTCRX509CERTIFICATE) RTCrX509Certificates_FindByIssuerAndSerialNumber(PCRTCRX509CERTIFICATES pCertificates,
|
---|
1098 | PCRTCRX509NAME pIssuer,
|
---|
1099 | PCRTASN1INTEGER pSerialNumber);
|
---|
1100 |
|
---|
1101 |
|
---|
1102 |
|
---|
1103 | RTDECL(int) RTCrX509CertPathsCreate(PRTCRX509CERTPATHS phCertPaths, PCRTCRX509CERTIFICATE pTarget);
|
---|
1104 | RTDECL(uint32_t) RTCrX509CertPathsRetain(RTCRX509CERTPATHS hCertPaths);
|
---|
1105 | RTDECL(uint32_t) RTCrX509CertPathsRelease(RTCRX509CERTPATHS hCertPaths);
|
---|
1106 | RTDECL(int) RTCrX509CertPathsSetTrustedStore(RTCRX509CERTPATHS hCertPaths, RTCRSTORE hTrustedStore);
|
---|
1107 | RTDECL(int) RTCrX509CertPathsSetUntrustedStore(RTCRX509CERTPATHS hCertPaths, RTCRSTORE hUntrustedStore);
|
---|
1108 | RTDECL(int) RTCrX509CertPathsSetUntrustedArray(RTCRX509CERTPATHS hCertPaths, PCRTCRX509CERTIFICATE paCerts, uint32_t cCerts);
|
---|
1109 | RTDECL(int) RTCrX509CertPathsSetUntrustedSet(RTCRX509CERTPATHS hCertPaths, struct RTCRPKCS7SETOFCERTS const *pSetOfCerts);
|
---|
1110 | RTDECL(int) RTCrX509CertPathsSetValidTime(RTCRX509CERTPATHS hCertPaths, PCRTTIME pTime);
|
---|
1111 | RTDECL(int) RTCrX509CertPathsSetValidTimeSpec(RTCRX509CERTPATHS hCertPaths, PCRTTIMESPEC pTimeSpec);
|
---|
1112 | RTDECL(int) RTCrX509CertPathsCreateEx(PRTCRX509CERTPATHS phCertPaths, PCRTCRX509CERTIFICATE pTarget, RTCRSTORE hTrustedStore,
|
---|
1113 | RTCRSTORE hUntrustedStore, PCRTCRX509CERTIFICATE paUntrustedCerts, uint32_t cUntrustedCerts,
|
---|
1114 | PCRTTIMESPEC pValidTime);
|
---|
1115 | RTDECL(int) RTCrX509CertPathsBuild(RTCRX509CERTPATHS hCertPaths, PRTERRINFO pErrInfo);
|
---|
1116 | RTDECL(int) RTCrX509CertPathsDumpOne(RTCRX509CERTPATHS hCertPaths, uint32_t iPath, uint32_t uVerbosity,
|
---|
1117 | PFNRTDUMPPRINTFV pfnPrintfV, void *pvUser);
|
---|
1118 | RTDECL(int) RTCrX509CertPathsDumpAll(RTCRX509CERTPATHS hCertPaths, uint32_t uVerbosity,
|
---|
1119 | PFNRTDUMPPRINTFV pfnPrintfV, void *pvUser);
|
---|
1120 |
|
---|
1121 | RTDECL(int) RTCrX509CertPathsValidateOne(RTCRX509CERTPATHS hCertPaths, uint32_t iPath, PRTERRINFO pErrInfo);
|
---|
1122 | RTDECL(int) RTCrX509CertPathsValidateAll(RTCRX509CERTPATHS hCertPaths, uint32_t *pcValidPaths, PRTERRINFO pErrInfo);
|
---|
1123 |
|
---|
1124 | RTDECL(uint32_t) RTCrX509CertPathsGetPathCount(RTCRX509CERTPATHS hCertPaths);
|
---|
1125 | RTDECL(int) RTCrX509CertPathsQueryPathInfo(RTCRX509CERTPATHS hCertPaths, uint32_t iPath,
|
---|
1126 | bool *pfTrusted, uint32_t *pcNodes, PCRTCRX509NAME *ppSubject,
|
---|
1127 | PCRTCRX509SUBJECTPUBLICKEYINFO *ppPublicKeyInfo,
|
---|
1128 | PCRTCRX509CERTIFICATE *ppCert, PCRTCRCERTCTX *ppCertCtx, int *prcVerify);
|
---|
1129 | RTDECL(uint32_t) RTCrX509CertPathsGetPathLength(RTCRX509CERTPATHS hCertPaths, uint32_t iPath);
|
---|
1130 | RTDECL(int) RTCrX509CertPathsGetPathVerifyResult(RTCRX509CERTPATHS hCertPaths, uint32_t iPath);
|
---|
1131 | RTDECL(PCRTCRX509CERTIFICATE) RTCrX509CertPathsGetPathNodeCert(RTCRX509CERTPATHS hCertPaths, uint32_t iPath, uint32_t iNode);
|
---|
1132 |
|
---|
1133 |
|
---|
1134 | RT_C_DECLS_END
|
---|
1135 |
|
---|
1136 | /** @} */
|
---|
1137 |
|
---|
1138 | /** @} */
|
---|
1139 |
|
---|
1140 | #endif /* !IPRT_INCLUDED_crypto_x509_h */
|
---|
1141 |
|
---|