]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cssm/lib/x509defs.h
Security-57336.1.9.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 typedef uint8 CSSM_BER_TAG;
36 #define BER_TAG_UNKNOWN 0
37 #define BER_TAG_BOOLEAN 1
38 #define BER_TAG_INTEGER 2
39 #define BER_TAG_BIT_STRING 3
40 #define BER_TAG_OCTET_STRING 4
41 #define BER_TAG_NULL 5
42 #define BER_TAG_OID 6
43 #define BER_TAG_OBJECT_DESCRIPTOR 7
44 #define BER_TAG_EXTERNAL 8
45 #define BER_TAG_REAL 9
46 #define BER_TAG_ENUMERATED 10
47 /* 12 to 15 are reserved for future versions of the recommendation */
48 #define BER_TAG_PKIX_UTF8_STRING 12
49 #define BER_TAG_SEQUENCE 16
50 #define BER_TAG_SET 17
51 #define BER_TAG_NUMERIC_STRING 18
52 #define BER_TAG_PRINTABLE_STRING 19
53 #define BER_TAG_T61_STRING 20
54 #define BER_TAG_TELETEX_STRING BER_TAG_T61_STRING
55 #define BER_TAG_VIDEOTEX_STRING 21
56 #define BER_TAG_IA5_STRING 22
57 #define BER_TAG_UTC_TIME 23
58 #define BER_TAG_GENERALIZED_TIME 24
59 #define BER_TAG_GRAPHIC_STRING 25
60 #define BER_TAG_ISO646_STRING 26
61 #define BER_TAG_GENERAL_STRING 27
62 #define BER_TAG_VISIBLE_STRING BER_TAG_ISO646_STRING
63 /* 28 - are reserved for future versions of the recommendation */
64 #define BER_TAG_PKIX_UNIVERSAL_STRING 28
65 #define BER_TAG_PKIX_BMP_STRING 30
66
67
68 /* Data Structures for X.509 Certificates */
69
70 typedef struct cssm_x509_algorithm_identifier {
71 CSSM_OID algorithm;
72 CSSM_DATA parameters;
73 } 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;
74
75 /* X509 Distinguished name structure */
76 typedef struct 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 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 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 typedef struct cssm_x509_subject_public_key_info {
95 CSSM_X509_ALGORITHM_IDENTIFIER algorithm;
96 CSSM_DATA subjectPublicKey;
97 } 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;
98
99 typedef struct cssm_x509_time {
100 CSSM_BER_TAG timeType;
101 CSSM_DATA time;
102 } 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;
103
104 /* Validity struct */
105 typedef struct x509_validity {
106 CSSM_X509_TIME notBefore;
107 CSSM_X509_TIME notAfter;
108 } 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;
109
110 #define CSSM_X509_OPTION_PRESENT CSSM_TRUE
111 #define CSSM_X509_OPTION_NOT_PRESENT CSSM_FALSE
112 typedef CSSM_BOOL CSSM_X509_OPTION;
113
114 typedef struct cssm_x509ext_basicConstraints {
115 CSSM_BOOL cA;
116 CSSM_X509_OPTION pathLenConstraintPresent;
117 uint32 pathLenConstraint;
118 } 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;
119
120 typedef enum extension_data_format {
121 CSSM_X509_DATAFORMAT_ENCODED = 0,
122 CSSM_X509_DATAFORMAT_PARSED,
123 CSSM_X509_DATAFORMAT_PAIR
124 } CSSM_X509EXT_DATA_FORMAT;
125
126 typedef struct cssm_x509_extensionTagAndValue {
127 CSSM_BER_TAG type;
128 CSSM_DATA value;
129 } 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;
130
131 typedef struct cssm_x509ext_pair {
132 CSSM_X509EXT_TAGandVALUE tagAndValue;
133 void *parsedValue;
134 } 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;
135
136 /* Extension structure */
137 typedef struct cssm_x509_extension {
138 CSSM_OID extnId;
139 CSSM_BOOL critical;
140 CSSM_X509EXT_DATA_FORMAT format;
141 union cssm_x509ext_value {
142 CSSM_X509EXT_TAGandVALUE *tagAndValue;
143 void *parsedValue;
144 CSSM_X509EXT_PAIR *valuePair;
145 } value;
146 CSSM_DATA BERvalue;
147 } 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;
148
149 typedef struct cssm_x509_extensions {
150 uint32 numberOfExtensions;
151 CSSM_X509_EXTENSION_PTR extensions;
152 } 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;
153
154 /* X509V3 certificate structure */
155 typedef struct cssm_x509_tbs_certificate {
156 CSSM_DATA version;
157 CSSM_DATA serialNumber;
158 CSSM_X509_ALGORITHM_IDENTIFIER signature;
159 CSSM_X509_NAME issuer;
160 CSSM_X509_VALIDITY validity;
161 CSSM_X509_NAME subject;
162 CSSM_X509_SUBJECT_PUBLIC_KEY_INFO subjectPublicKeyInfo;
163 CSSM_DATA issuerUniqueIdentifier;
164 CSSM_DATA subjectUniqueIdentifier;
165 CSSM_X509_EXTENSIONS extensions;
166 } 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;
167
168 /* Signature structure */
169 typedef struct cssm_x509_signature {
170 CSSM_X509_ALGORITHM_IDENTIFIER algorithmIdentifier;
171 CSSM_DATA encrypted;
172 } 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;
173
174 /* Signed certificate structure */
175 typedef struct cssm_x509_signed_certificate {
176 CSSM_X509_TBS_CERTIFICATE certificate;
177 CSSM_X509_SIGNATURE signature;
178 } 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;
179
180 typedef struct cssm_x509ext_policyQualifierInfo {
181 CSSM_OID policyQualifierId;
182 CSSM_DATA value;
183 } 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;
184
185 typedef struct cssm_x509ext_policyQualifiers {
186 uint32 numberOfPolicyQualifiers;
187 CSSM_X509EXT_POLICYQUALIFIERINFO *policyQualifier;
188 } 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;
189
190 typedef struct cssm_x509ext_policyInfo {
191 CSSM_OID policyIdentifier;
192 CSSM_X509EXT_POLICYQUALIFIERS policyQualifiers;
193 } 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;
194
195
196 /* Data Structures for X.509 Certificate Revocations Lists */
197
198 /* x509V2 entry in the CRL revokedCertificates sequence */
199 typedef struct cssm_x509_revoked_cert_entry {
200 CSSM_DATA certificateSerialNumber;
201 CSSM_X509_TIME revocationDate;
202 CSSM_X509_EXTENSIONS extensions;
203 } 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;
204
205 typedef struct cssm_x509_revoked_cert_list {
206 uint32 numberOfRevokedCertEntries;
207 CSSM_X509_REVOKED_CERT_ENTRY_PTR revokedCertEntry;
208 } 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;
209
210 /* x509v2 Certificate Revocation List (CRL) (unsigned) structure */
211 typedef struct cssm_x509_tbs_certlist {
212 CSSM_DATA version;
213 CSSM_X509_ALGORITHM_IDENTIFIER signature;
214 CSSM_X509_NAME issuer;
215 CSSM_X509_TIME thisUpdate;
216 CSSM_X509_TIME nextUpdate;
217 CSSM_X509_REVOKED_CERT_LIST_PTR revokedCertificates;
218 CSSM_X509_EXTENSIONS extensions;
219 } 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;
220
221 typedef struct cssm_x509_signed_crl {
222 CSSM_X509_TBS_CERTLIST tbsCertList;
223 CSSM_X509_SIGNATURE signature;
224 } 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;
225
226 #ifdef __cplusplus
227 }
228 #endif
229
230 #endif /* _X509DEFS_H_ */