]> git.saurik.com Git - apple/security.git/blob - Security/libsecurity_cssm/lib/cssmapple.h
Security-57031.1.35.tar.gz
[apple/security.git] / Security / libsecurity_cssm / lib / cssmapple.h
1 /*
2 * Copyright (c) 2000-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 * 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 /* Required name or identifier not present */
537 CSSMERR_APPLETP_IDENTIFIER_MISSING = CSSM_TP_PRIVATE_ERROR + 59,
538 /* Certificate authority pinning mismatch */
539 CSSMERR_APPLETP_CA_PIN_MISMATCH = CSSM_TP_PRIVATE_ERROR + 60
540 };
541
542 /* Apple .mac TP private error codes. */
543 enum
544 {
545 /* cert request queued */
546 CSSMERR_APPLE_DOTMAC_REQ_QUEUED = CSSM_TP_PRIVATE_ERROR + 100,
547 /* cert request redirected */
548 CSSMERR_APPLE_DOTMAC_REQ_REDIRECT = CSSM_TP_PRIVATE_ERROR + 101,
549 /* general server-reported error */
550 CSSMERR_APPLE_DOTMAC_REQ_SERVER_ERR = CSSM_TP_PRIVATE_ERROR + 102,
551 /* server-reported parameter error */
552 CSSMERR_APPLE_DOTMAC_REQ_SERVER_PARAM = CSSM_TP_PRIVATE_ERROR + 103,
553 /* server-reported authorization error */
554 CSSMERR_APPLE_DOTMAC_REQ_SERVER_AUTH = CSSM_TP_PRIVATE_ERROR + 104,
555 /* server-reported unimplemented */
556 CSSMERR_APPLE_DOTMAC_REQ_SERVER_UNIMPL = CSSM_TP_PRIVATE_ERROR + 105,
557 /* server-reported not available */
558 CSSMERR_APPLE_DOTMAC_REQ_SERVER_NOT_AVAIL = CSSM_TP_PRIVATE_ERROR + 106,
559 /* server-reported already exists */
560 CSSMERR_APPLE_DOTMAC_REQ_SERVER_ALREADY_EXIST = CSSM_TP_PRIVATE_ERROR + 107,
561 /* server-reported service error */
562 CSSMERR_APPLE_DOTMAC_REQ_SERVER_SERVICE_ERROR = CSSM_TP_PRIVATE_ERROR + 108,
563 /* request already pending for specified user */
564 CSSMERR_APPLE_DOTMAC_REQ_IS_PENDING = CSSM_TP_PRIVATE_ERROR + 109,
565 /* no request pending for specified user */
566 CSSMERR_APPLE_DOTMAC_NO_REQ_PENDING = CSSM_TP_PRIVATE_ERROR + 110,
567 /* CSR failed to verify */
568 CSSMERR_APPLE_DOTMAC_CSR_VERIFY_FAIL = CSSM_TP_PRIVATE_ERROR + 111,
569 /* server reported failed consistency check */
570 CSSMERR_APPLE_DOTMAC_FAILED_CONSISTENCY_CHECK = CSSM_TP_PRIVATE_ERROR + 112
571 };
572
573 enum
574 {
575 CSSM_APPLEDL_OPEN_PARAMETERS_VERSION = 1
576 };
577
578 enum cssm_appledl_open_parameters_mask
579 {
580 kCSSM_APPLEDL_MASK_MODE = (1 << 0)
581 };
582
583 /* Pass a CSSM_APPLEDL_OPEN_PARAMETERS_PTR as the OpenParameters argument to
584 CSSM_DL_DbCreate or CSSM_DL_DbOpen. When using this struct, you must zero
585 out the entire struct before setting any additional parameters to ensure
586 forward compatibility. */
587 typedef struct cssm_appledl_open_parameters
588 {
589 uint32 length; /* Should be sizeof(CSSM_APPLEDL_OPEN_PARAMETERS). */
590 uint32 version; /* Should be CSSM_APPLEDL_OPEN_PARAMETERS_VERSION. */
591
592 /* If no OpenParameters are specified, autoCommit is on (!CSSM_FALSE) by default.
593 When autoCommit is on (!CSSM_FALSE), changes made to the Db are written to disk
594 before returning from each function.
595 When autoCommit is off (CSSM_FALSE), changes made to the database are not guaranteed
596 to be written to disk until the Db is closed. This is useful for bulk writes.
597 Be aware that if autoCommit is off, changes made in previous calls to the DL might
598 get rolled back if a new modification operation fails. */
599 CSSM_BOOL autoCommit;
600
601 /* Mask marking which of the following fields are to be used. */
602 uint32 mask;
603
604 /* 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. */
605 mode_t mode;
606 } CSSM_APPLEDL_OPEN_PARAMETERS, *CSSM_APPLEDL_OPEN_PARAMETERS_PTR;
607
608
609 /* AppleCSPDL passthough ids */
610 enum
611 {
612 /* Tell the SecurityServer to lock the database specified by the DLDBHandle argument.
613 The InputParams and OutputParams arguments are ignored. */
614 CSSM_APPLECSPDL_DB_LOCK = 0,
615
616 /* Tell the SecurityServer to unlock the database specified by the DLDBHandle argument.
617 The InputParameters argument is a CSSM_DATA_PTR containing the password, or NULL if
618 the SecurityServer should prompt for the password.
619 The OutputParams argument is ignored.
620 The SecurityServer will put up UI (though the SecurityAgent) when this function is called
621 iff InputParameters is NULL. */
622 CSSM_APPLECSPDL_DB_UNLOCK = 1,
623
624 /* Ask the SecurityServer to get the db settings specified for the database
625 specified by the DLDBHandle argument. The settings are returned in the OutputParameters argument.
626 The OutputParameters argument is a pointer to a CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS_PTR.
627 Upon successful completion, the AppleCSPDL will have allocated a
628 CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS structure using the application-specified
629 allocators for the DL attachment specified by the DLDBHandle argument. The structure will contain
630 the current database settings for the specified database. The client should free the
631 CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS_PTR after it has finished using it.
632 The InputParameters argument is ignored.
633 The SecurityServer might put up UI (though the SecurityAgent) when this function is called. */
634 CSSM_APPLECSPDL_DB_GET_SETTINGS = 2,
635
636 /* Tell the SecurityServer to set the db settings specified in InputParameters on the database
637 specified by the DLDBHandle argument.
638 The InputParameters argument is a const CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS * containing
639 the new settings for the specified database.
640 The OutputParams argument is ignored.
641 The SecurityServer might put up UI (though the SecurityAgent) when this function is called. */
642 CSSM_APPLECSPDL_DB_SET_SETTINGS = 3,
643
644 /* Ask the SecurityServer whether the database specified by the DLDBHandle argument is locked.
645 The InputParameters argument is ignored.
646 The OutputParameters argument is a pointer to a CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS_PTR.
647 Upon successful completion, the AppleCSPDL will have allocated a
648 CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS structure using the application-specified
649 allocators for the DL attachment specified by the DLDBHandle argument. The structure will contain
650 the current lock status for the specified database. The client should free the
651 CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS_PTR after it has finished using it.
652 The SecurityServer will put up UI (though the SecurityAgent) when this function is called. */
653 CSSM_APPLECSPDL_DB_IS_LOCKED = 4,
654
655 /* Tell the SecurityServer to change the password for the database specified by
656 the DLDBHandle.
657
658 The InputParameters argument is a const CSSM_APPLECSPDL_DB_CHANGE_PASSWORD_PARAMETERS * containing
659 a CSSM_ACCESS_CREDENTIALS * which determines how the password will be changed. If the
660 accessCredentials are NULL, the SecurityAgent will prompt for the old and the new password for the
661 specified database. If credentials are specified, there should be 2 entries:
662 1. a 3-element list containing:
663 CSSM_WORDID_KEYCHAIN_LOCK, CSSM_SAMPLE_TYPE_PASSWORD, and the old password.
664 2. a 3-element list containing:
665 CSSM_WORDID_KEYCHAIN_CHANGE_LOCK, CSSM_SAMPLE_TYPE_PASSWORD, and the new password.
666
667 The OutputParams argument is ignored.
668 The SecurityServer might put up UI (though the SecurityAgent) when this function is called. */
669 CSSM_APPLECSPDL_DB_CHANGE_PASSWORD =5,
670
671 /* Return the SecurityServer database handle for the database specified by the DLDBHandle */
672 CSSM_APPLECSPDL_DB_GET_HANDLE = 6,
673
674 /* Given a CSSM_KEY for the CSPDL, return the SecurityServer key handle */
675 CSSM_APPLESCPDL_CSP_GET_KEYHANDLE = 7,
676
677 CSSM_APPLE_PRIVATE_CSPDL_CODE_8 = 8,
678 CSSM_APPLE_PRIVATE_CSPDL_CODE_9 = 9,
679 CSSM_APPLE_PRIVATE_CSPDL_CODE_10 = 10,
680 CSSM_APPLE_PRIVATE_CSPDL_CODE_11 = 11,
681 CSSM_APPLE_PRIVATE_CSPDL_CODE_12 = 12,
682 CSSM_APPLE_PRIVATE_CSPDL_CODE_13 = 13,
683 CSSM_APPLE_PRIVATE_CSPDL_CODE_14 = 14,
684 CSSM_APPLE_PRIVATE_CSPDL_CODE_15 = 15,
685 CSSM_APPLE_PRIVATE_CSPDL_CODE_16 = 16,
686 CSSM_APPLE_PRIVATE_CSPDL_CODE_17 = 17,
687 CSSM_APPLE_PRIVATE_CSPDL_CODE_18 = 18,
688
689 /* Given a CSSM_KEY_PTR in any format, obtain the SHA-1 hash of the
690 * associated key blob.
691 * Key is specified in CSSM_CSP_CreatePassThroughContext.
692 * Hash is allocated bythe CSP, in the App's memory, and returned
693 * in *outData. */
694 CSSM_APPLECSP_KEYDIGEST = 0x100
695 };
696
697
698
699 /* AppleCSPDL passthough parameters */
700 typedef struct cssm_applecspdl_db_settings_parameters
701 {
702 uint32 idleTimeout; // seconds idle timeout lock
703 uint8 lockOnSleep; // lock database when system sleeps
704 } CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS, *CSSM_APPLECSPDL_DB_SETTINGS_PARAMETERS_PTR;
705
706 /* AppleCSPDL passthough parameters */
707 typedef struct cssm_applecspdl_db_is_locked_parameters
708 {
709 uint8 isLocked; // True iff the database is locked
710 } CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS, *CSSM_APPLECSPDL_DB_IS_LOCKED_PARAMETERS_PTR;
711
712 /* AppleCSPDL passthough parameters */
713 typedef struct cssm_applecspdl_db_change_password_parameters
714 {
715 CSSM_ACCESS_CREDENTIALS *accessCredentials;
716 } CSSM_APPLECSPDL_DB_CHANGE_PASSWORD_PARAMETERS, *CSSM_APPLECSPDL_DB_CHANGE_PASSWORD_PARAMETERS_PTR;
717
718 /* Custom wrapped key formats */
719 enum {
720 CSSM_KEYBLOB_WRAPPED_FORMAT_APPLE_CUSTOM = 100,
721 CSSM_KEYBLOB_WRAPPED_FORMAT_OPENSSL, // traditional openssl
722 CSSM_KEYBLOB_WRAPPED_FORMAT_OPENSSH1 // OpenSSH v1
723 };
724
725 /*
726 * Custom context attributes for AppleCSP.
727 */
728 enum {
729 CSSM_ATTRIBUTE_VENDOR_DEFINED = 0x800000
730 };
731
732 enum {
733 /*
734 * Public Key attribute for use with CSSM_ALGID_FEED.
735 */
736 CSSM_ATTRIBUTE_PUBLIC_KEY =
737 (CSSM_ATTRIBUTE_DATA_KEY | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 0)),
738
739 /*
740 * FEE key attributes.
741 * See CSSM_FEE_PRIME_TYPE_xxx, CSSM_FEE_CURVE_TYPE_xxx enums, below.
742 */
743 CSSM_ATTRIBUTE_FEE_PRIME_TYPE =
744 (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 1)),
745 CSSM_ATTRIBUTE_FEE_CURVE_TYPE =
746 (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 2)),
747
748 /*
749 * Apple Secure Compression (ComCryption) optimization.
750 * See CSSM_ASC_OPTIMIZE_xxx, enums, below.
751 */
752 CSSM_ATTRIBUTE_ASC_OPTIMIZATION =
753 (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 3)),
754
755 /*
756 * RSA blinding. Value is integer, nonzero (blinding on) or zero.
757 */
758 CSSM_ATTRIBUTE_RSA_BLINDING =
759 (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 4)),
760
761 /*
762 * Additional public key from which to obtain algorithm-specific
763 * parameters.
764 */
765 CSSM_ATTRIBUTE_PARAM_KEY =
766 (CSSM_ATTRIBUTE_DATA_KEY | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 5)),
767
768 /*
769 * Prompt string for CSSM_ALGID_SECURE_PASSPHRASE key acquisition.
770 * Data is a UTF8-encoded external representation of a CFString.
771 */
772 CSSM_ATTRIBUTE_PROMPT =
773 (CSSM_ATTRIBUTE_DATA_CSSM_DATA | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 6)),
774
775 /*
776 * Alert panel title for CSSM_ALGID_SECURE_PASSPHRASE key acquisition.
777 * Data is a UTF8-encoded external representation of a CFString.
778 */
779 CSSM_ATTRIBUTE_ALERT_TITLE =
780 (CSSM_ATTRIBUTE_DATA_CSSM_DATA | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 7)),
781
782 /*
783 * Boolean to specify whether secure passphrase is being used to encrypt or to
784 * recover data. In the former case the user will be prompted to enter the
785 * passphrase twice. Value is integer, nonzero (verify passphrase) or zero.
786 */
787 CSSM_ATTRIBUTE_VERIFY_PASSPHRASE =
788 (CSSM_ATTRIBUTE_DATA_UINT32 | (CSSM_ATTRIBUTE_VENDOR_DEFINED + 8))
789
790 };
791
792 /*
793 * FEE key pair prime modulus types.
794 */
795 enum {
796 CSSM_FEE_PRIME_TYPE_DEFAULT = 0, /* default per key size */
797 CSSM_FEE_PRIME_TYPE_MERSENNE, /* (2 ** q) - 1Ê*/
798 CSSM_FEE_PRIME_TYPE_FEE, /* (2 ** q) - k */
799 CSSM_FEE_PRIME_TYPE_GENERAL /* random prime */
800 };
801
802 /*
803 * FEE curve types. Comments refer to equation
804 *
805 * y**2 = x**3 + c(x**2) + ax + b
806 */
807 enum {
808 CSSM_FEE_CURVE_TYPE_DEFAULT = 0, /* default per key size */
809 CSSM_FEE_CURVE_TYPE_MONTGOMERY, /* a==1, b==0 */
810 CSSM_FEE_CURVE_TYPE_WEIERSTRASS, /* c==0. IEEE P1363 compliant. */
811 CSSM_FEE_CURVE_TYPE_ANSI_X9_62 /* ANSI X9.62 compatible */
812 };
813
814 /*
815 * Apple Secure Compression (ComCryption) optimization attributes.
816 */
817 enum {
818 CSSM_ASC_OPTIMIZE_DEFAULT = 0,
819 CSSM_ASC_OPTIMIZE_SIZE, /* max compression (currently the default) */
820 CSSM_ASC_OPTIMIZE_SECURITY, /* currently not implemented */
821 CSSM_ASC_OPTIMIZE_TIME, /* min runtime */
822 CSSM_ASC_OPTIMIZE_TIME_SIZE, /* implies loss of security */
823 CSSM_ASC_OPTIMIZE_ASCII, /* optimized for ASCC text, not implemented */
824 };
825
826 /*
827 * Apple custom CSSM_KEYATTR_FLAGS.
828 */
829 enum {
830 /*
831 * When set, indicates a public key which is incomplete (though
832 * still valid) due to the lack of algorithm-specific parameters.
833 */
834 CSSM_KEYATTR_PARTIAL = 0x00010000,
835
836 /*
837 * When set, public keys are stored encrypted. Default is to store
838 * public keys in the clear. AppleCSPDL only.
839 */
840 CSSM_KEYATTR_PUBLIC_KEY_ENCRYPT = 0x00020000
841 };
842
843 /*
844 * Name/OID pair used in CSSM_APPLE_TP_CERT_REQUEST
845 */
846 typedef struct {
847 const char *string;
848 const CSSM_OID *oid;
849 } CSSM_APPLE_TP_NAME_OID;
850
851 /*
852 * Certificate request passed to CSSM_TP_SubmitCredRequest() in the
853 * CSSM_TP_AUTHORITY_REQUEST_TYPE.Requests field. Used for requesting
854 * both locally-generated certs (CSSMOID_APPLE_TP_LOCAL_CERT_GEN) and
855 * cert signing requests (CSSMOID_APPLE_TP_CSR_GEN).
856 */
857 typedef struct {
858 CSSM_CSP_HANDLE cspHand; // sign with this CSP
859 CSSM_CL_HANDLE clHand; // and this CL
860 uint32 serialNumber;
861 uint32 numSubjectNames;// size subjectNames[]
862 CSSM_APPLE_TP_NAME_OID *subjectNames;
863
864 /*
865 * Issuer name can be expressed in the simplified CSSM_APPLE_TP_NAME_OID
866 * array, as is the subject name, or as an CSSM_X509_NAME, which is
867 * typically obtained from a signing cert.
868 * Exactly one of {issuerNames, issuerNameX509} must be non-NULL.
869 */
870 uint32 numIssuerNames; // size issuerNames[]
871 CSSM_APPLE_TP_NAME_OID *issuerNames; // optional; NULL implies root
872 // (signer == subject)
873 CSSM_X509_NAME_PTR issuerNameX509;
874 const CSSM_KEY *certPublicKey;
875 const CSSM_KEY *issuerPrivateKey;
876
877 /* Unfortunately there is no practical way to map any algorithm
878 * to its appropriate OID, and we need both.... */
879 CSSM_ALGORITHMS signatureAlg; // e.g., CSSM_ALGID_SHA1WithRSA
880 CSSM_OID signatureOid; // e.g., CSSMOID_SHA1WithRSA
881 uint32 notBefore; // relative to "now"
882 uint32 notAfter;
883 uint32 numExtensions;
884 CE_DataAndType *extensions; // optional
885
886 /*
887 * Optional challenge string for CSSMOID_APPLE_TP_CSR_GEN.
888 */
889 const char *challengeString;
890 } CSSM_APPLE_TP_CERT_REQUEST;
891
892 /*
893 * Options for X509TP's CSSM_TP_CertGroupVerify for policy CSSMOID_APPLE_TP_SSL.
894 * A pointer to, and length of, one of these is optionally placed in
895 * CSSM_TP_VERIFY_CONTEXT.Cred->Policy.PolicyIds[n].FieldValue.
896 */
897 #define CSSM_APPLE_TP_SSL_OPTS_VERSION 1
898
899 /*
900 * Values for CSSM_APPLE_TP_SSL_OPTIONS.flags.
901 *
902 * Set this flag when evaluating a client cert.
903 */
904 #define CSSM_APPLE_TP_SSL_CLIENT 0x00000001
905
906 typedef struct {
907 uint32 Version; // CSSM_APPLE_TP_SSL_OPTS_VERSION
908
909 /*
910 * The domain name of the server (e.g., "store.apple.com".) In the
911 * SSL and TLS protocols, this must match the common name of the
912 * subject cert. Expressed as a C string, optionally NULL terminated
913 * if it is NULL terminated, the length field should include the NULL).
914 */
915 uint32 ServerNameLen;
916 const char *ServerName; // optional
917
918 /* new fields for struct version 1 */
919 uint32 Flags;
920 } CSSM_APPLE_TP_SSL_OPTIONS;
921
922 /*
923 * Options for X509TP's CSSM_TP_CertGroupVerify for policy
924 * CSSMOID_APPLE_TP_REVOCATION_CRL. A pointer to, and length of, one
925 * of these is optionally placed in
926 * CSSM_TP_VERIFY_CONTEXT.Cred->Policy.PolicyIds[n].FieldValue.
927 */
928 #define CSSM_APPLE_TP_CRL_OPTS_VERSION 0
929
930 typedef uint32 CSSM_APPLE_TP_CRL_OPT_FLAGS;
931 enum {
932 // require CRL verification for each cert; default is "try"
933 CSSM_TP_ACTION_REQUIRE_CRL_PER_CERT = 0x00000001,
934 // enable fetch from network
935 CSSM_TP_ACTION_FETCH_CRL_FROM_NET = 0x00000002,
936 // if set and positive OCSP verify for given cert, no further revocation
937 // checking need be done on that cert
938 CSSM_TP_ACTION_CRL_SUFFICIENT = 0x00000004,
939 // require CRL verification for certs which claim a CRL provider
940 CSSM_TP_ACTION_REQUIRE_CRL_IF_PRESENT = 0x00000008
941 };
942
943 typedef struct {
944 uint32 Version; // CSSM_APPLE_TP_CRL_OPTS_VERSION
945 CSSM_APPLE_TP_CRL_OPT_FLAGS CrlFlags;
946
947 /*
948 * When non-NULL, store CRLs fetched from net here.
949 * This is most likely a pointer to one of the
950 * CSSM_TP_CALLERAUTH_CONTEXT.DBList entries but that
951 * is not a strict requirement.
952 */
953 CSSM_DL_DB_HANDLE_PTR crlStore;
954 } CSSM_APPLE_TP_CRL_OPTIONS;
955
956 /*
957 * Options for X509TP's CSSM_TP_CertGroupVerify for policy
958 * CSSMOID_APPLE_TP_SMIME. A pointer to, and length of, one
959 * of these is optionally placed in
960 * CSSM_TP_VERIFY_CONTEXT.Cred->Policy.PolicyIds[n].FieldValue.
961 */
962 #define CSSM_APPLE_TP_SMIME_OPTS_VERSION 0
963 typedef struct {
964 uint32 Version; // CSSM_APPLE_TP_SMIME_OPTS_VERSION
965
966 /*
967 * Intended usage of the leaf cert. The cert's KeyUsage extension,
968 * if present, must be a superset of this.
969 */
970 CE_KeyUsage IntendedUsage;
971
972 /*
973 * The email address of the sender. If there is an email address
974 * in the sender's cert, that email address must match this one.
975 * Both (email address in the cert, and this one) are optional.
976 * Expressed as a C string, optionally NULL terminated (i.e.,
977 * SenderEmail[SenderEmailLen - 1] may or may not be NULL).
978 */
979 uint32 SenderEmailLen;
980 const char *SenderEmail; // optional
981 } CSSM_APPLE_TP_SMIME_OPTIONS;
982
983
984 /*
985 * Optional ActionData for all X509TP CertGroupVerify policies.
986 * A pointer to, and length of, one of these is optionally placed in
987 * CSSM_TP_VERIFY_CONTEXT.ActionData.
988 */
989 typedef uint32 CSSM_APPLE_TP_ACTION_FLAGS;
990 enum {
991 CSSM_TP_ACTION_ALLOW_EXPIRED = 0x00000001, // allow expired certs
992 CSSM_TP_ACTION_LEAF_IS_CA = 0x00000002, // first cert is a CA
993 CSSM_TP_ACTION_FETCH_CERT_FROM_NET = 0x00000004, // enable net fetch of CA cert
994 CSSM_TP_ACTION_ALLOW_EXPIRED_ROOT = 0x00000008, // allow expired roots
995 CSSM_TP_ACTION_REQUIRE_REV_PER_CERT = 0x00000010, // require positive revocation
996 // check per cert
997 CSSM_TP_ACTION_TRUST_SETTINGS = 0x00000020, // use TrustSettings instead of
998 // anchors
999 CSSM_TP_ACTION_IMPLICIT_ANCHORS = 0x00000040 // properly self-signed certs are
1000 // treated as anchors implicitly
1001 };
1002
1003 #define CSSM_APPLE_TP_ACTION_VERSION 0
1004 typedef struct {
1005 uint32 Version; // CSSM_APPLE_TP_ACTION_VERSION
1006 CSSM_APPLE_TP_ACTION_FLAGS ActionFlags; // CSSM_TP_ACTION_ALLOW_EXPIRED, etc.
1007 } CSSM_APPLE_TP_ACTION_DATA;
1008
1009 /*
1010 * Per-cert evidence returned from CSSM_TP_CertGroupVerify.
1011 * An array of these is presented in CSSM_TP_VERIFY_CONTEXT_RESULT.Evidence[2].
1012 * Same number of these as in the cert group in Evidence[1].
1013 */
1014
1015 /* First, an array of bits indicating various status of the cert. */
1016 typedef uint32 CSSM_TP_APPLE_CERT_STATUS;
1017 enum
1018 {
1019 CSSM_CERT_STATUS_EXPIRED = 0x00000001,
1020 CSSM_CERT_STATUS_NOT_VALID_YET = 0x00000002,
1021 CSSM_CERT_STATUS_IS_IN_INPUT_CERTS = 0x00000004,
1022 CSSM_CERT_STATUS_IS_IN_ANCHORS = 0x00000008,
1023 CSSM_CERT_STATUS_IS_ROOT = 0x00000010,
1024 CSSM_CERT_STATUS_IS_FROM_NET = 0x00000020,
1025 /* settings found in per-user Trust Settings */
1026 CSSM_CERT_STATUS_TRUST_SETTINGS_FOUND_USER = 0x00000040,
1027 /* settings found in Admin Trust Settings */
1028 CSSM_CERT_STATUS_TRUST_SETTINGS_FOUND_ADMIN = 0x00000080,
1029 /* settings found in System Trust Settings */
1030 CSSM_CERT_STATUS_TRUST_SETTINGS_FOUND_SYSTEM = 0x00000100,
1031 /* Trust Settings result = Trust */
1032 CSSM_CERT_STATUS_TRUST_SETTINGS_TRUST = 0x00000200,
1033 /* Trust Settings result = Deny */
1034 CSSM_CERT_STATUS_TRUST_SETTINGS_DENY = 0x00000400,
1035 /* Per-cert error ignored due to Trust Settings */
1036 CSSM_CERT_STATUS_TRUST_SETTINGS_IGNORED_ERROR = 0x00000800
1037 };
1038
1039 typedef struct {
1040 CSSM_TP_APPLE_CERT_STATUS StatusBits;
1041 uint32 NumStatusCodes;
1042 CSSM_RETURN *StatusCodes;
1043
1044 /* index into raw cert group or AnchorCerts depending on IS_IN_ANCHORS */
1045 uint32 Index;
1046
1047 /* nonzero if cert came from a DLDB */
1048 CSSM_DL_DB_HANDLE DlDbHandle;
1049 CSSM_DB_UNIQUE_RECORD_PTR UniqueRecord;
1050 } CSSM_TP_APPLE_EVIDENCE_INFO;
1051
1052 /*
1053 * CSSM_TP_VERIFY_CONTEXT_RESULT.Evidence[0], basically defines which version/flavor
1054 * of remaining evidence is.
1055 */
1056 #define CSSM_TP_APPLE_EVIDENCE_VERSION 0
1057 typedef struct
1058 {
1059 uint32 Version;
1060 } CSSM_TP_APPLE_EVIDENCE_HEADER;
1061
1062
1063 /*
1064 * Apple-specific CSSM_EVIDENCE_FORM values
1065 *
1066 * The form of the evidence returns from CSSM_TP_CertGroupVerify is:
1067 *
1068 * EvidenceForm contents of *Evidence
1069 * ------------ ---------------------
1070 * CSSM_EVIDENCE_FORM_APPLE_HEADER CSSM_TP_APPLE_EVIDENCE_HEADER
1071 * CSSM_EVIDENCE_FORM_APPLE_CERTGROUP CSSM_CERTGROUP
1072 * CSSM_EVIDENCE_FORM_APPLE_CERT_INFO array of CSSM_TP_APPLE_EVIDENCE_INFO, size
1073 * CSSM_CERTGROUP.NumCerts
1074 */
1075
1076 #define CSSM_EVIDENCE_FORM_APPLE_CUSTOM 0x80000000
1077 enum
1078 {
1079 CSSM_EVIDENCE_FORM_APPLE_HEADER = CSSM_EVIDENCE_FORM_APPLE_CUSTOM + 0,
1080 CSSM_EVIDENCE_FORM_APPLE_CERTGROUP = CSSM_EVIDENCE_FORM_APPLE_CUSTOM + 1,
1081 CSSM_EVIDENCE_FORM_APPLE_CERT_INFO = CSSM_EVIDENCE_FORM_APPLE_CUSTOM + 2
1082 };
1083
1084 /* AppleX509CL extensions: passthrough ids */
1085 enum {
1086 /*
1087 * Obtain a signed Certificate Signing Request.
1088 * Input = CSSM_APPLE_CL_CSR_REQUEST
1089 * Output = allocated CSSM_DATA which points to a DER-encoded CSR.
1090 */
1091 CSSM_APPLEX509CL_OBTAIN_CSR,
1092
1093 /*
1094 * Perform signature verify of a CSR.
1095 * Input: CSSM_DATA referring to a DER-encoded CSR.
1096 * Output: Nothing, returns CSSMERR_CL_VERIFICATION_FAILURE on
1097 * on failure.
1098 */
1099 CSSM_APPLEX509CL_VERIFY_CSR
1100 };
1101
1102 /*
1103 * Used in CL's CSSM_APPLEX509_OBTAIN_CSR Passthrough. This is the
1104 * input; the output is a CSSM_DATA * containing the signed and
1105 * DER-encoded CSR.
1106 */
1107 typedef struct {
1108 CSSM_X509_NAME_PTR subjectNameX509;
1109
1110 /* Unfortunately there is no practical way to map any algorithm
1111 * to its appropriate OID, and we need both.... */
1112 CSSM_ALGORITHMS signatureAlg; // e.g., CSSM_ALGID_SHA1WithRSA
1113 CSSM_OID signatureOid; // e.g., CSSMOID_SHA1WithRSA
1114
1115 CSSM_CSP_HANDLE cspHand; // sign with this CSP
1116 const CSSM_KEY *subjectPublicKey;
1117 const CSSM_KEY *subjectPrivateKey;
1118
1119 /*
1120 * Optional challenge string.
1121 */
1122 const char *challengeString;
1123 } CSSM_APPLE_CL_CSR_REQUEST;
1124
1125 /*
1126 * When a CRL with no NextUpdate field is encountered, we use this time
1127 * as the NextUpdate attribute when storing in a DB. It represents the
1128 * virtual end of time in CSSM_TIMESTRING form.
1129 */
1130 #define CSSM_APPLE_CRL_END_OF_TIME "99991231235959"
1131
1132 /*
1133 * Default filesystem names and locations for SecurityServer features
1134 * (included here for lack of a better place)
1135 */
1136 #define kKeychainSuffix ".keychain"
1137 #define kSystemKeychainName "System.keychain"
1138 #define kSystemKeychainDir "/Library/Keychains/"
1139 #define kSystemUnlockFile "/var/db/SystemKey"
1140
1141
1142 void cssmPerror(const char *how, CSSM_RETURN error);
1143
1144 /* Convert between CSSM_OID and CSSM_ALGORITHMS */
1145 bool cssmOidToAlg(const CSSM_OID *oid, CSSM_ALGORITHMS *alg);
1146 const CSSM_OID *cssmAlgToOid(CSSM_ALGORITHMS algId);
1147
1148 /*
1149 * The MacOS OSStatus space has an embedding for UNIX errno values, similar to
1150 * the way we embed CSSM_RETURN values in OSStatus. These are the base and limit
1151 * values for this embedding.
1152 */
1153 #define errSecErrnoBase 100000
1154 #define errSecErrnoLimit 100255
1155
1156 #ifdef __cplusplus
1157 }
1158 #endif // __cplusplus
1159
1160 #endif /* _CSSMAPPLE_H_ */