VirtualBox

source: vbox/trunk/include/iprt/crypto/x509.h@ 84379

Last change on this file since 84379 was 84379, checked in by vboxsync, 5 years ago

IPRT/RTCrX509CertPaths: Hacked the code to accept trusted targets. Added option trust anchor checks. bugref:9699

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette