]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cssm/lib/x509defs.h
Security-59306.120.7.tar.gz
[apple/security.git] / OSX / libsecurity_cssm / lib / x509defs.h
1 /*
2 * Copyright (c) 1999-2002,2004,2011,2014 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 *
23 * x509defs.h -- Data structures for X509 Certificate Library field values
24 */
25
26 #ifndef _X509DEFS_H_
27 #define _X509DEFS_H_ 1
28
29 #include <Security/cssmtype.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #pragma clang diagnostic push
36 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
37
38 typedef uint8 CSSM_BER_TAG;
39 #define BER_TAG_UNKNOWN 0
40 #define BER_TAG_BOOLEAN 1
41 #define BER_TAG_INTEGER 2
42 #define BER_TAG_BIT_STRING 3
43 #define BER_TAG_OCTET_STRING 4
44 #define BER_TAG_NULL 5
45 #define BER_TAG_OID 6
46 #define BER_TAG_OBJECT_DESCRIPTOR 7
47 #define BER_TAG_EXTERNAL 8
48 #define BER_TAG_REAL 9
49 #define BER_TAG_ENUMERATED 10
50 /* 12 to 15 are reserved for future versions of the recommendation */
51 #define BER_TAG_PKIX_UTF8_STRING 12
52 #define BER_TAG_SEQUENCE 16
53 #define BER_TAG_SET 17
54 #define BER_TAG_NUMERIC_STRING 18
55 #define BER_TAG_PRINTABLE_STRING 19
56 #define BER_TAG_T61_STRING 20
57 #define BER_TAG_TELETEX_STRING BER_TAG_T61_STRING
58 #define BER_TAG_VIDEOTEX_STRING 21
59 #define BER_TAG_IA5_STRING 22
60 #define BER_TAG_UTC_TIME 23
61 #define BER_TAG_GENERALIZED_TIME 24
62 #define BER_TAG_GRAPHIC_STRING 25
63 #define BER_TAG_ISO646_STRING 26
64 #define BER_TAG_GENERAL_STRING 27
65 #define BER_TAG_VISIBLE_STRING BER_TAG_ISO646_STRING
66 /* 28 - are reserved for future versions of the recommendation */
67 #define BER_TAG_PKIX_UNIVERSAL_STRING 28
68 #define BER_TAG_PKIX_BMP_STRING 30
69
70
71 /* Data Structures for X.509 Certificates */
72 #define CSSM_X509_ALGORITHM_IDENTIFIER SecAsn1AlgId
73 typedef SecAsn1AlgId *CSSM_X509_ALGORITHM_IDENTIFIER_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
74
75 /* X509 Distinguished name structure */
76 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_type_value_pair {
77 CSSM_OID type;
78 CSSM_BER_TAG valueType; /* The Tag to be used when */
79 /*this value is BER encoded */
80 CSSM_DATA value;
81 } CSSM_X509_TYPE_VALUE_PAIR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_TYPE_VALUE_PAIR_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
82
83 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_rdn {
84 uint32 numberOfPairs;
85 CSSM_X509_TYPE_VALUE_PAIR_PTR AttributeTypeAndValue;
86 } CSSM_X509_RDN DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_RDN_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
87
88 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_name {
89 uint32 numberOfRDNs;
90 CSSM_X509_RDN_PTR RelativeDistinguishedName;
91 } CSSM_X509_NAME DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_NAME_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
92
93 /* Public key info struct */
94 #define CSSM_X509_SUBJECT_PUBLIC_KEY_INFO SecAsn1PubKeyInfo
95 typedef SecAsn1PubKeyInfo *CSSM_X509_SUBJECT_PUBLIC_KEY_INFO_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
96
97 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_time {
98 CSSM_BER_TAG timeType;
99 CSSM_DATA time;
100 } CSSM_X509_TIME DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_TIME_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
101
102 /* Validity struct */
103 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER x509_validity {
104 CSSM_X509_TIME notBefore;
105 CSSM_X509_TIME notAfter;
106 } CSSM_X509_VALIDITY DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_VALIDITY_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
107
108 #define CSSM_X509_OPTION_PRESENT CSSM_TRUE
109 #define CSSM_X509_OPTION_NOT_PRESENT CSSM_FALSE
110 typedef CSSM_BOOL CSSM_X509_OPTION;
111
112 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_basicConstraints {
113 CSSM_BOOL cA;
114 CSSM_X509_OPTION pathLenConstraintPresent;
115 uint32 pathLenConstraint;
116 } CSSM_X509EXT_BASICCONSTRAINTS DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509EXT_BASICCONSTRAINTS_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
117
118 typedef enum extension_data_format {
119 CSSM_X509_DATAFORMAT_ENCODED = 0,
120 CSSM_X509_DATAFORMAT_PARSED,
121 CSSM_X509_DATAFORMAT_PAIR
122 } CSSM_X509EXT_DATA_FORMAT;
123
124 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_extensionTagAndValue {
125 CSSM_BER_TAG type;
126 CSSM_DATA value;
127 } CSSM_X509EXT_TAGandVALUE DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509EXT_TAGandVALUE_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
128
129 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_pair {
130 CSSM_X509EXT_TAGandVALUE tagAndValue;
131 void *parsedValue;
132 } CSSM_X509EXT_PAIR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509EXT_PAIR_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
133
134 /* Extension structure */
135 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_extension {
136 CSSM_OID extnId;
137 CSSM_BOOL critical;
138 CSSM_X509EXT_DATA_FORMAT format;
139 union DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_value {
140 CSSM_X509EXT_TAGandVALUE *tagAndValue;
141 void *parsedValue;
142 CSSM_X509EXT_PAIR *valuePair;
143 } value;
144 CSSM_DATA BERvalue;
145 } CSSM_X509_EXTENSION DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_EXTENSION_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
146
147 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_extensions {
148 uint32 numberOfExtensions;
149 CSSM_X509_EXTENSION_PTR extensions;
150 } CSSM_X509_EXTENSIONS DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_EXTENSIONS_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
151
152 /* X509V3 certificate structure */
153 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_tbs_certificate {
154 CSSM_DATA version;
155 CSSM_DATA serialNumber;
156 CSSM_X509_ALGORITHM_IDENTIFIER signature;
157 CSSM_X509_NAME issuer;
158 CSSM_X509_VALIDITY validity;
159 CSSM_X509_NAME subject;
160 CSSM_X509_SUBJECT_PUBLIC_KEY_INFO subjectPublicKeyInfo;
161 CSSM_DATA issuerUniqueIdentifier;
162 CSSM_DATA subjectUniqueIdentifier;
163 CSSM_X509_EXTENSIONS extensions;
164 } CSSM_X509_TBS_CERTIFICATE DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_TBS_CERTIFICATE_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
165
166 /* Signature structure */
167 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_signature {
168 CSSM_X509_ALGORITHM_IDENTIFIER algorithmIdentifier;
169 CSSM_DATA encrypted;
170 } CSSM_X509_SIGNATURE DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_SIGNATURE_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
171
172 /* Signed certificate structure */
173 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_signed_certificate {
174 CSSM_X509_TBS_CERTIFICATE certificate;
175 CSSM_X509_SIGNATURE signature;
176 } CSSM_X509_SIGNED_CERTIFICATE DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_SIGNED_CERTIFICATE_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
177
178 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_policyQualifierInfo {
179 CSSM_OID policyQualifierId;
180 CSSM_DATA value;
181 } CSSM_X509EXT_POLICYQUALIFIERINFO DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509EXT_POLICYQUALIFIERINFO_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
182
183 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_policyQualifiers {
184 uint32 numberOfPolicyQualifiers;
185 CSSM_X509EXT_POLICYQUALIFIERINFO *policyQualifier;
186 } CSSM_X509EXT_POLICYQUALIFIERS DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509EXT_POLICYQUALIFIERS_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
187
188 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_policyInfo {
189 CSSM_OID policyIdentifier;
190 CSSM_X509EXT_POLICYQUALIFIERS policyQualifiers;
191 } CSSM_X509EXT_POLICYINFO DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509EXT_POLICYINFO_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
192
193
194 /* Data Structures for X.509 Certificate Revocations Lists */
195
196 /* x509V2 entry in the CRL revokedCertificates sequence */
197 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_revoked_cert_entry {
198 CSSM_DATA certificateSerialNumber;
199 CSSM_X509_TIME revocationDate;
200 CSSM_X509_EXTENSIONS extensions;
201 } CSSM_X509_REVOKED_CERT_ENTRY DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_REVOKED_CERT_ENTRY_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
202
203 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_revoked_cert_list {
204 uint32 numberOfRevokedCertEntries;
205 CSSM_X509_REVOKED_CERT_ENTRY_PTR revokedCertEntry;
206 } CSSM_X509_REVOKED_CERT_LIST DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_REVOKED_CERT_LIST_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
207
208 /* x509v2 Certificate Revocation List (CRL) (unsigned) structure */
209 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_tbs_certlist {
210 CSSM_DATA version;
211 CSSM_X509_ALGORITHM_IDENTIFIER signature;
212 CSSM_X509_NAME issuer;
213 CSSM_X509_TIME thisUpdate;
214 CSSM_X509_TIME nextUpdate;
215 CSSM_X509_REVOKED_CERT_LIST_PTR revokedCertificates;
216 CSSM_X509_EXTENSIONS extensions;
217 } CSSM_X509_TBS_CERTLIST DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_TBS_CERTLIST_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
218
219 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_signed_crl {
220 CSSM_X509_TBS_CERTLIST tbsCertList;
221 CSSM_X509_SIGNATURE signature;
222 } CSSM_X509_SIGNED_CRL DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_SIGNED_CRL_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
223
224 #pragma clang diagnostic pop
225
226 #ifdef __cplusplus
227 }
228 #endif
229
230 #endif /* _X509DEFS_H_ */