]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cssm/lib/x509defs.h
Security-58286.260.20.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
73 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_algorithm_identifier {
74 CSSM_OID algorithm;
75 CSSM_DATA parameters;
76 } CSSM_X509_ALGORITHM_IDENTIFIER DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_ALGORITHM_IDENTIFIER_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
77
78 /* X509 Distinguished name structure */
79 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_type_value_pair {
80 CSSM_OID type;
81 CSSM_BER_TAG valueType; /* The Tag to be used when */
82 /*this value is BER encoded */
83 CSSM_DATA value;
84 } 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;
85
86 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_rdn {
87 uint32 numberOfPairs;
88 CSSM_X509_TYPE_VALUE_PAIR_PTR AttributeTypeAndValue;
89 } 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;
90
91 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_name {
92 uint32 numberOfRDNs;
93 CSSM_X509_RDN_PTR RelativeDistinguishedName;
94 } 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;
95
96 /* Public key info struct */
97 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_subject_public_key_info {
98 CSSM_X509_ALGORITHM_IDENTIFIER algorithm;
99 CSSM_DATA subjectPublicKey;
100 } CSSM_X509_SUBJECT_PUBLIC_KEY_INFO DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_X509_SUBJECT_PUBLIC_KEY_INFO_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
101
102 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_time {
103 CSSM_BER_TAG timeType;
104 CSSM_DATA time;
105 } 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;
106
107 /* Validity struct */
108 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER x509_validity {
109 CSSM_X509_TIME notBefore;
110 CSSM_X509_TIME notAfter;
111 } 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;
112
113 #define CSSM_X509_OPTION_PRESENT CSSM_TRUE
114 #define CSSM_X509_OPTION_NOT_PRESENT CSSM_FALSE
115 typedef CSSM_BOOL CSSM_X509_OPTION;
116
117 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_basicConstraints {
118 CSSM_BOOL cA;
119 CSSM_X509_OPTION pathLenConstraintPresent;
120 uint32 pathLenConstraint;
121 } 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;
122
123 typedef enum extension_data_format {
124 CSSM_X509_DATAFORMAT_ENCODED = 0,
125 CSSM_X509_DATAFORMAT_PARSED,
126 CSSM_X509_DATAFORMAT_PAIR
127 } CSSM_X509EXT_DATA_FORMAT;
128
129 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_extensionTagAndValue {
130 CSSM_BER_TAG type;
131 CSSM_DATA value;
132 } 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;
133
134 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_pair {
135 CSSM_X509EXT_TAGandVALUE tagAndValue;
136 void *parsedValue;
137 } 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;
138
139 /* Extension structure */
140 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_extension {
141 CSSM_OID extnId;
142 CSSM_BOOL critical;
143 CSSM_X509EXT_DATA_FORMAT format;
144 union DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_value {
145 CSSM_X509EXT_TAGandVALUE *tagAndValue;
146 void *parsedValue;
147 CSSM_X509EXT_PAIR *valuePair;
148 } value;
149 CSSM_DATA BERvalue;
150 } 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;
151
152 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_extensions {
153 uint32 numberOfExtensions;
154 CSSM_X509_EXTENSION_PTR extensions;
155 } 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;
156
157 /* X509V3 certificate structure */
158 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_tbs_certificate {
159 CSSM_DATA version;
160 CSSM_DATA serialNumber;
161 CSSM_X509_ALGORITHM_IDENTIFIER signature;
162 CSSM_X509_NAME issuer;
163 CSSM_X509_VALIDITY validity;
164 CSSM_X509_NAME subject;
165 CSSM_X509_SUBJECT_PUBLIC_KEY_INFO subjectPublicKeyInfo;
166 CSSM_DATA issuerUniqueIdentifier;
167 CSSM_DATA subjectUniqueIdentifier;
168 CSSM_X509_EXTENSIONS extensions;
169 } 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;
170
171 /* Signature structure */
172 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_signature {
173 CSSM_X509_ALGORITHM_IDENTIFIER algorithmIdentifier;
174 CSSM_DATA encrypted;
175 } 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;
176
177 /* Signed certificate structure */
178 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_signed_certificate {
179 CSSM_X509_TBS_CERTIFICATE certificate;
180 CSSM_X509_SIGNATURE signature;
181 } 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;
182
183 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_policyQualifierInfo {
184 CSSM_OID policyQualifierId;
185 CSSM_DATA value;
186 } 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;
187
188 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_policyQualifiers {
189 uint32 numberOfPolicyQualifiers;
190 CSSM_X509EXT_POLICYQUALIFIERINFO *policyQualifier;
191 } 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;
192
193 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509ext_policyInfo {
194 CSSM_OID policyIdentifier;
195 CSSM_X509EXT_POLICYQUALIFIERS policyQualifiers;
196 } 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;
197
198
199 /* Data Structures for X.509 Certificate Revocations Lists */
200
201 /* x509V2 entry in the CRL revokedCertificates sequence */
202 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_revoked_cert_entry {
203 CSSM_DATA certificateSerialNumber;
204 CSSM_X509_TIME revocationDate;
205 CSSM_X509_EXTENSIONS extensions;
206 } 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;
207
208 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_revoked_cert_list {
209 uint32 numberOfRevokedCertEntries;
210 CSSM_X509_REVOKED_CERT_ENTRY_PTR revokedCertEntry;
211 } 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;
212
213 /* x509v2 Certificate Revocation List (CRL) (unsigned) structure */
214 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_tbs_certlist {
215 CSSM_DATA version;
216 CSSM_X509_ALGORITHM_IDENTIFIER signature;
217 CSSM_X509_NAME issuer;
218 CSSM_X509_TIME thisUpdate;
219 CSSM_X509_TIME nextUpdate;
220 CSSM_X509_REVOKED_CERT_LIST_PTR revokedCertificates;
221 CSSM_X509_EXTENSIONS extensions;
222 } 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;
223
224 typedef struct DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER cssm_x509_signed_crl {
225 CSSM_X509_TBS_CERTLIST tbsCertList;
226 CSSM_X509_SIGNATURE signature;
227 } 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;
228
229 #pragma clang diagnostic pop
230
231 #ifdef __cplusplus
232 }
233 #endif
234
235 #endif /* _X509DEFS_H_ */