]> git.saurik.com Git - apple/security.git/blob - libsecurity_cssm/lib/cssmapple.h
Security-55163.44.tar.gz
[apple/security.git] / libsecurity_cssm / lib / cssmapple.h
1 /*
2 * Copyright (c) 2000-2004 Apple Computer, 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 * cssmapple.h -- CSSM features specific to Apple's Implementation
24 */
25
26 #ifndef _CSSMAPPLE_H_
27 #define _CSSMAPPLE_H_ 1
28
29 #include <Security/cssmerr.h>
30 #include <Security/cssmtype.h>
31 #include <Security/x509defs.h> /* for CSSM_APPLE_TP_CERT_REQUEST fields */
32 #include <Security/certextensions.h> /* ditto */
33 #include <sys/types.h> /* for the BSD *_t types */
34 #include <stdbool.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /* Guids for standard Apple addin modules. */
41
42 /* CSSM itself: {87191ca0-0fc9-11d4-849a-000502b52122} */
43 extern const CSSM_GUID gGuidCssm;
44
45 /* File based DL (aka "Keychain DL"): {87191ca1-0fc9-11d4-849a-000502b52122} */
46 extern const CSSM_GUID gGuidAppleFileDL;
47
48 /* Core CSP (local space): {87191ca2-0fc9-11d4-849a-000502b52122} */
49 extern const CSSM_GUID gGuidAppleCSP;
50
51 /* Secure CSP/DL (aka "Keychain CSPDL): {87191ca3-0fc9-11d4-849a-000502b52122} */
52 extern const CSSM_GUID gGuidAppleCSPDL;
53
54 /* X509 Certificate CL: {87191ca4-0fc9-11d4-849a-000502b52122} */
55 extern const CSSM_GUID gGuidAppleX509CL;
56
57 /* X509 Certificate TP: {87191ca5-0fc9-11d4-849a-000502b52122} */
58 extern const CSSM_GUID gGuidAppleX509TP;
59
60 /* DLAP/OpenDirectory access DL: {87191ca6-0fc9-11d4-849a-000502b52122} */
61 extern const CSSM_GUID gGuidAppleLDAPDL;
62
63 /* TP for ".mac" related policies: {87191ca7-0fc9-11d4-849a-000502b52122} */
64 extern const CSSM_GUID gGuidAppleDotMacTP;
65
66 /* Smartcard CSP/DL: {87191ca8-0fc9-11d4-849a-000502b52122} */
67 extern const CSSM_GUID gGuidAppleSdCSPDL;
68
69 /* DL for ".mac" certificate access: {87191ca9-0fc9-11d4-849a-000502b52122} */
70 extern const CSSM_GUID gGuidAppleDotMacDL;
71
72
73 /* Apple defined WORDID values */
74 enum
75 {
76 CSSM_WORDID_KEYCHAIN_PROMPT = CSSM_WORDID_VENDOR_START,
77 CSSM_WORDID_KEYCHAIN_LOCK,
78 CSSM_WORDID_KEYCHAIN_CHANGE_LOCK,
79 CSSM_WORDID_PROCESS,
80 CSSM_WORDID__RESERVED_1, /* was used in 10.2 test seeds; no longer in use */
81 CSSM_WORDID_SYMMETRIC_KEY,
82 CSSM_WORDID_SYSTEM,
83 CSSM_WORDID_KEY,
84 CSSM_WORDID_PIN,
85 CSSM_WORDID_PREAUTH,
86 CSSM_WORDID_PREAUTH_SOURCE,
87 CSSM_WORDID_ASYMMETRIC_KEY,
88 CSSM_WORDID__FIRST_UNUSED
89 };
90
91 /* Apple defined ACL subject and credential types */
92 enum
93 {
94 CSSM_ACL_SUBJECT_TYPE_KEYCHAIN_PROMPT = CSSM_WORDID_KEYCHAIN_PROMPT,
95 CSSM_ACL_SUBJECT_TYPE_PROCESS = CSSM_WORDID_PROCESS,
96 CSSM_ACL_SUBJECT_TYPE_CODE_SIGNATURE = CSSM_WORDID_SIGNATURE,
97 CSSM_ACL_SUBJECT_TYPE_COMMENT = CSSM_WORDID_COMMENT,
98 CSSM_ACL_SUBJECT_TYPE_SYMMETRIC_KEY = CSSM_WORDID_SYMMETRIC_KEY,
99 CSSM_ACL_SUBJECT_TYPE_PREAUTH = CSSM_WORDID_PREAUTH,
100 CSSM_ACL_SUBJECT_TYPE_PREAUTH_SOURCE = CSSM_WORDID_PREAUTH_SOURCE,
101 CSSM_ACL_SUBJECT_TYPE_ASYMMETRIC_KEY = CSSM_WORDID_ASYMMETRIC_KEY
102 };
103
104 enum
105 {
106 CSSM_SAMPLE_TYPE_KEYCHAIN_PROMPT = CSSM_WORDID_KEYCHAIN_PROMPT,
107 CSSM_SAMPLE_TYPE_KEYCHAIN_LOCK = CSSM_WORDID_KEYCHAIN_LOCK,
108 CSSM_SAMPLE_TYPE_KEYCHAIN_CHANGE_LOCK = CSSM_WORDID_KEYCHAIN_CHANGE_LOCK,
109 CSSM_SAMPLE_TYPE_PROCESS = CSSM_WORDID_PROCESS,
110 CSSM_SAMPLE_TYPE_COMMENT = CSSM_WORDID_COMMENT,
111 CSSM_SAMPLE_TYPE_RETRY_ID = CSSM_WORDID_PROPAGATE,
112 CSSM_SAMPLE_TYPE_SYMMETRIC_KEY = CSSM_WORDID_SYMMETRIC_KEY,
113 CSSM_SAMPLE_TYPE_PREAUTH = CSSM_WORDID_PREAUTH,
114 CSSM_SAMPLE_TYPE_ASYMMETRIC_KEY = CSSM_WORDID_ASYMMETRIC_KEY
115 // there is no CSSM_SAMPLE_TYPE_PREAUTH_SOURCE
116 };
117
118
119 /* Apple-defined ACL authorization tags */
120 enum {
121 CSSM_ACL_AUTHORIZATION_CHANGE_ACL = CSSM_ACL_AUTHORIZATION_TAG_VENDOR_DEFINED_START,
122 CSSM_ACL_AUTHORIZATION_CHANGE_OWNER,
123
124 // the "pre-auth" tags form a contiguous range of (up to) 64K pre-authorizations
125 CSSM_ACL_AUTHORIZATION_PREAUTH_BASE =
126 CSSM_ACL_AUTHORIZATION_TAG_VENDOR_DEFINED_START + 0x1000000,
127 CSSM_ACL_AUTHORIZATION_PREAUTH_END = CSSM_ACL_AUTHORIZATION_PREAUTH_BASE + 0x10000
128 };
129
130 /* pre-authorization conversions (auth-tag to slot and back) */
131 #define CSSM_ACL_AUTHORIZATION_PREAUTH(slot) \
132 (CSSM_ACL_AUTHORIZATION_PREAUTH_BASE + (slot))
133 #define CSSM_ACL_AUTHORIZATION_PREAUTH_SLOT(auth) \
134 ((auth) - CSSM_ACL_AUTHORIZATION_PREAUTH_BASE)
135 #define CSSM_ACL_AUTHORIZATION_IS_PREAUTH(auth) \
136 ((auth) >= CSSM_ACL_AUTHORIZATION_PREAUTH_BASE && \
137 (auth) < CSSM_ACL_AUTHORIZATION_PREAUTH_END)
138
139
140 /* Parameters and structures for Apple-defined ACL subjects and samples */
141
142 enum { /* types of code signatures - item 1 of CSSM_ACL_SUBJECT_TYPE_CODE_SIGNATURE subjects */
143 CSSM_ACL_CODE_SIGNATURE_INVALID = 0, /* standard OS X code signature */
144 CSSM_ACL_CODE_SIGNATURE_OSX = 1 /* standard OS X code signature */
145 };
146
147 /* ACL subjects of type PROCESS */
148
149 enum { /* PROCESS_SUBJECT mask fields */
150 CSSM_ACL_MATCH_UID = 0x01, /* match userid against uid field */
151 CSSM_ACL_MATCH_GID = 0x02, /* match groupid against gid field */
152 CSSM_ACL_MATCH_HONOR_ROOT = 0x100, /* let root (uid 0) match any userid */
153 CSSM_ACL_MATCH_BITS = CSSM_ACL_MATCH_UID | CSSM_ACL_MATCH_GID
154 };
155
156 enum { /* PROCESS_SUBJECT structure version field */
157 CSSM_ACL_PROCESS_SELECTOR_CURRENT_VERSION = 0x101
158 };
159
160 typedef struct cssm_acl_process_subject_selector { /* PROCESS_SUBJECT selector */
161 uint16 version; /* version of this selector */
162 uint16 mask; /* active fields mask */
163 uint32 uid; /* effective user id match */
164 uint32 gid; /* effective group id match */
165 } CSSM_ACL_PROCESS_SUBJECT_SELECTOR;
166
167 /* ACL subjects of type KEYCHAIN_PROMPT */
168
169 enum { /* KEYCHAIN_PROMPT structure version field */
170 CSSM_ACL_KEYCHAIN_PROMPT_CURRENT_VERSION = 0x101
171 };
172
173 enum { /* KEYCHAIN_PROMPT operational flags */
174 CSSM_ACL_KEYCHAIN_PROMPT_REQUIRE_PASSPHRASE = 0x0001, /* require re-entering of passphrase */
175 /* the following bits are ignored by 10.4 and earlier */
176 CSSM_ACL_KEYCHAIN_PROMPT_UNSIGNED = 0x0010, /* prompt for unsigned clients */
177 CSSM_ACL_KEYCHAIN_PROMPT_UNSIGNED_ACT = 0x0020, /* UNSIGNED bit overrides system default */
178 CSSM_ACL_KEYCHAIN_PROMPT_INVALID = 0x0040, /* prompt for invalid signed clients */
179 CSSM_ACL_KEYCHAIN_PROMPT_INVALID_ACT = 0x0080, /* INVALID bit overrides system default */
180 };
181
182 typedef struct cssm_acl_keychain_prompt_selector { /* KEYCHAIN_PROMPT selector */
183 uint16 version; /* version of this selector */
184 uint16 flags; /* flag bits */
185 } CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR;
186
187 /* ACL subjects of type CSSM_ACL_SUBJECT_TYPE_PREAUTH_SOURCE */
188 typedef uint32 CSSM_ACL_PREAUTH_TRACKING_STATE;
189 enum { /* preauth tracking state */
190 CSSM_ACL_PREAUTH_TRACKING_COUNT_MASK = 0xff, /* mask for count status */
191 CSSM_ACL_PREAUTH_TRACKING_BLOCKED = 0, /* retries exhausted; the slot is blocked */
192 /* 0 .. 255 is a count of (re)tries remaining */
193
194 /* bits or'ed into any count given */
195 CSSM_ACL_PREAUTH_TRACKING_UNKNOWN = 0x40000000, /* status of slot is unknown (ignore count) */
196 CSSM_ACL_PREAUTH_TRACKING_AUTHORIZED = 0x80000000 /* the slot is currently authorized (or'ed in) */
197 };
198
199
200 /* Apple defined values of a CSSM_DB_ACCESS_TYPE */
201 enum {
202 CSSM_DB_ACCESS_RESET = 0x10000 /* clear pre-authentications (or'ed bit) */
203 };
204
205
206 /* Apple defined algorithm IDs */
207 enum
208 {
209 CSSM_ALGID_APPLE_YARROW = CSSM_ALGID_VENDOR_DEFINED,
210 CSSM_ALGID_AES, /* RijnDael */
211 CSSM_ALGID_FEE, /* FEE Key Generation */
212 CSSM_ALGID_FEE_MD5, /* FEE/ElGamal signature w/ MD5 hash */
213 CSSM_ALGID_FEE_SHA1, /* FEE/ElGamal signature w/ SHA1 hash */
214 CSSM_ALGID_FEED, /* 1:1 FEE asymmetric encryption */
215 CSSM_ALGID_FEEDEXP, /* 2:1 FEE asymmetric encryption */
216 CSSM_ALGID_ASC, /* Apple Secure Compression */
217 CSSM_ALGID_SHA1HMAC_LEGACY, /* HMAC/SHA1, legacy compatible */
218 CSSM_ALGID_KEYCHAIN_KEY, /* derive or manipulate keychain master keys */
219 CSSM_ALGID_PKCS12_PBE_ENCR, /* PKCS12, encrypt/decrypt key */
220 CSSM_ALGID_PKCS12_PBE_MAC, /* PKCS12, MAC key */
221 CSSM_ALGID_SECURE_PASSPHRASE, /* passphrase acquired by SecurityServer */
222 CSSM_ALGID_PBE_OPENSSL_MD5, /* traditional openssl key derivation */
223 CSSM_ALGID_SHA256, /* 256-bit SHA2 */
224 CSSM_ALGID_SHA384, /* 384-bit SHA2 */
225 CSSM_ALGID_SHA512, /* 512-bit SHA2 */
226 CSSM_ALGID_ENTROPY_DEFAULT, /* default entropy source of (CSP) device, if any */
227 CSSM_ALGID_SHA224, /* SHA2, 224 bit */
228 CSSM_ALGID_SHA224WithRSA, /* RSA signature on SHA224 digest */
229 CSSM_ALGID_SHA256WithRSA, /* RSA signature on SHA256 digest */
230 CSSM_ALGID_SHA384WithRSA, /* RSA signature on SHA384 digest */
231 CSSM_ALGID_SHA512WithRSA, /* RSA signature on SHA512 digest */
232 CSSM_ALGID_OPENSSH1, /* OpenSSH v1 RSA key wrapping */
233 CSSM_ALGID_SHA224WithECDSA, /* ECDSA signature on SHA224 digest */
234 CSSM_ALGID_SHA256WithECDSA, /* ECDSA signature on SHA256 digest */
235 CSSM_ALGID_SHA384WithECDSA, /* ECDSA signature on SHA384 digest */
236 CSSM_ALGID_SHA512WithECDSA, /* ECDSA signature on SHA512 digest */
237 CSSM_ALGID_ECDSA_SPECIFIED, /* ECDSA with separate digest algorithm specifier */
238 CSSM_ALGID_ECDH_X963_KDF, /* ECDH with X9.63 key derivation */
239 CSSM_ALGID__FIRST_UNUSED
240 };
241
242 /* Apple defined padding */
243 enum
244 {
245 /* RFC 2246 section E.2 for SSLv2 rollback detection */
246 CSSM_PADDING_APPLE_SSLv2 = CSSM_PADDING_VENDOR_DEFINED
247 };
248
249
250 /* Apple defined keyblob formats */
251 enum {
252 CSSM_KEYBLOB_RAW_FORMAT_VENDOR_DEFINED = 0x80000000
253 };
254 enum {
255 /* X509 SubjectPublicKeyInfo */
256 CSSM_KEYBLOB_RAW_FORMAT_X509 = CSSM_KEYBLOB_RAW_FORMAT_VENDOR_DEFINED,
257 /* OpenSSH v1 */
258 CSSM_KEYBLOB_RAW_FORMAT_OPENSSH,
259 /* openssl-style DSA private key */
260 CSSM_KEYBLOB_RAW_FORMAT_OPENSSL,
261 /* OpenSSH v2 */
262 CSSM_KEYBLOB_RAW_FORMAT_OPENSSH2
263 };
264
265 /* Apple adds some "common" error codes. CDSA does not define an official start value for this. */
266 enum
267 {
268 CSSM_CUSTOM_COMMON_ERROR_EXTENT = 0x00e0,
269
270 CSSM_ERRCODE_NO_USER_INTERACTION = 0x00e0,
271 CSSM_ERRCODE_USER_CANCELED = 0x00e1,
272 CSSM_ERRCODE_SERVICE_NOT_AVAILABLE = 0x00e2,
273 CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION = 0x00e3,
274 CSSM_ERRCODE_DEVICE_RESET = 0x00e4,
275 CSSM_ERRCODE_DEVICE_FAILED = 0x00e5,
276 CSSM_ERRCODE_IN_DARK_WAKE = 0x00e6
277 };
278
279 enum {
280 CSSMERR_CSSM_NO_USER_INTERACTION = CSSM_CSSM_BASE_ERROR + CSSM_ERRCODE_NO_USER_INTERACTION,
281 CSSMERR_AC_NO_USER_INTERACTION = CSSM_AC_BASE_ERROR + CSSM_ERRCODE_NO_USER_INTERACTION,
282 CSSMERR_CSP_NO_USER_INTERACTION = CSSM_CSP_BASE_ERROR + CSSM_ERRCODE_NO_USER_INTERACTION,
283 CSSMERR_CL_NO_USER_INTERACTION = CSSM_CL_BASE_ERROR + CSSM_ERRCODE_NO_USER_INTERACTION,
284 CSSMERR_DL_NO_USER_INTERACTION = CSSM_DL_BASE_ERROR + CSSM_ERRCODE_NO_USER_INTERACTION,
285 CSSMERR_TP_NO_USER_INTERACTION = CSSM_TP_BASE_ERROR + CSSM_ERRCODE_NO_USER_INTERACTION,
286
287 CSSMERR_CSSM_USER_CANCELED = CSSM_CSSM_BASE_ERROR + CSSM_ERRCODE_USER_CANCELED,
288 CSSMERR_AC_USER_CANCELED = CSSM_AC_BASE_ERROR + CSSM_ERRCODE_USER_CANCELED,
289 CSSMERR_CSP_USER_CANCELED = CSSM_CSP_BASE_ERROR + CSSM_ERRCODE_USER_CANCELED,
290 CSSMERR_CL_USER_CANCELED = CSSM_CL_BASE_ERROR + CSSM_ERRCODE_USER_CANCELED,
291 CSSMERR_DL_USER_CANCELED = CSSM_DL_BASE_ERROR + CSSM_ERRCODE_USER_CANCELED,
292 CSSMERR_TP_USER_CANCELED = CSSM_TP_BASE_ERROR + CSSM_ERRCODE_USER_CANCELED,
293
294 CSSMERR_CSSM_SERVICE_NOT_AVAILABLE = CSSM_CSSM_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE,
295 CSSMERR_AC_SERVICE_NOT_AVAILABLE = CSSM_AC_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE,
296 CSSMERR_CSP_SERVICE_NOT_AVAILABLE = CSSM_CSP_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE,
297 CSSMERR_CL_SERVICE_NOT_AVAILABLE = CSSM_CL_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE,
298 CSSMERR_DL_SERVICE_NOT_AVAILABLE = CSSM_DL_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE,
299 CSSMERR_TP_SERVICE_NOT_AVAILABLE = CSSM_TP_BASE_ERROR + CSSM_ERRCODE_SERVICE_NOT_AVAILABLE,
300
301 CSSMERR_CSSM_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_CSSM_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION,
302 CSSMERR_AC_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_AC_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION,
303 CSSMERR_CSP_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_CSP_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION,
304 CSSMERR_CL_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_CL_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION,
305 CSSMERR_DL_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_DL_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION,
306 CSSMERR_TP_INSUFFICIENT_CLIENT_IDENTIFICATION = CSSM_TP_BASE_ERROR + CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION,
307
308 CSSMERR_CSSM_DEVICE_RESET = CSSM_CSSM_BASE_ERROR + CSSM_ERRCODE_DEVICE_RESET,
309 CSSMERR_AC_DEVICE_RESET = CSSM_AC_BASE_ERROR + CSSM_ERRCODE_DEVICE_RESET,
310 CSSMERR_CSP_DEVICE_RESET = CSSM_CSP_BASE_ERROR + CSSM_ERRCODE_DEVICE_RESET,
311 CSSMERR_CL_DEVICE_RESET = CSSM_CL_BASE_ERROR + CSSM_ERRCODE_DEVICE_RESET,
312 CSSMERR_DL_DEVICE_RESET = CSSM_DL_BASE_ERROR + CSSM_ERRCODE_DEVICE_RESET,
313 CSSMERR_TP_DEVICE_RESET = CSSM_TP_BASE_ERROR + CSSM_ERRCODE_DEVICE_RESET,
314
315 CSSMERR_CSSM_DEVICE_FAILED = CSSM_CSSM_BASE_ERROR + CSSM_ERRCODE_DEVICE_FAILED,
316 CSSMERR_AC_DEVICE_FAILED = CSSM_AC_BASE_ERROR + CSSM_ERRCODE_DEVICE_FAILED,
317 CSSMERR_CSP_DEVICE_FAILED = CSSM_CSP_BASE_ERROR + CSSM_ERRCODE_DEVICE_FAILED,
318 CSSMERR_CL_DEVICE_FAILED = CSSM_CL_BASE_ERROR + CSSM_ERRCODE_DEVICE_FAILED,
319 CSSMERR_DL_DEVICE_FAILED = CSSM_DL_BASE_ERROR + CSSM_ERRCODE_DEVICE_FAILED,
320 CSSMERR_TP_DEVICE_FAILED = CSSM_TP_BASE_ERROR + CSSM_ERRCODE_DEVICE_FAILED,
321
322 CSSMERR_CSSM_IN_DARK_WAKE = CSSM_CSSM_BASE_ERROR + CSSM_ERRCODE_IN_DARK_WAKE,
323 CSSMERR_AC_IN_DARK_WAKE = CSSM_AC_BASE_ERROR + CSSM_ERRCODE_IN_DARK_WAKE,
324 CSSMERR_CSP_IN_DARK_WAKE = CSSM_CSP_BASE_ERROR + CSSM_ERRCODE_IN_DARK_WAKE,
325 CSSMERR_CL_IN_DARK_WAKE = CSSM_CL_BASE_ERROR + CSSM_ERRCODE_IN_DARK_WAKE,
326 CSSMERR_DL_IN_DARK_WAKE = CSSM_DL_BASE_ERROR + CSSM_ERRCODE_IN_DARK_WAKE,
327 CSSMERR_TP_IN_DARK_WAKE = CSSM_TP_BASE_ERROR + CSSM_ERRCODE_IN_DARK_WAKE
328 };
329
330 /* AppleCSPDL, AppleCSP private error codes. */
331 enum {
332 CSSMERR_CSP_APPLE_ADD_APPLICATION_ACL_SUBJECT = CSSM_CSP_PRIVATE_ERROR + 0,
333 /*
334 * An attempt was made to use a public key which is incomplete due to
335 * the lack of algorithm-specific parameters.
336 */
337 CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE = CSSM_CSP_PRIVATE_ERROR + 1,
338
339 /* a code signature match failed */
340 CSSMERR_CSP_APPLE_SIGNATURE_MISMATCH = CSSM_CSP_PRIVATE_ERROR + 2,
341
342 /* Key StartDate/EndDate invalid */
343 CSSMERR_CSP_APPLE_INVALID_KEY_START_DATE = CSSM_CSP_PRIVATE_ERROR + 3,
344 CSSMERR_CSP_APPLE_INVALID_KEY_END_DATE = CSSM_CSP_PRIVATE_ERROR + 4,
345
346 /* Keychain Syncing error codes */
347 CSSMERR_CSPDL_APPLE_DL_CONVERSION_ERROR = CSSM_CSP_PRIVATE_ERROR + 5,
348
349 /* SSLv2 padding check: rollback attack detected */
350 CSSMERR_CSP_APPLE_SSLv2_ROLLBACK = CSSM_CSP_PRIVATE_ERROR + 6
351 };
352
353
354 /* AppleFileDL record types. */
355 enum
356 {
357 CSSM_DL_DB_RECORD_GENERIC_PASSWORD = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 0,
358 CSSM_DL_DB_RECORD_INTERNET_PASSWORD = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 1,
359 CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 2,
360
361 CSSM_DL_DB_RECORD_X509_CERTIFICATE = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 0x1000,
362 CSSM_DL_DB_RECORD_USER_TRUST,
363 CSSM_DL_DB_RECORD_X509_CRL,
364 CSSM_DL_DB_RECORD_UNLOCK_REFERRAL,
365 CSSM_DL_DB_RECORD_EXTENDED_ATTRIBUTE,
366 CSSM_DL_DB_RECORD_METADATA = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 0x8000
367 };
368
369 /* AppleFileDL extentions: passthrough ids */
370 enum {
371 // Toggle whether or not to autocommit after modifying the database.
372 // The input parameter is a CSSM_BOOL, where TRUE turns autocommit on
373 // and FALSE turns it off.
374 CSSM_APPLEFILEDL_TOGGLE_AUTOCOMMIT,
375
376 // Commit any pending changes to the database.
377 CSSM_APPLEFILEDL_COMMIT,
378
379 // Rollback and discard any pending changes to the database.
380 CSSM_APPLEFILEDL_ROLLBACK
381 };
382
383 /* UNLOCK_REFERRAL "type" attribute values */
384 enum {
385 CSSM_APPLE_UNLOCK_TYPE_KEY_DIRECT = 1, // master secret key stored directly
386 CSSM_APPLE_UNLOCK_TYPE_WRAPPED_PRIVATE = 2 // master key wrapped by public key
387 };
388
389 /* Apple DL private error codes. */
390 enum
391 {
392 /* The OpenParameters argument passed to CSSM_DL_DbCreate or CSSM_DL_DbOpen
393 was neither NULL nor a pointer to a valid CSSM_APPLEDL_OPEN_PARAMETERS
394 structure. */
395 CSSMERR_APPLEDL_INVALID_OPEN_PARAMETERS = CSSM_DL_PRIVATE_ERROR + 0,
396
397 /* an operation failed because the disk was full */
398 CSSMERR_APPLEDL_DISK_FULL = CSSM_DL_PRIVATE_ERROR + 1,
399
400 /* an operation failed because a disk quota was exceeded */
401 CSSMERR_APPLEDL_QUOTA_EXCEEDED = CSSM_DL_PRIVATE_ERROR + 2,
402
403 /* an operation failed because a file was too large */
404 CSSMERR_APPLEDL_FILE_TOO_BIG = CSSM_DL_PRIVATE_ERROR + 3,
405
406 /* a keychain database's internal information ("blob") is invalid */
407 CSSMERR_APPLEDL_INVALID_DATABASE_BLOB = CSSM_DL_PRIVATE_ERROR + 4,
408 CSSMERR_APPLEDL_INVALID_KEY_BLOB = CSSM_DL_PRIVATE_ERROR + 5,
409
410 /* the internal data format version for a database's internal information ("blob") is invalid */
411 CSSMERR_APPLEDL_INCOMPATIBLE_DATABASE_BLOB = CSSM_DL_PRIVATE_ERROR + 6,
412 CSSMERR_APPLEDL_INCOMPATIBLE_KEY_BLOB = CSSM_DL_PRIVATE_ERROR + 7,
413 };
414
415 /* Apple X509TP private error codes. */
416 enum
417 {
418 /* Host name mismatch */
419 CSSMERR_APPLETP_HOSTNAME_MISMATCH = CSSM_TP_PRIVATE_ERROR + 0,
420 /* Non-understood extension with Critical flag true */
421 CSSMERR_APPLETP_UNKNOWN_CRITICAL_EXTEN = CSSM_TP_PRIVATE_ERROR + 1,
422 /* Basic Constraints extension required per policy, but not present */
423 CSSMERR_APPLETP_NO_BASIC_CONSTRAINTS = CSSM_TP_PRIVATE_ERROR + 2,
424 /* Invalid BasicConstraints.CA */
425 CSSMERR_APPLETP_INVALID_CA = CSSM_TP_PRIVATE_ERROR + 3,
426 /* Invalid Authority Key ID */
427 CSSMERR_APPLETP_INVALID_AUTHORITY_ID = CSSM_TP_PRIVATE_ERROR + 4,
428 /* Invalid Subject Key ID */
429 CSSMERR_APPLETP_INVALID_SUBJECT_ID = CSSM_TP_PRIVATE_ERROR + 5,
430 /* Invalid Key Usage for policy */
431 CSSMERR_APPLETP_INVALID_KEY_USAGE = CSSM_TP_PRIVATE_ERROR + 6,
432 /* Invalid Extended Key Usage for policy */
433 CSSMERR_APPLETP_INVALID_EXTENDED_KEY_USAGE = CSSM_TP_PRIVATE_ERROR + 7,
434 /* Invalid Subject/Authority Key ID Linkage */
435 CSSMERR_APPLETP_INVALID_ID_LINKAGE = CSSM_TP_PRIVATE_ERROR + 8,
436 /* PathLengthConstraint exceeded */
437 CSSMERR_APPLETP_PATH_LEN_CONSTRAINT = CSSM_TP_PRIVATE_ERROR + 9,
438 /* Cert group terminated at a root cert which did not self-verify */
439 CSSMERR_APPLETP_INVALID_ROOT = CSSM_TP_PRIVATE_ERROR + 10,
440 /* CRL expired/not valid yet */
441 CSSMERR_APPLETP_CRL_EXPIRED = CSSM_TP_PRIVATE_ERROR + 11,
442 CSSMERR_APPLETP_CRL_NOT_VALID_YET = CSSM_TP_PRIVATE_ERROR + 12,
443 /* Cannot find appropriate CRL */
444 CSSMERR_APPLETP_CRL_NOT_FOUND = CSSM_TP_PRIVATE_ERROR + 13,
445 /* specified CRL server down */
446 CSSMERR_APPLETP_CRL_SERVER_DOWN = CSSM_TP_PRIVATE_ERROR + 14,
447 /* illegible CRL distribution point URL */
448 CSSMERR_APPLETP_CRL_BAD_URI = CSSM_TP_PRIVATE_ERROR + 15,
449 /* Unknown critical cert/CRL extension */
450 CSSMERR_APPLETP_UNKNOWN_CERT_EXTEN = CSSM_TP_PRIVATE_ERROR + 16,
451 CSSMERR_APPLETP_UNKNOWN_CRL_EXTEN = CSSM_TP_PRIVATE_ERROR + 17,
452 /* CRL not verifiable to anchor or root */
453 CSSMERR_APPLETP_CRL_NOT_TRUSTED = CSSM_TP_PRIVATE_ERROR + 18,
454 /* CRL verified to untrusted root */
455 CSSMERR_APPLETP_CRL_INVALID_ANCHOR_CERT = CSSM_TP_PRIVATE_ERROR + 19,
456 /* CRL failed policy verification */
457 CSSMERR_APPLETP_CRL_POLICY_FAIL = CSSM_TP_PRIVATE_ERROR + 20,
458 /* IssuingDistributionPoint extension violation */
459 CSSMERR_APPLETP_IDP_FAIL = CSSM_TP_PRIVATE_ERROR + 21,
460 /* Cert not found at specified issuerAltName */
461 CSSMERR_APPLETP_CERT_NOT_FOUND_FROM_ISSUER = CSSM_TP_PRIVATE_ERROR + 22,
462 /* Bad cert obtained from specified issuerAltName */
463 CSSMERR_APPLETP_BAD_CERT_FROM_ISSUER = CSSM_TP_PRIVATE_ERROR + 23,
464 /* S/MIME Email address mismatch */
465 CSSMERR_APPLETP_SMIME_EMAIL_ADDRS_NOT_FOUND = CSSM_TP_PRIVATE_ERROR + 24,
466 /* Appropriate S/MIME ExtendedKeyUsage not found */
467 CSSMERR_APPLETP_SMIME_BAD_EXT_KEY_USE = CSSM_TP_PRIVATE_ERROR + 25,
468 /* S/MIME KeyUsage incompatibility */
469 CSSMERR_APPLETP_SMIME_BAD_KEY_USE = CSSM_TP_PRIVATE_ERROR + 26,
470 /* S/MIME, cert with KeyUsage flagged !critical */
471 CSSMERR_APPLETP_SMIME_KEYUSAGE_NOT_CRITICAL = CSSM_TP_PRIVATE_ERROR + 27,
472 /* S/MIME, leaf with empty subject name and no email addrs
473 * in SubjectAltName */
474 CSSMERR_APPLETP_SMIME_NO_EMAIL_ADDRS = CSSM_TP_PRIVATE_ERROR + 28,
475 /* S/MIME, leaf with empty subject name, SubjectAltName
476 * not critical */
477 CSSMERR_APPLETP_SMIME_SUBJ_ALT_NAME_NOT_CRIT = CSSM_TP_PRIVATE_ERROR + 29,
478 /* Appropriate SSL ExtendedKeyUsage not found */
479 CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE = CSSM_TP_PRIVATE_ERROR + 30,
480 /* unparseable OCSP response */
481 CSSMERR_APPLETP_OCSP_BAD_RESPONSE = CSSM_TP_PRIVATE_ERROR + 31,
482 /* unparseable OCSP request */
483 CSSMERR_APPLETP_OCSP_BAD_REQUEST = CSSM_TP_PRIVATE_ERROR + 32,
484 /* OCSP service unavailable */
485 CSSMERR_APPLETP_OCSP_UNAVAILABLE = CSSM_TP_PRIVATE_ERROR + 33,
486 /* OCSP status: cert unrecognized */
487 CSSMERR_APPLETP_OCSP_STATUS_UNRECOGNIZED = CSSM_TP_PRIVATE_ERROR + 34,
488 /* revocation check not successful for each cert */
489 CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK = CSSM_TP_PRIVATE_ERROR + 35,
490 /* general network error */
491 CSSMERR_APPLETP_NETWORK_FAILURE = CSSM_TP_PRIVATE_ERROR + 36,
492 /* OCSP response not verifiable to anchor or root */
493 CSSMERR_APPLETP_OCSP_NOT_TRUSTED = CSSM_TP_PRIVATE_ERROR + 37,
494 /* OCSP response verified to untrusted root */
495 CSSMERR_APPLETP_OCSP_INVALID_ANCHOR_CERT = CSSM_TP_PRIVATE_ERROR + 38,
496 /* OCSP response signature error */
497 CSSMERR_APPLETP_OCSP_SIG_ERROR = CSSM_TP_PRIVATE_ERROR + 39,
498 /* No signer for OCSP response found */
499 CSSMERR_APPLETP_OCSP_NO_SIGNER = CSSM_TP_PRIVATE_ERROR + 40,
500 /* OCSP responder status: malformed request */
501 CSSMERR_APPLETP_OCSP_RESP_MALFORMED_REQ = CSSM_TP_PRIVATE_ERROR + 41,
502 /* OCSP responder status: internal error */
503 CSSMERR_APPLETP_OCSP_RESP_INTERNAL_ERR = CSSM_TP_PRIVATE_ERROR + 42,
504 /* OCSP responder status: try later */
505 CSSMERR_APPLETP_OCSP_RESP_TRY_LATER = CSSM_TP_PRIVATE_ERROR + 43,
506 /* OCSP responder status: signature required */
507 CSSMERR_APPLETP_OCSP_RESP_SIG_REQUIRED = CSSM_TP_PRIVATE_ERROR + 44,
508 /* OCSP responder status: unauthorized */
509 CSSMERR_APPLETP_OCSP_RESP_UNAUTHORIZED = CSSM_TP_PRIVATE_ERROR + 45,
510 /* OCSP response nonce did not match request */
511 CSSMERR_APPLETP_OCSP_NONCE_MISMATCH = CSSM_TP_PRIVATE_ERROR + 46,
512 /* Illegal cert chain length for Code Signing */
513 CSSMERR_APPLETP_CS_BAD_CERT_CHAIN_LENGTH = CSSM_TP_PRIVATE_ERROR + 47,
514 /* Missing Basic Constraints for Code Signing */
515 CSSMERR_APPLETP_CS_NO_BASIC_CONSTRAINTS = CSSM_TP_PRIVATE_ERROR + 48,
516 /* Bad PathLengthConstraint for Code Signing */
517 CSSMERR_APPLETP_CS_BAD_PATH_LENGTH = CSSM_TP_PRIVATE_ERROR + 49,
518 /* Missing ExtendedKeyUsage for Code Signing */
519 CSSMERR_APPLETP_CS_NO_EXTENDED_KEY_USAGE = CSSM_TP_PRIVATE_ERROR + 50,
520 /* Development style Code Signing Cert Detected */
521 CSSMERR_APPLETP_CODE_SIGN_DEVELOPMENT = CSSM_TP_PRIVATE_ERROR + 51,
522 /* Illegal cert chain length for Resource Signing */
523 CSSMERR_APPLETP_RS_BAD_CERT_CHAIN_LENGTH = CSSM_TP_PRIVATE_ERROR + 52,
524 /* bad extended key usage for Resource Signing */
525 CSSMERR_APPLETP_RS_BAD_EXTENDED_KEY_USAGE = CSSM_TP_PRIVATE_ERROR + 53,
526 /* Trust Setting: deny */
527 CSSMERR_APPLETP_TRUST_SETTING_DENY = CSSM_TP_PRIVATE_ERROR + 54,
528 /* invalid empty SubjectName */
529 CSSMERR_APPLETP_INVALID_EMPTY_SUBJECT = CSSM_TP_PRIVATE_ERROR + 55,
530 /* unknown critical Qualified Cert Statement ID */
531 CSSMERR_APPLETP_UNKNOWN_QUAL_CERT_STATEMENT = CSSM_TP_PRIVATE_ERROR + 56,
532 /* Missing required extension */
533 CSSMERR_APPLETP_MISSING_REQUIRED_EXTENSION = CSSM_TP_PRIVATE_ERROR + 57,
534 /* Extended key usage not marked critical */
535 CSSMERR_APPLETP_EXT_KEYUSAGE_NOT_CRITICAL = CSSM_TP_PRIVATE_ERROR + 58
536 };
537
538 /* Apple .mac TP private error codes. */
539 enum
540 {
541 /* cert request queued */
542 CSSMERR_APPLE_DOTMAC_REQ_QUEUED = CSSM_TP_PRIVATE_ERROR + 100,
543 /* cert request redirected */
544 CSSMERR_APPLE_DOTMAC_REQ_REDIRECT = CSSM_TP_PRIVATE_ERROR + 101,
545 /* general server-reported error */
546 CSSMERR_APPLE_DOTMAC_REQ_SERVER_ERR = CSSM_TP_PRIVATE_ERROR + 102,
547 /* server-reported parameter error */
548 CSSMERR_APPLE_DOTMAC_REQ_SERVER_PARAM = CSSM_TP_PRIVATE_ERROR + 103,
549 /* server-reported authorization error */
550 CSSMERR_APPLE_DOTMAC_REQ_SERVER_AUTH = CSSM_TP_PRIVATE_ERROR + 104,
551 /* server-reported unimplemented */
552 CSSMERR_APPLE_DOTMAC_REQ_SERVER_UNIMPL = CSSM_TP_PRIVATE_ERROR + 105,
553 /* server-reported not available */
554 CSSMERR_APPLE_DOTMAC_REQ_SERVER_NOT_AVAIL = CSSM_TP_PRIVATE_ERROR + 106,
555 /* server-reported already exists */
556 CSSMERR_APPLE_DOTMAC_REQ_SERVER_ALREADY_EXIST = CSSM_TP_PRIVATE_ERROR + 107,
557 /* server-reported service error */
558 CSSMERR_APPLE_DOTMAC_REQ_SERVER_SERVICE_ERROR = CSSM_TP_PRIVATE_ERROR + 108,
559 /* request already pending for specified user */
560 CSSMERR_APPLE_DOTMAC_REQ_IS_PENDING = CSSM_TP_PRIVATE_ERROR + 109,
561 /* no request pending for specified user */
562 CSSMERR_APPLE_DOTMAC_NO_REQ_PENDING = CSSM_TP_PRIVATE_ERROR + 110,
563 /* CSR failed to verify */
564 CSSMERR_APPLE_DOTMAC_CSR_VERIFY_FAIL = CSSM_TP_PRIVATE_ERROR + 111,
565 /* server reported failed consistency check */
566 CSSMERR_APPLE_DOTMAC_FAILED_CONSISTENCY_CHECK = CSSM_TP_PRIVATE_ERROR + 112
567 };
568
569 enum
570 {
571 CSSM_APPLEDL_OPEN_PARAMETERS_VERSION = 1
572 };
573
574 enum cssm_appledl_open_parameters_mask
575 {
576 kCSSM_APPLEDL_MASK_MODE = (1 << 0)
577 };
578
579 /* Pass a CSSM_APPLEDL_OPEN_PARAMETERS_PTR as the OpenParameters argument to
580 CSSM_DL_DbCreate or CSSM_DL_DbOpen. When using this struct, you must zero
581 out the entire struct before setting any additional parameters to ensure
582 forward compatibility. */
583 typedef struct cssm_appledl_open_parameters
584 {
585 uint32 length; /* Should be sizeof(CSSM_APPLEDL_OPEN_PARAMETERS). */
586 uint32 version; /* Should be CSSM_APPLEDL_OPEN_PARAMETERS_VERSION. */
587
588 /* If no OpenParameters are specified, autoCommit is on (!CSSM_FALSE) by default.
589 When autoCommit is on (!CSSM_FALSE), changes made to the Db are written to disk
590 before returning from each function.
591 When autoCommit is off (CSSM_FALSE), changes made to the database are not guaranteed
592 to be written to disk until the Db is closed. This is useful for bulk writes.
593 Be aware that if autoCommit is off, changes made in previous calls to the DL might
594 get rolled back if a new modification operation fails. */
595 CSSM_BOOL autoCommit;
596
597 /* Mask marking which of the following fields are to be used. */
598 uint32 mask;
599
600 /* When calling DbCreate, the initial mode to create the database file with; ignored on DbOpen. You must set the kCSSM_APPLEDL_MASK_MODE bit in mask or mode is ignored. */
601 mode_t mode;
602 } CSSM_APPLEDL_OPEN_PARAMETERS, *CSSM_APPLEDL_OPEN_PARAMETERS_PTR;
603
604
605 /* AppleCSPDL passthough ids */
606 enum
607 {
608 /* Tell the SecurityServer to lock the database specified by the DLDBHandle argument.
609 The InputParams and OutputParams arguments are ignored. */
610 CSSM_APPLECSPDL_DB_LOCK = 0,
611
612 /* Tell the SecurityServer to unlock the database specified by the DLDBHandle argument.
613 The InputParameters argument is a CSSM_DATA_PTR containing the password, or NULL if
614 the SecurityServer should prompt for the password.
615 The OutputParams argument is ignored.
616 The SecurityServer will put up UI (though the SecurityAgent) when this function is called
617 iff InputParameters is NULL. */
618 CSSM_APPLECSPDL_DB_UNLOCK = 1,
619
620 /* Ask the SecurityServer to get the db settings specified for the database
621 specified by the DLDBHandle argument. The settings are returned in the OutputParameters argument.
622 The OutputParameters argument is a pointer to a CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS_PTR.
623 Upon successful completion, the AppleCSPDL will have allocated a
624 CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS structure using the application-specified
625 allocators for the DL attachment specified by the DLDBHandle argument. The structure will contain
626 the current database settings for the specified database. The client should free the
627 CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS_PTR after it has finished using it.
628 The InputParameters argument is ignored.
629 The SecurityServer might put up UI (though the SecurityAgent) when this function is called. */
630 CSSM_APPLECSPDL_DB_GET_SETTINGS = 2,
631
632 /* Tell the SecurityServer to set the db settings specified in InputParameters on the database
633 specified by the DLDBHandle argument.
634 The InputParameters argument is a const CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS * containing
635 the new settings for the specified database.
636 The OutputParams argument is ignored.
637 The SecurityServer might put up UI (though the SecurityAgent) when this function is called. */
638 CSSM_APPLECSPDL_DB_SET_SETTINGS = 3,
639
640 /* Ask the SecurityServer whether the database specified by the DLDBHandle argument is locked.
641 The InputParameters argument is ignored.
642 The OutputParameters argument is a pointer to a CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS_PTR.
643 Upon successful completion, the AppleCSPDL will have allocated a
644 CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS structure using the application-specified
645 allocators for the DL attachment specified by the DLDBHandle argument. The structure will contain
646 the current lock status for the specified database. The client should free the
647 CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS_PTR after it has finished using it.
648 The SecurityServer will put up UI (though the SecurityAgent) when this function is called. */
649 CSSM_APPLECSPDL_DB_IS_LOCKED = 4,
650
651 /* Tell the SecurityServer to change the password for the database specified by
652 the DLDBHandle.
653
654 The InputParameters argument is a const CSSM_APPLECSPDL_DB_CHANGE_PASSWORD_PARAMETERS * containing
655 a CSSM_ACCESS_CREDENTIALS * which determines how the password will be changed. If the
656 accessCredentials are NULL, the SecurityAgent will prompt for the old and the new password for the
657 specified database. If credentials are specified, there should be 2 entries:
658 1. a 3-element list containing:
659 CSSM_WORDID_KEYCHAIN_LOCK, CSSM_SAMPLE_TYPE_PASSWORD, and the old password.
660 2. a 3-element list containing:
661 CSSM_WORDID_KEYCHAIN_CHANGE_LOCK, CSSM_SAMPLE_TYPE_PASSWORD, and the new password.
662
663 The OutputParams argument is ignored.
664 The SecurityServer might put up UI (though the SecurityAgent) when this function is called. */
665 CSSM_APPLECSPDL_DB_CHANGE_PASSWORD =5,
666
667 /* Return the SecurityServer database handle for the database specified by the DLDBHandle */
668 CSSM_APPLECSPDL_DB_GET_HANDLE = 6,
669
670 /* Given a CSSM_KEY for the CSPDL, return the SecurityServer key handle */
671 CSSM_APPLESCPDL_CSP_GET_KEYHANDLE = 7,
672
673 CSSM_APPLE_PRIVATE_CSPDL_CODE_8 = 8,
674 CSSM_APPLE_PRIVATE_CSPDL_CODE_9 = 9,
675 CSSM_APPLE_PRIVATE_CSPDL_CODE_10 = 10,
676 CSSM_APPLE_PRIVATE_CSPDL_CODE_11 = 11,
677 CSSM_APPLE_PRIVATE_CSPDL_CODE_12 = 12,
678 CSSM_APPLE_PRIVATE_CSPDL_CODE_13 = 13,
679 CSSM_APPLE_PRIVATE_CSPDL_CODE_14 = 14,
680 CSSM_APPLE_PRIVATE_CSPDL_CODE_15 = 15,
681 CSSM_APPLE_PRIVATE_CSPDL_CODE_16 = 16,
682
683 /* Given a CSSM_KEY_PTR in any format, obtain the SHA-1 hash of the
684 * associated key blob.
685 * Key is specified in CSSM_CSP_CreatePassThroughContext.
686 * Hash is allocated bythe CSP, in the App's memory, and returned
687 * in *outData. */
688 CSSM_APPLECSP_KEYDIGEST = 0x100
689 };
690
691
692
693 /* AppleCSPDL passthough parameters */
694 typedef struct cssm_applecspdl_db_settings_parameters
695 {
696 uint32 idleTimeout; // seconds idle timeout lock
697 uint8 lockOnSleep; // lock database when system sleeps
698 } CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS, *CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS_PTR;
699
700 /* AppleCSPDL passthough parameters */
701 typedef struct cssm_applecspdl_db_is_locked_parameters
702 {
703 uint8 isLocked; // True iff the database is locked
704 } CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS, *CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS_PTR;
705
706 /* AppleCSPDL passthough parameters */
707 typedef struct cssm_applecspdl_db_change_password_parameters
708 {
709 CSSM_ACCESS_CREDENTIALS *accessCredentials;
710 } CSSM_APPLECSPDL_DB_CHANGE_PASSWORD_PARAMETERS, *CSSM_APPLECSPDL_DB_CHANGE_PASSWORD_PARAMETERS_PTR;
711
712 /* Custom wrapped key formats */
713 enum {
714 CSSM_KEYBLOB_WRAPPED_FORMAT_APPLE_CUSTOM = 100,
715 CSSM_KEYBLOB_WRAPPED_FORMAT_OPENSSL, // traditional openssl
716 CSSM_KEYBLOB_WRAPPED_FORMAT_OPENSSH1 // OpenSSH v1
717 };
718
719 /*
720 * Custom context attributes for AppleCSP.
721 */
722 enum {
723 CSSM_ATTRIBUTE_VENDOR_DEFINED = 0x800000
724 };
725
726 enum {
727 /*
728 * Public Key attribute for use with CSSM_ALGID_FEED.
729 */
730 CSSM_ATTRIBUTE_PUBLIC_KEY =
731 (CSSM_ATTRIBUTE_DATA_KEY | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 0)),
732
733 /*
734 * FEE key attributes.
735 * See CSSM_FEE_PRIME_TYPE_xxx, CSSM_FEE_CURVE_TYPE_xxx enums, below.
736 */
737 CSSM_ATTRIBUTE_FEE_PRIME_TYPE =
738 (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 1)),
739 CSSM_ATTRIBUTE_FEE_CURVE_TYPE =
740 (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 2)),
741
742 /*
743 * Apple Secure Compression (ComCryption) optimization.
744 * See CSSM_ASC_OPTIMIZE_xxx, enums, below.
745 */
746 CSSM_ATTRIBUTE_ASC_OPTIMIZATION =
747 (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 3)),
748
749 /*
750 * RSA blinding. Value is integer, nonzero (blinding on) or zero.
751 */
752 CSSM_ATTRIBUTE_RSA_BLINDING =
753 (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 4)),
754
755 /*
756 * Additional public key from which to obtain algorithm-specific
757 * parameters.
758 */
759 CSSM_ATTRIBUTE_PARAM_KEY =
760 (CSSM_ATTRIBUTE_DATA_KEY | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 5)),
761
762 /*
763 * Prompt string for CSSM_ALGID_SECURE_PASSPHRASE key acquisition.
764 * Data is a UTF8-encoded external representation of a CFString.
765 */
766 CSSM_ATTRIBUTE_PROMPT =
767 (CSSM_ATTRIBUTE_DATA_CSSM_DATA | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 6)),
768
769 /*
770 * Alert panel title for CSSM_ALGID_SECURE_PASSPHRASE key acquisition.
771 * Data is a UTF8-encoded external representation of a CFString.
772 */
773 CSSM_ATTRIBUTE_ALERT_TITLE =
774 (CSSM_ATTRIBUTE_DATA_CSSM_DATA | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 7)),
775
776 /*
777 * Boolean to specify whether secure passphrase is being used to encrypt or to
778 * recover data. In the former case the user will be prompted to enter the
779 * passphrase twice. Value is integer, nonzero (verify passphrase) or zero.
780 */
781 CSSM_ATTRIBUTE_VERIFY_PASSPHRASE =
782 (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 8))
783
784 };
785
786 /*
787 * FEE key pair prime modulus types.
788 */
789 enum {
790 CSSM_FEE_PRIME_TYPE_DEFAULT = 0, /* default per key size */
791 CSSM_FEE_PRIME_TYPE_MERSENNE, /* (2 ** q) - 1Ê*/
792 CSSM_FEE_PRIME_TYPE_FEE, /* (2 ** q) - k */
793 CSSM_FEE_PRIME_TYPE_GENERAL /* random prime */
794 };
795
796 /*
797 * FEE curve types. Comments refer to equation
798 *
799 * y**2 = x**3 + c(x**2) + ax + b
800 */
801 enum {
802 CSSM_FEE_CURVE_TYPE_DEFAULT = 0, /* default per key size */
803 CSSM_FEE_CURVE_TYPE_MONTGOMERY, /* a==1, b==0 */
804 CSSM_FEE_CURVE_TYPE_WEIERSTRASS, /* c==0. IEEE P1363 compliant. */
805 CSSM_FEE_CURVE_TYPE_ANSI_X9_62 /* ANSI X9.62 compatible */
806 };
807
808 /*
809 * Apple Secure Compression (ComCryption) optimization attributes.
810 */
811 enum {
812 CSSM_ASC_OPTIMIZE_DEFAULT = 0,
813 CSSM_ASC_OPTIMIZE_SIZE, /* max compression (currently the default) */
814 CSSM_ASC_OPTIMIZE_SECURITY, /* currently not implemented */
815 CSSM_ASC_OPTIMIZE_TIME, /* min runtime */
816 CSSM_ASC_OPTIMIZE_TIME_SIZE, /* implies loss of security */
817 CSSM_ASC_OPTIMIZE_ASCII, /* optimized for ASCC text, not implemented */
818 };
819
820 /*
821 * Apple custom CSSM_KEYATTR_FLAGS.
822 */
823 enum {
824 /*
825 * When set, indicates a public key which is incomplete (though
826 * still valid) due to the lack of algorithm-specific parameters.
827 */
828 CSSM_KEYATTR_PARTIAL = 0x00010000,
829
830 /*
831 * When set, public keys are stored encrypted. Default is to store
832 * public keys in the clear. AppleCSPDL only.
833 */
834 CSSM_KEYATTR_PUBLIC_KEY_ENCRYPT = 0x00020000
835 };
836
837 /*
838 * Name/OID pair used in CSSM_APPLE_TP_CERT_REQUEST
839 */
840 typedef struct {
841 const char *string;
842 const CSSM_OID *oid;
843 } CSSM_APPLE_TP_NAME_OID;
844
845 /*
846 * Certificate request passed to CSSM_TP_SubmitCredRequest() in the
847 * CSSM_TP_AUTHORITY_REQUEST_TYPE.Requests field. Used for requesting
848 * both locally-generated certs (CSSMOID_APPLE_TP_LOCAL_CERT_GEN) and
849 * cert signing requests (CSSMOID_APPLE_TP_CSR_GEN).
850 */
851 typedef struct {
852 CSSM_CSP_HANDLE cspHand; // sign with this CSP
853 CSSM_CL_HANDLE clHand; // and this CL
854 uint32 serialNumber;
855 uint32 numSubjectNames;// size subjectNames[]
856 CSSM_APPLE_TP_NAME_OID *subjectNames;
857
858 /*
859 * Issuer name can be expressed in the simplified CSSM_APPLE_TP_NAME_OID
860 * array, as is the subject name, or as an CSSM_X509_NAME, which is
861 * typically obtained from a signing cert.
862 * Exactly one of {issuerNames, issuerNameX509} must be non-NULL.
863 */
864 uint32 numIssuerNames; // size issuerNames[]
865 CSSM_APPLE_TP_NAME_OID *issuerNames; // optional; NULL implies root
866 // (signer == subject)
867 CSSM_X509_NAME_PTR issuerNameX509;
868 const CSSM_KEY *certPublicKey;
869 const CSSM_KEY *issuerPrivateKey;
870
871 /* Unfortunately there is no practical way to map any algorithm
872 * to its appropriate OID, and we need both.... */
873 CSSM_ALGORITHMS signatureAlg; // e.g., CSSM_ALGID_SHA1WithRSA
874 CSSM_OID signatureOid; // e.g., CSSMOID_SHA1WithRSA
875 uint32 notBefore; // relative to "now"
876 uint32 notAfter;
877 uint32 numExtensions;
878 CE_DataAndType *extensions; // optional
879
880 /*
881 * Optional challenge string for CSSMOID_APPLE_TP_CSR_GEN.
882 */
883 const char *challengeString;
884 } CSSM_APPLE_TP_CERT_REQUEST;
885
886 /*
887 * Options for X509TP's CSSM_TP_CertGroupVerify for policy CSSMOID_APPLE_TP_SSL.
888 * A pointer to, and length of, one of these is optionally placed in
889 * CSSM_TP_VERIFY_CONTEXT.Cred->Policy.PolicyIds[n].FieldValue.
890 */
891 #define CSSM_APPLE_TP_SSL_OPTS_VERSION 1
892
893 /*
894 * Values for CSSM_APPLE_TP_SSL_OPTIONS.flags.
895 *
896 * Set this flag when evaluating a client cert.
897 */
898 #define CSSM_APPLE_TP_SSL_CLIENT 0x00000001
899
900 typedef struct {
901 uint32 Version; // CSSM_APPLE_TP_SSL_OPTS_VERSION
902
903 /*
904 * The domain name of the server (e.g., "store.apple.com".) In the
905 * SSL and TLS protocols, this must match the common name of the
906 * subject cert. Expressed as a C string, optionally NULL terminated
907 * if it is NULL terminated, the length field should include the NULL).
908 */
909 uint32 ServerNameLen;
910 const char *ServerName; // optional
911
912 /* new fields for struct version 1 */
913 uint32 Flags;
914 } CSSM_APPLE_TP_SSL_OPTIONS;
915
916 /*
917 * Options for X509TP's CSSM_TP_CertGroupVerify for policy
918 * CSSMOID_APPLE_TP_REVOCATION_CRL. A pointer to, and length of, one
919 * of these is optionally placed in
920 * CSSM_TP_VERIFY_CONTEXT.Cred->Policy.PolicyIds[n].FieldValue.
921 */
922 #define CSSM_APPLE_TP_CRL_OPTS_VERSION 0
923
924 typedef uint32 CSSM_APPLE_TP_CRL_OPT_FLAGS;
925 enum {
926 // require CRL verification for each cert; default is "try"
927 CSSM_TP_ACTION_REQUIRE_CRL_PER_CERT = 0x00000001,
928 // enable fetch from network
929 CSSM_TP_ACTION_FETCH_CRL_FROM_NET = 0x00000002,
930 // if set and positive OCSP verify for given cert, no further revocation
931 // checking need be done on that cert
932 CSSM_TP_ACTION_CRL_SUFFICIENT = 0x00000004,
933 // require CRL verification for certs which claim a CRL provider
934 CSSM_TP_ACTION_REQUIRE_CRL_IF_PRESENT = 0x00000008
935 };
936
937 typedef struct {
938 uint32 Version; // CSSM_APPLE_TP_CRL_OPTS_VERSION
939 CSSM_APPLE_TP_CRL_OPT_FLAGS CrlFlags;
940
941 /*
942 * When non-NULL, store CRLs fetched from net here.
943 * This is most likely a pointer to one of the
944 * CSSM_TP_CALLERAUTH_CONTEXT.DBList entries but that
945 * is not a strict requirement.
946 */
947 CSSM_DL_DB_HANDLE_PTR crlStore;
948 } CSSM_APPLE_TP_CRL_OPTIONS;
949
950 /*
951 * Options for X509TP's CSSM_TP_CertGroupVerify for policy
952 * CSSMOID_APPLE_TP_SMIME. A pointer to, and length of, one
953 * of these is optionally placed in
954 * CSSM_TP_VERIFY_CONTEXT.Cred->Policy.PolicyIds[n].FieldValue.
955 */
956 #define CSSM_APPLE_TP_SMIME_OPTS_VERSION 0
957 typedef struct {
958 uint32 Version; // CSSM_APPLE_TP_SMIME_OPTS_VERSION
959
960 /*
961 * Intended usage of the leaf cert. The cert's KeyUsage extension,
962 * if present, must be a superset of this.
963 */
964 CE_KeyUsage IntendedUsage;
965
966 /*
967 * The email address of the sender. If there is an email address
968 * in the sender's cert, that email address must match this one.
969 * Both (email address in the cert, and this one) are optional.
970 * Expressed as a C string, optionally NULL terminated (i.e.,
971 * SenderEmail[SenderEmailLen - 1] may or may not be NULL).
972 */
973 uint32 SenderEmailLen;
974 const char *SenderEmail; // optional
975 } CSSM_APPLE_TP_SMIME_OPTIONS;
976
977
978 /*
979 * Optional ActionData for all X509TP CertGroupVerify policies.
980 * A pointer to, and length of, one of these is optionally placed in
981 * CSSM_TP_VERIFY_CONTEXT.ActionData.
982 */
983 typedef uint32 CSSM_APPLE_TP_ACTION_FLAGS;
984 enum {
985 CSSM_TP_ACTION_ALLOW_EXPIRED = 0x00000001, // allow expired certs
986 CSSM_TP_ACTION_LEAF_IS_CA = 0x00000002, // first cert is a CA
987 CSSM_TP_ACTION_FETCH_CERT_FROM_NET = 0x00000004, // enable net fetch of CA cert
988 CSSM_TP_ACTION_ALLOW_EXPIRED_ROOT = 0x00000008, // allow expired roots
989 CSSM_TP_ACTION_REQUIRE_REV_PER_CERT = 0x00000010, // require positive revocation
990 // check per cert
991 CSSM_TP_ACTION_TRUST_SETTINGS = 0x00000020, // use TrustSettings instead of
992 // anchors
993 CSSM_TP_ACTION_IMPLICIT_ANCHORS = 0x00000040 // properly self-signed certs are
994 // treated as anchors implicitly
995 };
996
997 #define CSSM_APPLE_TP_ACTION_VERSION 0
998 typedef struct {
999 uint32 Version; // CSSM_APPLE_TP_ACTION_VERSION
1000 CSSM_APPLE_TP_ACTION_FLAGS ActionFlags; // CSSM_TP_ACTION_ALLOW_EXPIRED, etc.
1001 } CSSM_APPLE_TP_ACTION_DATA;
1002
1003 /*
1004 * Per-cert evidence returned from CSSM_TP_CertGroupVerify.
1005 * An array of these is presented in CSSM_TP_VERIFY_CONTEXT_RESULT.Evidence[2].
1006 * Same number of these as in the cert group in Evidence[1].
1007 */
1008
1009 /* First, an array of bits indicating various status of the cert. */
1010 typedef uint32 CSSM_TP_APPLE_CERT_STATUS;
1011 enum
1012 {
1013 CSSM_CERT_STATUS_EXPIRED = 0x00000001,
1014 CSSM_CERT_STATUS_NOT_VALID_YET = 0x00000002,
1015 CSSM_CERT_STATUS_IS_IN_INPUT_CERTS = 0x00000004,
1016 CSSM_CERT_STATUS_IS_IN_ANCHORS = 0x00000008,
1017 CSSM_CERT_STATUS_IS_ROOT = 0x00000010,
1018 CSSM_CERT_STATUS_IS_FROM_NET = 0x00000020,
1019 /* settings found in per-user Trust Settings */
1020 CSSM_CERT_STATUS_TRUST_SETTINGS_FOUND_USER = 0x00000040,
1021 /* settings found in Admin Trust Settings */
1022 CSSM_CERT_STATUS_TRUST_SETTINGS_FOUND_ADMIN = 0x00000080,
1023 /* settings found in System Trust Settings */
1024 CSSM_CERT_STATUS_TRUST_SETTINGS_FOUND_SYSTEM = 0x00000100,
1025 /* Trust Settings result = Trust */
1026 CSSM_CERT_STATUS_TRUST_SETTINGS_TRUST = 0x00000200,
1027 /* Trust Settings result = Deny */
1028 CSSM_CERT_STATUS_TRUST_SETTINGS_DENY = 0x00000400,
1029 /* Per-cert error ignored due to Trust Settings */
1030 CSSM_CERT_STATUS_TRUST_SETTINGS_IGNORED_ERROR = 0x00000800
1031 };
1032
1033 typedef struct {
1034 CSSM_TP_APPLE_CERT_STATUS StatusBits;
1035 uint32 NumStatusCodes;
1036 CSSM_RETURN *StatusCodes;
1037
1038 /* index into raw cert group or AnchorCerts depending on IS_IN_ANCHORS */
1039 uint32 Index;
1040
1041 /* nonzero if cert came from a DLDB */
1042 CSSM_DL_DB_HANDLE DlDbHandle;
1043 CSSM_DB_UNIQUE_RECORD_PTR UniqueRecord;
1044 } CSSM_TP_APPLE_EVIDENCE_INFO;
1045
1046 /*
1047 * CSSM_TP_VERIFY_CONTEXT_RESULT.Evidence[0], basically defines which version/flavor
1048 * of remaining evidence is.
1049 */
1050 #define CSSM_TP_APPLE_EVIDENCE_VERSION 0
1051 typedef struct
1052 {
1053 uint32 Version;
1054 } CSSM_TP_APPLE_EVIDENCE_HEADER;
1055
1056
1057 /*
1058 * Apple-specific CSSM_EVIDENCE_FORM values
1059 *
1060 * The form of the evidence returns from CSSM_TP_CertGroupVerify is:
1061 *
1062 * EvidenceForm contents of *Evidence
1063 * ------------ ---------------------
1064 * CSSM_EVIDENCE_FORM_APPLE_HEADER CSSM_TP_APPLE_EVIDENCE_HEADER
1065 * CSSM_EVIDENCE_FORM_APPLE_CERTGROUP CSSM_CERTGROUP
1066 * CSSM_EVIDENCE_FORM_APPLE_CERT_INFO array of CSSM_TP_APPLE_EVIDENCE_INFO, size
1067 * CSSM_CERTGROUP.NumCerts
1068 */
1069
1070 #define CSSM_EVIDENCE_FORM_APPLE_CUSTOM 0x80000000
1071 enum
1072 {
1073 CSSM_EVIDENCE_FORM_APPLE_HEADER = CSSM_EVIDENCE_FORM_APPLE_CUSTOM + 0,
1074 CSSM_EVIDENCE_FORM_APPLE_CERTGROUP = CSSM_EVIDENCE_FORM_APPLE_CUSTOM + 1,
1075 CSSM_EVIDENCE_FORM_APPLE_CERT_INFO = CSSM_EVIDENCE_FORM_APPLE_CUSTOM + 2
1076 };
1077
1078 /* AppleX509CL extensions: passthrough ids */
1079 enum {
1080 /*
1081 * Obtain a signed Certificate Signing Request.
1082 * Input = CSSM_APPLE_CL_CSR_REQUEST
1083 * Output = allocated CSSM_DATA which points to a DER-encoded CSR.
1084 */
1085 CSSM_APPLEX509CL_OBTAIN_CSR,
1086
1087 /*
1088 * Perform signature verify of a CSR.
1089 * Input: CSSM_DATA referring to a DER-encoded CSR.
1090 * Output: Nothing, returns CSSMERR_CL_VERIFICATION_FAILURE on
1091 * on failure.
1092 */
1093 CSSM_APPLEX509CL_VERIFY_CSR
1094 };
1095
1096 /*
1097 * Used in CL's CSSM_APPLEX509_OBTAIN_CSR Passthrough. This is the
1098 * input; the output is a CSSM_DATA * containing the signed and
1099 * DER-encoded CSR.
1100 */
1101 typedef struct {
1102 CSSM_X509_NAME_PTR subjectNameX509;
1103
1104 /* Unfortunately there is no practical way to map any algorithm
1105 * to its appropriate OID, and we need both.... */
1106 CSSM_ALGORITHMS signatureAlg; // e.g., CSSM_ALGID_SHA1WithRSA
1107 CSSM_OID signatureOid; // e.g., CSSMOID_SHA1WithRSA
1108
1109 CSSM_CSP_HANDLE cspHand; // sign with this CSP
1110 const CSSM_KEY *subjectPublicKey;
1111 const CSSM_KEY *subjectPrivateKey;
1112
1113 /*
1114 * Optional challenge string.
1115 */
1116 const char *challengeString;
1117 } CSSM_APPLE_CL_CSR_REQUEST;
1118
1119 /*
1120 * When a CRL with no NextUpdate field is encountered, we use this time
1121 * as the NextUpdate attribute when storing in a DB. It represents the
1122 * virtual end of time in CSSM_TIMESTRING form.
1123 */
1124 #define CSSM_APPLE_CRL_END_OF_TIME "99991231235959"
1125
1126 /*
1127 * Default filesystem names and locations for SecurityServer features
1128 * (included here for lack of a better place)
1129 */
1130 #define kKeychainSuffix ".keychain"
1131 #define kSystemKeychainName "System.keychain"
1132 #define kSystemKeychainDir "/Library/Keychains/"
1133 #define kSystemUnlockFile "/var/db/SystemKey"
1134
1135
1136 void cssmPerror(const char *how, CSSM_RETURN error);
1137
1138 /* Convert between CSSM_OID and CSSM_ALGORITHMS */
1139 bool cssmOidToAlg(const CSSM_OID *oid, CSSM_ALGORITHMS *alg);
1140 const CSSM_OID *cssmAlgToOid(CSSM_ALGORITHMS algId);
1141
1142 /*
1143 * The MacOS OSStatus space has an embedding for UNIX errno values, similar to
1144 * the way we embed CSSM_RETURN values in OSStatus. These are the base and limit
1145 * values for this embedding.
1146 */
1147 #define errSecErrnoBase 100000
1148 #define errSecErrnoLimit 100255
1149
1150 #ifdef __cplusplus
1151 }
1152 #endif // __cplusplus
1153
1154 #endif /* _CSSMAPPLE_H_ */