]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/lib/SecBase.cpp
Security-58286.41.2.tar.gz
[apple/security.git] / OSX / libsecurity_keychain / lib / SecBase.cpp
1 /*
2 * Copyright (c) 2003-2013 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
24 #include <Security/SecBase.h>
25 #include <Security/SecBasePriv.h>
26 #include <Security/SecKeychainPriv.h>
27 #include <security_utilities/threading.h>
28 #include <utilities/SecCFRelease.h>
29 #include "SecBridge.h"
30
31 static CFStringRef copyErrorMessageFromBundle(OSStatus status,CFStringRef tableName);
32
33 // caller MUST release the string, since it is gotten with "CFCopyLocalizedStringFromTableInBundle"
34 // intended use of reserved param is to pass in CFStringRef with name of the Table for lookup
35 // Will look by default in "SecErrorMessages.strings" in the resources of Security.framework.
36
37
38 CFStringRef
39 SecCopyErrorMessageString(OSStatus status, void *reserved)
40 {
41 try
42 {
43 CFStringRef result = copyErrorMessageFromBundle(status,CFSTR("SecErrorMessages"));
44 if (result == NULL)
45 result = copyErrorMessageFromBundle(status,CFSTR("SecDebugErrorMessages"));
46
47 if (result == NULL)
48 {
49 if (status >= errSecErrnoBase && status <= errSecErrnoLimit)
50 {
51 result = CFStringCreateWithFormat (NULL, NULL, CFSTR("UNIX[%s]"), strerror(status-errSecErrnoBase));
52 }
53 else
54 {
55 // no error message found, so format a faked-up error message from the status
56 result = CFStringCreateWithFormat(NULL, NULL, CFSTR("OSStatus %d"), (int)status);
57 }
58 }
59
60 return result;
61 }
62 catch (...)
63 {
64 return NULL;
65 }
66 }
67
68
69 void
70 cssmPerror(const char *how, CSSM_RETURN error)
71 {
72 try
73 {
74 const char* errMsg = cssmErrorString(error);
75 fprintf(stderr, "%s: %s\n", how ? how : "error", errMsg);
76 }
77 catch (...)
78 {
79 fprintf(stderr, "failed to print error: %lu\n", (unsigned long)error);
80 }
81 }
82
83
84 const char *
85 cssmErrorString(CSSM_RETURN error)
86 {
87 static ThreadNexus<string> lastError;
88
89 try {
90 string err;
91
92 if (error >= errSecErrnoBase && error <= errSecErrnoLimit)
93 {
94 err = string ("UNIX[") + strerror(error - errSecErrnoBase) + "]";
95 }
96 else
97 {
98 CFStringRef result = copyErrorMessageFromBundle(error,CFSTR("SecErrorMessages"));
99 if (result == NULL)
100 result = copyErrorMessageFromBundle(error,CFSTR("SecDebugErrorMessages"));
101 err = cfString(result, true);
102 CFReleaseSafe(result);
103 }
104
105 if (err.empty())
106 {
107 char buf[200];
108 snprintf(buf, sizeof(buf), "unknown error %ld=%lx", (long) error, (long) error);
109 err = buf;
110 }
111
112 lastError() = err;
113 return lastError().c_str();
114 }
115 catch (...)
116 {
117 char buf[256];
118 snprintf (buf, sizeof (buf), "unknown error %ld=%lx", (long) error, (long) error);
119 lastError() = buf;
120 return lastError().c_str();
121 }
122 }
123
124
125 static ModuleNexus<Mutex> gBundleLock;
126
127 CFStringRef
128 copyErrorMessageFromBundle(OSStatus status,CFStringRef tableName)
129 {
130 StLock<Mutex> _lock(gBundleLock());
131
132 CFStringRef errorString = nil;
133 CFStringRef keyString = nil;
134 CFBundleRef secBundle = NULL;
135
136 // Make a bundle instance using the URLRef.
137 secBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.security"));
138 if (!secBundle)
139 goto xit;
140
141 // Convert status to Int32 string representation, e.g. "-25924"
142 keyString = CFStringCreateWithFormat (kCFAllocatorDefault,NULL,CFSTR("%d"),(int)status);
143 if (!keyString)
144 goto xit;
145
146 errorString = CFCopyLocalizedStringFromTableInBundle(keyString,tableName,secBundle,NULL);
147 if (CFStringCompare(errorString, keyString, 0)==kCFCompareEqualTo) // no real error message
148 {
149 if (errorString)
150 CFRelease(errorString);
151 errorString = nil;
152 }
153 xit:
154 if (keyString)
155 CFRelease(keyString);
156
157 return errorString;
158 }
159
160 /* Convert a possible CSSM type osStatus error to a more Keychain friendly OSStatus. */
161 OSStatus SecKeychainErrFromOSStatus(OSStatus osStatus)
162 {
163 if (CSSM_ERR_IS_CONVERTIBLE(osStatus))
164 {
165 switch (CSSM_ERRCODE(osStatus))
166 {
167 // CONVERTIBLE ERROR CODES.
168 case CSSM_ERRCODE_SERVICE_NOT_AVAILABLE:
169 return errSecNotAvailable;
170 case CSSM_ERRCODE_USER_CANCELED:
171 return errSecUserCanceled;
172 case CSSM_ERRCODE_OPERATION_AUTH_DENIED:
173 return errSecAuthFailed;
174 case CSSM_ERRCODE_NO_USER_INTERACTION:
175 return errSecInteractionNotAllowed;
176 case CSSM_ERRCODE_IN_DARK_WAKE:
177 return errSecInDarkWake;
178 case CSSM_ERRCODE_OS_ACCESS_DENIED:
179 return errSecWrPerm;
180 case CSSM_ERRCODE_INSUFFICIENT_CLIENT_IDENTIFICATION:
181 return errSecInsufficientClientID;
182 case CSSM_ERRCODE_DEVICE_RESET:
183 return errSecDeviceReset;
184 case CSSM_ERRCODE_DEVICE_FAILED:
185 return errSecDeviceFailed;
186 case CSSM_ERRCODE_INTERNAL_ERROR:
187 return errSecInternalError;
188 case CSSM_ERRCODE_MEMORY_ERROR:
189 return errSecMemoryError;
190 case CSSM_ERRCODE_MDS_ERROR:
191 return errSecMDSError;
192 case CSSM_ERRCODE_INVALID_POINTER:
193 case CSSM_ERRCODE_INVALID_INPUT_POINTER:
194 case CSSM_ERRCODE_INVALID_OUTPUT_POINTER:
195 case CSSM_ERRCODE_INVALID_CERTGROUP_POINTER:
196 case CSSM_ERRCODE_INVALID_CERT_POINTER:
197 case CSSM_ERRCODE_INVALID_CRL_POINTER:
198 case CSSM_ERRCODE_INVALID_FIELD_POINTER:
199 case CSSM_ERRCODE_INVALID_DB_LIST_POINTER:
200 return errSecInvalidPointer;
201 case CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED:
202 return errSecUnimplemented;
203 case CSSM_ERRCODE_SELF_CHECK_FAILED:
204 case CSSMERR_CL_SELF_CHECK_FAILED:
205 case CSSMERR_DL_SELF_CHECK_FAILED:
206 return errSecSelfCheckFailed;
207 case CSSM_ERRCODE_FUNCTION_FAILED:
208 return errSecFunctionFailed;
209 case CSSM_ERRCODE_MODULE_MANIFEST_VERIFY_FAILED:
210 return errSecModuleManifestVerifyFailed;
211 case CSSM_ERRCODE_INVALID_GUID:
212 return errSecInvalidGUID;
213 case CSSM_ERRCODE_OBJECT_USE_AUTH_DENIED:
214 case CSSM_ERRCODE_OBJECT_MANIP_AUTH_DENIED:
215 return errAuthorizationDenied;
216 case CSSM_ERRCODE_OBJECT_ACL_NOT_SUPPORTED:
217 case CSSM_ERRCODE_OBJECT_ACL_REQUIRED:
218 case CSSM_ERRCODE_INVALID_ACL_SUBJECT_VALUE:
219 case CSSM_ERRCODE_ACL_SUBJECT_TYPE_NOT_SUPPORTED:
220 case CSSM_ERRCODE_INVALID_ACL_EDIT_MODE:
221 case CSSM_ERRCODE_INVALID_NEW_ACL_ENTRY:
222 case CSSM_ERRCODE_INVALID_NEW_ACL_OWNER:
223 return errSecInvalidACL;
224 case CSSM_ERRCODE_INVALID_ACCESS_CREDENTIALS:
225 return errSecInvalidAccessCredentials;
226 case CSSM_ERRCODE_INVALID_ACL_BASE_CERTS:
227 case CSSM_ERRCODE_ACL_BASE_CERTS_NOT_SUPPORTED:
228 return errSecInvalidCertificateGroup;
229 case CSSM_ERRCODE_INVALID_SAMPLE_VALUE:
230 return errSecInvalidSampleValue;
231 case CSSM_ERRCODE_SAMPLE_VALUE_NOT_SUPPORTED:
232 return errSecInvalidSampleValue;
233 case CSSM_ERRCODE_INVALID_ACL_CHALLENGE_CALLBACK:
234 return errSecInvalidCallback;
235 case CSSM_ERRCODE_ACL_CHALLENGE_CALLBACK_FAILED:
236 return errSecCallbackFailed;
237 case CSSM_ERRCODE_INVALID_ACL_ENTRY_TAG:
238 case CSSM_ERRCODE_UNKNOWN_TAG:
239 return errSecUnknownTag;
240 case CSSM_ERRCODE_ACL_ENTRY_TAG_NOT_FOUND:
241 return errSecTagNotFound;
242 case CSSM_ERRCODE_ACL_CHANGE_FAILED:
243 return errSecACLChangeFailed;
244 case CSSM_ERRCODE_ACL_DELETE_FAILED:
245 return errSecACLDeleteFailed;
246 case CSSM_ERRCODE_ACL_REPLACE_FAILED:
247 return errSecACLReplaceFailed;
248 case CSSM_ERRCODE_ACL_ADD_FAILED:
249 return errSecACLAddFailed;
250 case CSSM_ERRCODE_INVALID_CONTEXT_HANDLE:
251 case CSSM_ERRCODE_INVALID_DB_HANDLE:
252 case CSSM_ERRCODE_INVALID_CSP_HANDLE:
253 case CSSM_ERRCODE_INVALID_DL_HANDLE:
254 case CSSM_ERRCODE_INVALID_CL_HANDLE:
255 case CSSM_ERRCODE_INVALID_TP_HANDLE:
256 case CSSM_ERRCODE_INVALID_KR_HANDLE:
257 case CSSM_ERRCODE_INVALID_AC_HANDLE:
258 return errSecInvalidHandle;
259 case CSSM_ERRCODE_INCOMPATIBLE_VERSION:
260 return errSecIncompatibleVersion;
261 case CSSM_ERRCODE_INVALID_DATA:
262 return errSecInvalidData;
263 case CSSM_ERRCODE_CRL_ALREADY_SIGNED:
264 return errSecCRLAlreadySigned;
265 case CSSM_ERRCODE_INVALID_NUMBER_OF_FIELDS:
266 return errSecInvalidNumberOfFields;
267 case CSSM_ERRCODE_VERIFICATION_FAILURE:
268 return errSecVerificationFailure;
269 case CSSM_ERRCODE_PRIVILEGE_NOT_GRANTED:
270 return errSecPrivilegeNotGranted;
271 case CSSM_ERRCODE_INVALID_DB_LIST:
272 return errSecInvalidDBList;
273 case CSSM_ERRCODE_UNKNOWN_FORMAT:
274 return errSecUnknownFormat;
275 case CSSM_ERRCODE_INVALID_PASSTHROUGH_ID:
276 return errSecInvalidPassthroughID;
277 case CSSM_ERRCODE_INVALID_NETWORK_ADDR:
278 return errSecInvalidNetworkAddress;
279 case CSSM_ERRCODE_INVALID_CRYPTO_DATA:
280 return errSecInvalidData;
281 }
282 }
283 switch (osStatus)
284 {
285 // Some CSSM errors mapped to OSStatus-type (SnowLeopard and earlier).
286 //
287 case CSSMERR_DL_RECORD_NOT_FOUND:
288 case CSSMERR_APPLETP_CERT_NOT_FOUND_FROM_ISSUER:
289 case CSSMERR_CSP_PRIVATE_KEY_NOT_FOUND:
290 return errSecItemNotFound;
291 case CSSMERR_DL_INVALID_UNIQUE_INDEX_DATA:
292 case CSSMERR_CSP_PRIVATE_KEY_ALREADY_EXISTS:
293 case CSSMERR_CSP_KEY_LABEL_ALREADY_EXISTS:
294 return errSecDuplicateItem;
295 case CSSMERR_DL_DATABASE_CORRUPT:
296 return errSecInvalidKeychain;
297 case CSSMERR_DL_DATASTORE_DOESNOT_EXIST:
298 return errSecNoSuchKeychain;
299 case CSSMERR_DL_DATASTORE_ALREADY_EXISTS:
300 return errSecDuplicateKeychain;
301 case CSSMERR_APPLEDL_DISK_FULL:
302 return errSecDskFull;
303 case CSSMERR_DL_INVALID_OPEN_PARAMETERS:
304 case CSSMERR_APPLEDL_INVALID_OPEN_PARAMETERS:
305 case CSSMERR_APPLE_DOTMAC_REQ_SERVER_PARAM:
306 return errSecParam;
307 case CSSMERR_DL_INVALID_FIELD_NAME:
308 case CSSMERR_CSSM_INVALID_ATTRIBUTE:
309 return errSecNoSuchAttr;
310 case CSSMERR_DL_OS_ACCESS_DENIED:
311 case CSSMERR_CSP_OS_ACCESS_DENIED:
312 case CSSMERR_TP_OS_ACCESS_DENIED:
313 case CSSMERR_AC_OS_ACCESS_DENIED:
314 case CSSMERR_CL_OS_ACCESS_DENIED:
315 return errSecWrPerm;
316 case CSSMERR_CSSM_BUFFER_TOO_SMALL:
317 return errSecBufferTooSmall;
318 case CSSMERR_CSSM_FUNCTION_NOT_IMPLEMENTED:
319 case CSSMERR_CSP_FUNCTION_NOT_IMPLEMENTED:
320 case CSSMERR_TP_FUNCTION_NOT_IMPLEMENTED:
321 case CSSMERR_AC_FUNCTION_NOT_IMPLEMENTED:
322 case CSSMERR_CL_FUNCTION_NOT_IMPLEMENTED:
323 case CSSMERR_DL_FUNCTION_NOT_IMPLEMENTED:
324 case CSSMERR_APPLE_DOTMAC_REQ_SERVER_UNIMPL:
325 return errSecUnimplemented;
326 case CSSMERR_CSSM_INTERNAL_ERROR:
327 case CSSMERR_CSP_INTERNAL_ERROR:
328 case CSSMERR_TP_INTERNAL_ERROR:
329 case CSSMERR_AC_INTERNAL_ERROR:
330 case CSSMERR_CL_INTERNAL_ERROR:
331 case CSSMERR_DL_INTERNAL_ERROR:
332 return errSecInternalError;
333 case CSSMERR_CSSM_MEMORY_ERROR:
334 case CSSMERR_CSP_MEMORY_ERROR:
335 case CSSMERR_TP_MEMORY_ERROR:
336 case CSSMERR_AC_MEMORY_ERROR:
337 case CSSMERR_CSP_DEVICE_MEMORY_ERROR:
338 case CSSMERR_CL_MEMORY_ERROR:
339 case CSSMERR_DL_MEMORY_ERROR:
340 return errSecMemoryError;
341 case CSSMERR_CSSM_MDS_ERROR:
342 case CSSMERR_CSP_MDS_ERROR:
343 case CSSMERR_TP_MDS_ERROR:
344 case CSSMERR_AC_MDS_ERROR:
345 case CSSMERR_CL_MDS_ERROR:
346 case CSSMERR_DL_MDS_ERROR:
347 return errSecMDSError;
348 case CSSMERR_CSSM_INVALID_POINTER:
349 case CSSMERR_CSP_INVALID_POINTER:
350 case CSSMERR_TP_INVALID_POINTER:
351 case CSSMERR_AC_INVALID_POINTER:
352 case CSSMERR_CL_INVALID_POINTER:
353 case CSSMERR_DL_INVALID_POINTER:
354 case CSSMERR_CSSM_INVALID_INPUT_POINTER:
355 case CSSMERR_CSP_INVALID_INPUT_POINTER:
356 case CSSMERR_TP_INVALID_INPUT_POINTER:
357 case CSSMERR_AC_INVALID_INPUT_POINTER:
358 case CSSMERR_CL_INVALID_INPUT_POINTER:
359 case CSSMERR_DL_INVALID_INPUT_POINTER:
360 case CSSMERR_TP_INVALID_DB_LIST_POINTER:
361 case CSSMERR_AC_INVALID_DB_LIST_POINTER:
362 case CSSMERR_DL_INVALID_DB_LIST_POINTER:
363 case CSSMERR_TP_INVALID_CERTGROUP_POINTER:
364 case CSSMERR_TP_INVALID_CERT_POINTER:
365 case CSSMERR_TP_INVALID_CRL_POINTER:
366 case CSSMERR_TP_INVALID_FIELD_POINTER:
367 case CSSMERR_CSP_INVALID_KEY_POINTER:
368 case CSSMERR_TP_INVALID_CALLERAUTH_CONTEXT_POINTER:
369 case CSSMERR_TP_INVALID_IDENTIFIER_POINTER:
370 case CSSMERR_TP_INVALID_CRLGROUP_POINTER:
371 case CSSMERR_TP_INVALID_TUPLEGROUP_POINTER:
372 case CSSMERR_CL_INVALID_CERTGROUP_POINTER:
373 case CSSMERR_CL_INVALID_CERT_POINTER:
374 case CSSMERR_CL_INVALID_CRL_POINTER:
375 case CSSMERR_CL_INVALID_FIELD_POINTER:
376 case CSSMERR_CL_INVALID_BUNDLE_POINTER:
377 case CSSMERR_CSSM_INVALID_OUTPUT_POINTER:
378 case CSSMERR_CSP_INVALID_OUTPUT_POINTER:
379 case CSSMERR_TP_INVALID_OUTPUT_POINTER:
380 case CSSMERR_AC_INVALID_OUTPUT_POINTER:
381 case CSSMERR_CL_INVALID_OUTPUT_POINTER:
382 case CSSMERR_DL_INVALID_OUTPUT_POINTER:
383 return errSecInvalidPointer;
384 case CSSMERR_CSSM_FUNCTION_FAILED:
385 case CSSMERR_CSP_FUNCTION_FAILED:
386 case CSSMERR_TP_FUNCTION_FAILED:
387 case CSSMERR_AC_FUNCTION_FAILED:
388 case CSSMERR_CL_FUNCTION_FAILED:
389 case CSSMERR_DL_FUNCTION_FAILED:
390 return errSecFunctionFailed;
391 case CSSMERR_CSP_INVALID_DATA:
392 case CSSMERR_TP_INVALID_DATA:
393 case CSSMERR_AC_INVALID_DATA:
394 case CSSMERR_CL_INVALID_DATA:
395 case CSSMERR_CSP_INVALID_CRYPTO_DATA:
396 case CSSMERR_CSP_INVALID_DATA_COUNT:
397 case CSSMERR_TP_INVALID_ACTION_DATA:
398 return errSecInvalidData;
399 case CSSMERR_TP_INVALID_DB_LIST:
400 case CSSMERR_AC_INVALID_DB_LIST:
401 return errSecInvalidDBList;
402 case CSSMERR_CSP_INVALID_PASSTHROUGH_ID:
403 case CSSMERR_TP_INVALID_PASSTHROUGH_ID:
404 case CSSMERR_AC_INVALID_PASSTHROUGH_ID:
405 case CSSMERR_CL_INVALID_PASSTHROUGH_ID:
406 case CSSMERR_DL_INVALID_PASSTHROUGH_ID:
407 return errSecInvalidPassthroughID;
408 case CSSMERR_TP_INVALID_CSP_HANDLE:
409 case CSSMERR_TP_INVALID_CL_HANDLE:
410 case CSSMERR_TP_INVALID_DL_HANDLE:
411 case CSSMERR_AC_INVALID_TP_HANDLE:
412 case CSSMERR_AC_INVALID_DL_HANDLE:
413 case CSSMERR_DL_INVALID_DL_HANDLE:
414 case CSSMERR_AC_INVALID_CL_HANDLE:
415 case CSSMERR_DL_INVALID_CL_HANDLE:
416 case CSSMERR_DL_INVALID_CSP_HANDLE:
417 case CSSMERR_TP_INVALID_DB_HANDLE:
418 case CSSMERR_CSSM_INVALID_ADDIN_HANDLE:
419 case CSSMERR_CSSM_INVALID_CONTEXT_HANDLE:
420 case CSSMERR_CL_INVALID_CACHE_HANDLE:
421 case CSSMERR_CL_INVALID_RESULTS_HANDLE:
422 case CSSMERR_DL_INVALID_RESULTS_HANDLE:
423 case CSSMERR_TP_INVALID_KEYCACHE_HANDLE:
424 case CSSMERR_CSP_INVALID_CONTEXT_HANDLE:
425 case CSSMERR_TP_INVALID_CONTEXT_HANDLE:
426 case CSSMERR_AC_INVALID_CONTEXT_HANDLE:
427 case CSSMERR_CL_INVALID_CONTEXT_HANDLE:
428 return errSecInvalidHandle;
429 case CSSMERR_TP_CRL_ALREADY_SIGNED:
430 case CSSMERR_CL_CRL_ALREADY_SIGNED:
431 return errSecCRLAlreadySigned;
432 case CSSMERR_TP_INVALID_NUMBER_OF_FIELDS:
433 case CSSMERR_CL_INVALID_NUMBER_OF_FIELDS:
434 return errSecInvalidNumberOfFields;
435 case CSSMERR_TP_VERIFICATION_FAILURE:
436 case CSSMERR_CL_VERIFICATION_FAILURE:
437 return errSecVerificationFailure;
438 case CSSMERR_TP_INVALID_NETWORK_ADDR:
439 case CSSMERR_DL_INVALID_NETWORK_ADDR:
440 return errSecInvalidNetworkAddress;
441 case CSSMERR_TP_UNKNOWN_TAG:
442 case CSSMERR_CL_UNKNOWN_TAG:
443 case CSSMERR_CSP_INVALID_ACL_ENTRY_TAG:
444 case CSSMERR_DL_INVALID_ACL_ENTRY_TAG:
445 case CSSMERR_DL_INVALID_SELECTION_TAG:
446 return errSecUnknownTag;
447 case CSSMERR_CSP_INVALID_SIGNATURE:
448 case CSSMERR_TP_INVALID_SIGNATURE:
449 return errSecInvalidSignature;
450 case CSSMERR_CSSM_USER_CANCELED:
451 case CSSMERR_CSP_USER_CANCELED:
452 case CSSMERR_TP_USER_CANCELED:
453 case CSSMERR_AC_USER_CANCELED:
454 case CSSMERR_CL_USER_CANCELED:
455 case CSSMERR_DL_USER_CANCELED:
456 return errSecUserCanceled;
457 case CSSMERR_CSSM_NO_USER_INTERACTION:
458 case CSSMERR_CSP_NO_USER_INTERACTION:
459 case CSSMERR_TP_NO_USER_INTERACTION:
460 case CSSMERR_AC_NO_USER_INTERACTION:
461 case CSSMERR_CL_NO_USER_INTERACTION:
462 case CSSMERR_DL_NO_USER_INTERACTION:
463 return errSecInteractionNotAllowed;
464 case CSSMERR_CSSM_IN_DARK_WAKE:
465 case CSSMERR_CSP_IN_DARK_WAKE:
466 case CSSMERR_TP_IN_DARK_WAKE:
467 case CSSMERR_AC_IN_DARK_WAKE:
468 case CSSMERR_CL_IN_DARK_WAKE:
469 case CSSMERR_DL_IN_DARK_WAKE:
470 return errSecInDarkWake;
471 case CSSMERR_CSSM_SERVICE_NOT_AVAILABLE:
472 case CSSMERR_CSP_SERVICE_NOT_AVAILABLE:
473 case CSSMERR_TP_SERVICE_NOT_AVAILABLE:
474 case CSSMERR_AC_SERVICE_NOT_AVAILABLE:
475 case CSSMERR_CL_SERVICE_NOT_AVAILABLE:
476 case CSSMERR_DL_SERVICE_NOT_AVAILABLE:
477 return errSecServiceNotAvailable;
478 case CSSMERR_CSSM_INSUFFICIENT_CLIENT_IDENTIFICATION:
479 case CSSMERR_CSP_INSUFFICIENT_CLIENT_IDENTIFICATION:
480 case CSSMERR_TP_INSUFFICIENT_CLIENT_IDENTIFICATION:
481 case CSSMERR_AC_INSUFFICIENT_CLIENT_IDENTIFICATION:
482 case CSSMERR_CL_INSUFFICIENT_CLIENT_IDENTIFICATION:
483 case CSSMERR_DL_INSUFFICIENT_CLIENT_IDENTIFICATION:
484 return errSecInsufficientClientID;
485 case CSSMERR_CSSM_DEVICE_RESET:
486 case CSSMERR_CSP_DEVICE_RESET:
487 case CSSMERR_TP_DEVICE_RESET:
488 case CSSMERR_AC_DEVICE_RESET:
489 case CSSMERR_CL_DEVICE_RESET:
490 case CSSMERR_DL_DEVICE_RESET:
491 return errSecDeviceReset;
492 case CSSMERR_CSSM_DEVICE_FAILED:
493 case CSSMERR_CSP_DEVICE_FAILED:
494 case CSSMERR_TP_DEVICE_FAILED:
495 case CSSMERR_AC_DEVICE_FAILED:
496 case CSSMERR_CL_DEVICE_FAILED:
497 case CSSMERR_DL_DEVICE_FAILED:
498 return errSecDeviceFailed;
499 case CSSMERR_APPLE_DOTMAC_REQ_SERVER_AUTH:
500 case CSSMERR_CSSM_EMM_AUTHENTICATE_FAILED:
501 case CSSMERR_CSSM_ADDIN_AUTHENTICATE_FAILED:
502 case CSSMERR_CSP_OPERATION_AUTH_DENIED:
503 case CSSMERR_CSP_OBJECT_USE_AUTH_DENIED:
504 case CSSMERR_CSP_OBJECT_MANIP_AUTH_DENIED:
505 case CSSMERR_TP_AUTHENTICATION_FAILED:
506 case CSSMERR_DL_OPERATION_AUTH_DENIED:
507 case CSSMERR_DL_OBJECT_USE_AUTH_DENIED:
508 case CSSMERR_DL_OBJECT_MANIP_AUTH_DENIED:
509 return errAuthorizationDenied;
510 case CSSMERR_CSSM_SCOPE_NOT_SUPPORTED:
511 case CSSMERR_CL_SCOPE_NOT_SUPPORTED:
512 case CSSMERR_CL_INVALID_SCOPE:
513 return errSecInvalidScope;
514 case CSSMERR_TP_INVALID_NAME:
515 case CSSMERR_DL_INVALID_DB_NAME:
516 return errSecInvalidName;
517 case CSSMERR_APPLETP_BAD_CERT_FROM_ISSUER:
518 case CSSMERR_TP_INVALID_CERTIFICATE:
519 case CSSMERR_TP_INVALID_ANCHOR_CERT:
520 case CSSMERR_APPLETP_CRL_INVALID_ANCHOR_CERT:
521 case CSSMERR_APPLETP_OCSP_INVALID_ANCHOR_CERT:
522 return errSecInvalidCertificateRef;
523 case CSSMERR_CSP_ACL_ENTRY_TAG_NOT_FOUND:
524 case CSSMERR_DL_ACL_ENTRY_TAG_NOT_FOUND:
525 return errSecTagNotFound;
526 case CSSMERR_DL_UNSUPPORTED_QUERY:
527 case CSSMERR_DL_INVALID_QUERY:
528 return errSecInvalidQuery;
529 case CSSMERR_CSP_INVALID_ACL_CHALLENGE_CALLBACK:
530 case CSSMERR_TP_INVALID_CALLBACK:
531 case CSSMERR_DL_INVALID_ACL_CHALLENGE_CALLBACK:
532 return errSecInvalidCallback;
533 case CSSMERR_CSP_ACL_CHALLENGE_CALLBACK_FAILED:
534 case CSSMERR_CSP_CRYPTO_DATA_CALLBACK_FAILED:
535 case CSSMERR_DL_ACL_CHALLENGE_CALLBACK_FAILED:
536 return errSecCallbackFailed;
537 case CSSMERR_TP_INVALID_CERTGROUP:
538 case CSSMERR_TP_CERTGROUP_INCOMPLETE:
539 case CSSMERR_DL_INVALID_ACL_BASE_CERTS:
540 case CSSMERR_DL_ACL_BASE_CERTS_NOT_SUPPORTED:
541 case CSSMERR_CSP_INVALID_ACL_BASE_CERTS:
542 return errSecInvalidCertificateGroup;
543 case CSSMERR_CSP_ACL_DELETE_FAILED:
544 case CSSMERR_DL_ACL_DELETE_FAILED:
545 return errSecACLDeleteFailed;
546 case CSSMERR_CSP_ACL_REPLACE_FAILED:
547 case CSSMERR_DL_ACL_REPLACE_FAILED:
548 return errSecACLReplaceFailed;
549 case CSSMERR_CSP_ACL_ADD_FAILED:
550 case CSSMERR_DL_ACL_ADD_FAILED:
551 return errSecACLAddFailed;
552 case CSSMERR_DL_ACL_CHANGE_FAILED:
553 case CSSMERR_CSP_ACL_CHANGE_FAILED:
554 return errSecACLChangeFailed;
555 case CSSMERR_CSSM_PRIVILEGE_NOT_GRANTED:
556 case CSSMERR_CSP_PRIVILEGE_NOT_GRANTED:
557 return errSecPrivilegeNotGranted;
558 case CSSMERR_CSP_INVALID_ACCESS_CREDENTIALS:
559 case CSSMERR_DL_INVALID_ACCESS_CREDENTIALS:
560 return errSecInvalidAccessCredentials;
561 case CSSMERR_DL_INVALID_RECORD_INDEX:
562 case CSSMERR_DL_INVALID_RECORDTYPE:
563 case CSSMERR_DL_UNSUPPORTED_RECORDTYPE:
564 case CSSMERR_DL_INVALID_RECORD_UID:
565 case CSSMERR_DL_STALE_UNIQUE_RECORD:
566 return errSecInvalidRecord;
567 case CSSMERR_CSP_INVALID_KEY:
568 case CSSMERR_CSP_INVALID_KEY_REFERENCE:
569 case CSSMERR_CSP_INVALID_KEY_CLASS:
570 return errSecInvalidKeyRef;
571 case CSSMERR_CSP_OBJECT_ACL_NOT_SUPPORTED:
572 case CSSMERR_CSP_OBJECT_ACL_REQUIRED:
573 case CSSMERR_CSP_ACL_BASE_CERTS_NOT_SUPPORTED:
574 case CSSMERR_CSP_INVALID_ACL_SUBJECT_VALUE:
575 case CSSMERR_CSP_ACL_SUBJECT_TYPE_NOT_SUPPORTED:
576 case CSSMERR_DL_OBJECT_ACL_NOT_SUPPORTED:
577 case CSSMERR_DL_OBJECT_ACL_REQUIRED:
578 case CSSMERR_DL_INVALID_ACL_SUBJECT_VALUE:
579 case CSSMERR_DL_ACL_SUBJECT_TYPE_NOT_SUPPORTED:
580 case CSSMERR_DL_INVALID_NEW_ACL_ENTRY:
581 case CSSMERR_DL_INVALID_NEW_ACL_OWNER:
582 case CSSMERR_DL_INVALID_ACL_EDIT_MODE:
583 case CSSMERR_CSP_INVALID_ACL_EDIT_MODE:
584 case CSSMERR_CSP_INVALID_NEW_ACL_ENTRY:
585 case CSSMERR_CSP_INVALID_NEW_ACL_OWNER:
586 return errSecInvalidACL;
587 case CSSMERR_CSP_INVALID_SAMPLE_VALUE:
588 case CSSMERR_DL_INVALID_SAMPLE_VALUE:
589 case CSSMERR_CSP_SAMPLE_VALUE_NOT_SUPPORTED:
590 case CSSMERR_DL_SAMPLE_VALUE_NOT_SUPPORTED:
591 return errSecInvalidSampleValue;
592 case CSSMERR_TP_UNKNOWN_FORMAT:
593 case CSSMERR_CL_UNKNOWN_FORMAT:
594 return errSecUnknownFormat;
595 case CSSMERR_CSP_APPLE_ADD_APPLICATION_ACL_SUBJECT:
596 return errSecAppleAddAppACLSubject;
597 case CSSMERR_CSP_APPLE_PUBLIC_KEY_INCOMPLETE:
598 return errSecApplePublicKeyIncomplete;
599 case CSSMERR_CSP_APPLE_SIGNATURE_MISMATCH:
600 return errSecAppleSignatureMismatch;
601 case CSSMERR_CSP_APPLE_INVALID_KEY_START_DATE:
602 return errSecAppleInvalidKeyStartDate;
603 case CSSMERR_CSP_APPLE_INVALID_KEY_END_DATE:
604 return errSecAppleInvalidKeyEndDate;
605 case CSSMERR_CSPDL_APPLE_DL_CONVERSION_ERROR:
606 return errSecConversionError;
607 case CSSMERR_CSP_APPLE_SSLv2_ROLLBACK:
608 return errSecAppleSSLv2Rollback;
609 case CSSMERR_APPLEDL_QUOTA_EXCEEDED:
610 return errSecQuotaExceeded;
611 case CSSMERR_APPLEDL_FILE_TOO_BIG:
612 return errSecFileTooBig;
613 case CSSMERR_APPLEDL_INVALID_DATABASE_BLOB:
614 return errSecInvalidDatabaseBlob;
615 case CSSMERR_APPLEDL_INVALID_KEY_BLOB:
616 return errSecInvalidKeyBlob;
617 case CSSMERR_APPLEDL_INCOMPATIBLE_DATABASE_BLOB:
618 return errSecIncompatibleDatabaseBlob;
619 case CSSMERR_APPLEDL_INCOMPATIBLE_KEY_BLOB:
620 return errSecIncompatibleKeyBlob;
621 case CSSMERR_APPLETP_HOSTNAME_MISMATCH:
622 return errSecHostNameMismatch;
623 case CSSMERR_APPLETP_UNKNOWN_CRITICAL_EXTEN:
624 return errSecUnknownCriticalExtensionFlag;
625 case CSSMERR_APPLETP_NO_BASIC_CONSTRAINTS:
626 return errSecNoBasicConstraints;
627 case CSSMERR_APPLETP_INVALID_AUTHORITY_ID:
628 return errSecInvalidAuthorityKeyID;
629 case CSSMERR_APPLETP_INVALID_SUBJECT_ID:
630 return errSecInvalidSubjectKeyID;
631 case CSSMERR_APPLETP_INVALID_KEY_USAGE:
632 return errSecInvalidKeyUsageForPolicy;
633 case CSSMERR_APPLETP_INVALID_EXTENDED_KEY_USAGE:
634 return errSecInvalidExtendedKeyUsage;
635 case CSSMERR_APPLETP_INVALID_ID_LINKAGE:
636 return errSecInvalidIDLinkage;
637 case CSSMERR_APPLETP_PATH_LEN_CONSTRAINT:
638 return errSecPathLengthConstraintExceeded;
639 case CSSMERR_APPLETP_INVALID_ROOT:
640 return errSecInvalidRoot;
641 case CSSMERR_APPLETP_CRL_EXPIRED:
642 return errSecCRLExpired;
643 case CSSMERR_APPLETP_CRL_NOT_VALID_YET:
644 return errSecCRLNotValidYet;
645 case CSSMERR_APPLETP_CRL_NOT_FOUND:
646 return errSecCRLNotFound;
647 case CSSMERR_APPLETP_CRL_SERVER_DOWN:
648 return errSecCRLServerDown;
649 case CSSMERR_APPLETP_CRL_BAD_URI:
650 return errSecCRLBadURI;
651 case CSSMERR_APPLETP_UNKNOWN_CERT_EXTEN:
652 return errSecUnknownCertExtension;
653 case CSSMERR_APPLETP_UNKNOWN_CRL_EXTEN:
654 return errSecUnknownCRLExtension;
655 case CSSMERR_APPLETP_CRL_NOT_TRUSTED:
656 return errSecCRLNotTrusted;
657 case CSSMERR_APPLETP_CRL_POLICY_FAIL:
658 return errSecCRLPolicyFailed;
659 case CSSMERR_APPLETP_IDP_FAIL:
660 return errSecIDPFailure;
661 case CSSMERR_APPLETP_SMIME_EMAIL_ADDRS_NOT_FOUND:
662 return errSecSMIMEEmailAddressesNotFound;
663 case CSSMERR_APPLETP_SMIME_BAD_EXT_KEY_USE:
664 return errSecSMIMEBadExtendedKeyUsage;
665 case CSSMERR_APPLETP_SMIME_BAD_KEY_USE:
666 return errSecSMIMEBadKeyUsage;
667 case CSSMERR_APPLETP_SMIME_KEYUSAGE_NOT_CRITICAL:
668 return errSecSMIMEKeyUsageNotCritical;
669 case CSSMERR_APPLETP_SMIME_NO_EMAIL_ADDRS:
670 return errSecSMIMENoEmailAddress;
671 case CSSMERR_APPLETP_SMIME_SUBJ_ALT_NAME_NOT_CRIT:
672 return errSecSMIMESubjAltNameNotCritical;
673 case CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE:
674 return errSecSSLBadExtendedKeyUsage;
675 case CSSMERR_APPLETP_OCSP_BAD_RESPONSE:
676 return errSecOCSPBadResponse;
677 case CSSMERR_APPLETP_OCSP_BAD_REQUEST:
678 return errSecOCSPBadRequest;
679 case CSSMERR_APPLETP_OCSP_UNAVAILABLE:
680 return errSecOCSPUnavailable;
681 case CSSMERR_APPLETP_OCSP_STATUS_UNRECOGNIZED:
682 return errSecOCSPStatusUnrecognized;
683 case CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK:
684 return errSecIncompleteCertRevocationCheck;
685 case CSSMERR_APPLETP_NETWORK_FAILURE:
686 return errSecNetworkFailure;
687 case CSSMERR_APPLETP_OCSP_NOT_TRUSTED:
688 return errSecOCSPNotTrustedToAnchor;
689 case CSSMERR_APPLETP_OCSP_SIG_ERROR:
690 return errSecOCSPSignatureError;
691 case CSSMERR_APPLETP_OCSP_NO_SIGNER:
692 return errSecOCSPNoSigner;
693 case CSSMERR_APPLETP_OCSP_RESP_MALFORMED_REQ:
694 return errSecOCSPResponderMalformedReq;
695 case CSSMERR_APPLETP_OCSP_RESP_INTERNAL_ERR:
696 return errSecOCSPResponderInternalError;
697 case CSSMERR_APPLETP_OCSP_RESP_TRY_LATER:
698 return errSecOCSPResponderTryLater;
699 case CSSMERR_APPLETP_OCSP_RESP_SIG_REQUIRED:
700 return errSecOCSPResponderSignatureRequired;
701 case CSSMERR_APPLETP_OCSP_RESP_UNAUTHORIZED:
702 return errSecOCSPResponderUnauthorized;
703 case CSSMERR_APPLETP_OCSP_NONCE_MISMATCH:
704 return errSecOCSPResponseNonceMismatch;
705 case CSSMERR_APPLETP_CS_BAD_CERT_CHAIN_LENGTH:
706 return errSecCodeSigningBadCertChainLength;
707 case CSSMERR_APPLETP_CS_NO_BASIC_CONSTRAINTS:
708 return errSecCodeSigningNoBasicConstraints;
709 case CSSMERR_APPLETP_CS_BAD_PATH_LENGTH:
710 return errSecCodeSigningBadPathLengthConstraint;
711 case CSSMERR_APPLETP_CS_NO_EXTENDED_KEY_USAGE:
712 return errSecCodeSigningNoExtendedKeyUsage;
713 case CSSMERR_APPLETP_CODE_SIGN_DEVELOPMENT:
714 return errSecCodeSigningDevelopment;
715 case CSSMERR_APPLETP_RS_BAD_CERT_CHAIN_LENGTH:
716 return errSecResourceSignBadCertChainLength;
717 case CSSMERR_APPLETP_RS_BAD_EXTENDED_KEY_USAGE:
718 return errSecResourceSignBadExtKeyUsage;
719 case CSSMERR_APPLETP_TRUST_SETTING_DENY:
720 return errSecTrustSettingDeny;
721 case CSSMERR_APPLETP_INVALID_EMPTY_SUBJECT:
722 return errSecInvalidSubjectName;
723 case CSSMERR_APPLETP_UNKNOWN_QUAL_CERT_STATEMENT:
724 return errSecUnknownQualifiedCertStatement;
725 case CSSMERR_APPLETP_MISSING_REQUIRED_EXTENSION:
726 return errSecMissingRequiredExtension;
727 case CSSMERR_APPLETP_EXT_KEYUSAGE_NOT_CRITICAL:
728 return errSecExtendedKeyUsageNotCritical;
729 case CSSMERR_APPLE_DOTMAC_REQ_QUEUED:
730 return errSecMobileMeRequestQueued;
731 case CSSMERR_APPLE_DOTMAC_REQ_REDIRECT:
732 return errSecMobileMeRequestRedirected;
733 case CSSMERR_APPLE_DOTMAC_REQ_SERVER_ERR:
734 return errSecMobileMeServerError;
735 case CSSMERR_APPLE_DOTMAC_REQ_SERVER_NOT_AVAIL:
736 return errSecMobileMeServerNotAvailable;
737 case CSSMERR_APPLE_DOTMAC_REQ_SERVER_ALREADY_EXIST:
738 return errSecMobileMeServerAlreadyExists;
739 case CSSMERR_APPLE_DOTMAC_REQ_SERVER_SERVICE_ERROR:
740 return errSecMobileMeServerServiceErr;
741 case CSSMERR_APPLE_DOTMAC_REQ_IS_PENDING:
742 return errSecMobileMeRequestAlreadyPending;
743 case CSSMERR_APPLE_DOTMAC_NO_REQ_PENDING:
744 return errSecMobileMeNoRequestPending;
745 case CSSMERR_APPLE_DOTMAC_CSR_VERIFY_FAIL:
746 return errSecMobileMeCSRVerifyFailure;
747 case CSSMERR_APPLE_DOTMAC_FAILED_CONSISTENCY_CHECK:
748 return errSecMobileMeFailedConsistencyCheck;
749 case CSSMERR_CSSM_NOT_INITIALIZED:
750 return errSecNotInitialized;
751 case CSSMERR_CSSM_INVALID_HANDLE_USAGE:
752 return errSecInvalidHandleUsage;
753 case CSSMERR_CSSM_PVC_REFERENT_NOT_FOUND:
754 return errSecPVCReferentNotFound;
755 case CSSMERR_CSSM_FUNCTION_INTEGRITY_FAIL:
756 return errSecFunctionIntegrityFail;
757 case CSSMERR_CSSM_SELF_CHECK_FAILED:
758 case CSSMERR_CSP_SELF_CHECK_FAILED:
759 return errSecSelfCheckFailed;
760 case CSSMERR_CSSM_MODULE_MANIFEST_VERIFY_FAILED:
761 return errSecModuleManifestVerifyFailed;
762 case CSSMERR_CSSM_INVALID_GUID:
763 return errSecInvalidGUID;
764 case CSSMERR_CSSM_INCOMPATIBLE_VERSION:
765 return errSecIncompatibleVersion;
766 case CSSMERR_CSSM_PVC_ALREADY_CONFIGURED:
767 return errSecPVCAlreadyConfigured;
768 case CSSMERR_CSSM_INVALID_PVC:
769 return errSecInvalidPVC;
770 case CSSMERR_CSSM_EMM_LOAD_FAILED:
771 return errSecEMMLoadFailed;
772 case CSSMERR_CSSM_EMM_UNLOAD_FAILED:
773 return errSecEMMUnloadFailed;
774 case CSSMERR_CSSM_ADDIN_LOAD_FAILED:
775 return errSecAddinLoadFailed;
776 case CSSMERR_CSSM_INVALID_KEY_HIERARCHY:
777 return errSecInvalidKeyHierarchy;
778 case CSSMERR_CSSM_ADDIN_UNLOAD_FAILED:
779 return errSecAddinUnloadFailed;
780 case CSSMERR_CSSM_LIB_REF_NOT_FOUND:
781 return errSecLibraryReferenceNotFound;
782 case CSSMERR_CSSM_INVALID_ADDIN_FUNCTION_TABLE:
783 return errSecInvalidAddinFunctionTable;
784 case CSSMERR_CSSM_INVALID_SERVICE_MASK:
785 return errSecInvalidServiceMask;
786 case CSSMERR_CSSM_MODULE_NOT_LOADED:
787 return errSecModuleNotLoaded;
788 case CSSMERR_CSSM_INVALID_SUBSERVICEID:
789 return errSecInvalidSubServiceID;
790 case CSSMERR_CSSM_ATTRIBUTE_NOT_IN_CONTEXT:
791 return errSecAttributeNotInContext;
792 case CSSMERR_CSSM_MODULE_MANAGER_INITIALIZE_FAIL:
793 return errSecModuleManagerInitializeFailed;
794 case CSSMERR_CSSM_MODULE_MANAGER_NOT_FOUND:
795 return errSecModuleManagerNotFound;
796 case CSSMERR_CSSM_EVENT_NOTIFICATION_CALLBACK_NOT_FOUND:
797 return errSecEventNotificationCallbackNotFound;
798 case CSSMERR_CSP_INPUT_LENGTH_ERROR:
799 return errSecInputLengthError;
800 case CSSMERR_CSP_OUTPUT_LENGTH_ERROR:
801 return errSecOutputLengthError;
802 case CSSMERR_CSP_PRIVILEGE_NOT_SUPPORTED:
803 return errSecPrivilegeNotSupported;
804 case CSSMERR_CSP_DEVICE_ERROR:
805 return errSecDeviceError;
806 case CSSMERR_CSP_ATTACH_HANDLE_BUSY:
807 return errSecAttachHandleBusy;
808 case CSSMERR_CSP_NOT_LOGGED_IN:
809 return errSecNotLoggedIn;
810 case CSSMERR_CSP_ALGID_MISMATCH:
811 return errSecAlgorithmMismatch;
812 case CSSMERR_CSP_KEY_USAGE_INCORRECT:
813 return errSecKeyUsageIncorrect;
814 case CSSMERR_CSP_KEY_BLOB_TYPE_INCORRECT:
815 return errSecKeyBlobTypeIncorrect;
816 case CSSMERR_CSP_KEY_HEADER_INCONSISTENT:
817 return errSecKeyHeaderInconsistent;
818 case CSSMERR_CSP_UNSUPPORTED_KEY_FORMAT:
819 return errSecUnsupportedKeyFormat;
820 case CSSMERR_CSP_UNSUPPORTED_KEY_SIZE:
821 return errSecUnsupportedKeySize;
822 case CSSMERR_CSP_INVALID_KEYUSAGE_MASK:
823 return errSecInvalidKeyUsageMask;
824 case CSSMERR_CSP_UNSUPPORTED_KEYUSAGE_MASK:
825 return errSecUnsupportedKeyUsageMask;
826 case CSSMERR_CSP_INVALID_KEYATTR_MASK:
827 return errSecInvalidKeyAttributeMask;
828 case CSSMERR_CSP_UNSUPPORTED_KEYATTR_MASK:
829 return errSecUnsupportedKeyAttributeMask;
830 case CSSMERR_CSP_INVALID_KEY_LABEL:
831 return errSecInvalidKeyLabel;
832 case CSSMERR_CSP_UNSUPPORTED_KEY_LABEL:
833 return errSecUnsupportedKeyLabel;
834 case CSSMERR_CSP_INVALID_KEY_FORMAT:
835 return errSecInvalidKeyFormat;
836 case CSSMERR_CSP_VECTOR_OF_BUFS_UNSUPPORTED:
837 return errSecUnsupportedVectorOfBuffers;
838 case CSSMERR_CSP_INVALID_INPUT_VECTOR:
839 return errSecInvalidInputVector;
840 case CSSMERR_CSP_INVALID_OUTPUT_VECTOR:
841 return errSecInvalidOutputVector;
842 case CSSMERR_CSP_INVALID_CONTEXT:
843 return errSecInvalidContext;
844 case CSSMERR_CSP_INVALID_ALGORITHM:
845 return errSecInvalidAlgorithm;
846 case CSSMERR_CSP_INVALID_ATTR_KEY:
847 return errSecInvalidAttributeKey;
848 case CSSMERR_CSP_MISSING_ATTR_KEY:
849 return errSecMissingAttributeKey;
850 case CSSMERR_CSP_INVALID_ATTR_INIT_VECTOR:
851 return errSecInvalidAttributeInitVector;
852 case CSSMERR_CSP_MISSING_ATTR_INIT_VECTOR:
853 return errSecMissingAttributeInitVector;
854 case CSSMERR_CSP_INVALID_ATTR_SALT:
855 return errSecInvalidAttributeSalt;
856 case CSSMERR_CSP_MISSING_ATTR_SALT:
857 return errSecMissingAttributeSalt;
858 case CSSMERR_CSP_INVALID_ATTR_PADDING:
859 return errSecInvalidAttributePadding;
860 case CSSMERR_CSP_MISSING_ATTR_PADDING:
861 return errSecMissingAttributePadding;
862 case CSSMERR_CSP_INVALID_ATTR_RANDOM:
863 return errSecInvalidAttributeRandom;
864 case CSSMERR_CSP_MISSING_ATTR_RANDOM:
865 return errSecMissingAttributeRandom;
866 case CSSMERR_CSP_INVALID_ATTR_SEED:
867 return errSecInvalidAttributeSeed;
868 case CSSMERR_CSP_MISSING_ATTR_SEED:
869 return errSecMissingAttributeSeed;
870 case CSSMERR_CSP_INVALID_ATTR_PASSPHRASE:
871 return errSecInvalidAttributePassphrase;
872 case CSSMERR_CSP_MISSING_ATTR_PASSPHRASE:
873 return errSecMissingAttributePassphrase;
874 case CSSMERR_CSP_INVALID_ATTR_KEY_LENGTH:
875 return errSecInvalidAttributeKeyLength;
876 case CSSMERR_CSP_MISSING_ATTR_KEY_LENGTH:
877 return errSecMissingAttributeKeyLength;
878 case CSSMERR_CSP_INVALID_ATTR_BLOCK_SIZE:
879 return errSecInvalidAttributeBlockSize;
880 case CSSMERR_CSP_MISSING_ATTR_BLOCK_SIZE:
881 return errSecMissingAttributeBlockSize;
882 case CSSMERR_CSP_INVALID_ATTR_OUTPUT_SIZE:
883 return errSecInvalidAttributeOutputSize;
884 case CSSMERR_CSP_MISSING_ATTR_OUTPUT_SIZE:
885 return errSecMissingAttributeOutputSize;
886 case CSSMERR_CSP_INVALID_ATTR_ROUNDS:
887 return errSecInvalidAttributeRounds;
888 case CSSMERR_CSP_MISSING_ATTR_ROUNDS:
889 return errSecMissingAttributeRounds;
890 case CSSMERR_CSP_INVALID_ATTR_ALG_PARAMS:
891 return errSecInvalidAlgorithmParms;
892 case CSSMERR_CSP_MISSING_ATTR_ALG_PARAMS:
893 return errSecMissingAlgorithmParms;
894 case CSSMERR_CSP_INVALID_ATTR_LABEL:
895 return errSecInvalidAttributeLabel;
896 case CSSMERR_CSP_MISSING_ATTR_LABEL:
897 return errSecMissingAttributeLabel;
898 case CSSMERR_CSP_INVALID_ATTR_KEY_TYPE:
899 return errSecInvalidAttributeKeyType;
900 case CSSMERR_CSP_MISSING_ATTR_KEY_TYPE:
901 return errSecMissingAttributeKeyType;
902 case CSSMERR_CSP_INVALID_ATTR_MODE:
903 return errSecInvalidAttributeMode;
904 case CSSMERR_CSP_MISSING_ATTR_MODE:
905 return errSecMissingAttributeMode;
906 case CSSMERR_CSP_INVALID_ATTR_EFFECTIVE_BITS:
907 return errSecInvalidAttributeEffectiveBits;
908 case CSSMERR_CSP_MISSING_ATTR_EFFECTIVE_BITS:
909 return errSecMissingAttributeEffectiveBits;
910 case CSSMERR_CSP_INVALID_ATTR_START_DATE:
911 return errSecInvalidAttributeStartDate;
912 case CSSMERR_CSP_MISSING_ATTR_START_DATE:
913 return errSecMissingAttributeStartDate;
914 case CSSMERR_CSP_INVALID_ATTR_END_DATE:
915 return errSecInvalidAttributeEndDate;
916 case CSSMERR_CSP_MISSING_ATTR_END_DATE:
917 return errSecMissingAttributeEndDate;
918 case CSSMERR_CSP_INVALID_ATTR_VERSION:
919 return errSecInvalidAttributeVersion;
920 case CSSMERR_CSP_MISSING_ATTR_VERSION:
921 return errSecMissingAttributeVersion;
922 case CSSMERR_CSP_INVALID_ATTR_PRIME:
923 return errSecInvalidAttributePrime;
924 case CSSMERR_CSP_MISSING_ATTR_PRIME:
925 return errSecMissingAttributePrime;
926 case CSSMERR_CSP_INVALID_ATTR_BASE:
927 return errSecInvalidAttributeBase;
928 case CSSMERR_CSP_MISSING_ATTR_BASE:
929 return errSecMissingAttributeBase;
930 case CSSMERR_CSP_INVALID_ATTR_SUBPRIME:
931 return errSecInvalidAttributeSubprime;
932 case CSSMERR_CSP_MISSING_ATTR_SUBPRIME:
933 return errSecMissingAttributeSubprime;
934 case CSSMERR_CSP_INVALID_ATTR_ITERATION_COUNT:
935 return errSecInvalidAttributeIterationCount;
936 case CSSMERR_CSP_MISSING_ATTR_ITERATION_COUNT:
937 return errSecMissingAttributeIterationCount;
938 case CSSMERR_CSP_INVALID_ATTR_DL_DB_HANDLE:
939 return errSecInvalidAttributeDLDBHandle;
940 case CSSMERR_CSP_MISSING_ATTR_DL_DB_HANDLE:
941 return errSecMissingAttributeDLDBHandle;
942 case CSSMERR_CSP_INVALID_ATTR_ACCESS_CREDENTIALS:
943 return errSecInvalidAttributeAccessCredentials;
944 case CSSMERR_CSP_MISSING_ATTR_ACCESS_CREDENTIALS:
945 return errSecMissingAttributeAccessCredentials;
946 case CSSMERR_CSP_INVALID_ATTR_PUBLIC_KEY_FORMAT:
947 return errSecInvalidAttributePublicKeyFormat;
948 case CSSMERR_CSP_MISSING_ATTR_PUBLIC_KEY_FORMAT:
949 return errSecMissingAttributePublicKeyFormat;
950 case CSSMERR_CSP_INVALID_ATTR_PRIVATE_KEY_FORMAT:
951 return errSecInvalidAttributePrivateKeyFormat;
952 case CSSMERR_CSP_MISSING_ATTR_PRIVATE_KEY_FORMAT:
953 return errSecMissingAttributePrivateKeyFormat;
954 case CSSMERR_CSP_INVALID_ATTR_SYMMETRIC_KEY_FORMAT:
955 return errSecInvalidAttributeSymmetricKeyFormat;
956 case CSSMERR_CSP_MISSING_ATTR_SYMMETRIC_KEY_FORMAT:
957 return errSecMissingAttributeSymmetricKeyFormat;
958 case CSSMERR_CSP_INVALID_ATTR_WRAPPED_KEY_FORMAT:
959 return errSecInvalidAttributeWrappedKeyFormat;
960 case CSSMERR_CSP_MISSING_ATTR_WRAPPED_KEY_FORMAT:
961 return errSecMissingAttributeWrappedKeyFormat;
962 case CSSMERR_CSP_STAGED_OPERATION_IN_PROGRESS:
963 return errSecStagedOperationInProgress;
964 case CSSMERR_CSP_STAGED_OPERATION_NOT_STARTED:
965 return errSecStagedOperationNotStarted;
966 case CSSMERR_CSP_VERIFY_FAILED:
967 return errSecVerifyFailed;
968 case CSSMERR_CSP_QUERY_SIZE_UNKNOWN:
969 return errSecQuerySizeUnknown;
970 case CSSMERR_CSP_BLOCK_SIZE_MISMATCH:
971 return errSecBlockSizeMismatch;
972 case CSSMERR_CSP_PUBLIC_KEY_INCONSISTENT:
973 return errSecPublicKeyInconsistent;
974 case CSSMERR_CSP_DEVICE_VERIFY_FAILED:
975 return errSecDeviceVerifyFailed;
976 case CSSMERR_CSP_INVALID_LOGIN_NAME:
977 return errSecInvalidLoginName;
978 case CSSMERR_CSP_ALREADY_LOGGED_IN:
979 return errSecAlreadyLoggedIn;
980 case CSSMERR_CSP_INVALID_DIGEST_ALGORITHM:
981 return errSecInvalidDigestAlgorithm;
982 case CSSMERR_TP_INVALID_CRLGROUP:
983 return errSecInvalidCRLGroup;
984 case CSSMERR_TP_CERTIFICATE_CANT_OPERATE:
985 return errSecCertificateCannotOperate;
986 case CSSMERR_TP_CERT_EXPIRED:
987 return errSecCertificateExpired;
988 case CSSMERR_TP_CERT_NOT_VALID_YET:
989 return errSecCertificateNotValidYet;
990 case CSSMERR_TP_CERT_REVOKED:
991 return errSecCertificateRevoked;
992 case CSSMERR_TP_CERT_SUSPENDED:
993 return errSecCertificateSuspended;
994 case CSSMERR_TP_INSUFFICIENT_CREDENTIALS:
995 return errSecInsufficientCredentials;
996 case CSSMERR_TP_INVALID_ACTION:
997 return errSecInvalidAction;
998 case CSSMERR_TP_INVALID_AUTHORITY:
999 return errSecInvalidAuthority;
1000 case CSSMERR_TP_VERIFY_ACTION_FAILED:
1001 return errSecVerifyActionFailed;
1002 case CSSMERR_TP_INVALID_CERT_AUTHORITY:
1003 case CSSMERR_APPLETP_INVALID_CA:
1004 return errSecInvalidCertAuthority;
1005 case CSSMERR_TP_INVALID_CRL_AUTHORITY:
1006 return errSecInvaldCRLAuthority;
1007 case CSSMERR_TP_INVALID_CRL_ENCODING:
1008 return errSecInvalidCRLEncoding;
1009 case CSSMERR_TP_INVALID_CRL_TYPE:
1010 return errSecInvalidCRLType;
1011 case CSSMERR_TP_INVALID_CRL:
1012 return errSecInvalidCRL;
1013 case CSSMERR_TP_INVALID_FORM_TYPE:
1014 return errSecInvalidFormType;
1015 case CSSMERR_TP_INVALID_ID:
1016 return errSecInvalidID;
1017 case CSSMERR_TP_INVALID_IDENTIFIER:
1018 return errSecInvalidIdentifier;
1019 case CSSMERR_TP_INVALID_INDEX:
1020 return errSecInvalidIndex;
1021 case CSSMERR_TP_INVALID_POLICY_IDENTIFIERS:
1022 return errSecInvalidPolicyIdentifiers;
1023 case CSSMERR_TP_INVALID_TIMESTRING:
1024 return errSecInvalidTimeString;
1025 case CSSMERR_TP_INVALID_REASON:
1026 return errSecInvalidReason;
1027 case CSSMERR_TP_INVALID_REQUEST_INPUTS:
1028 return errSecInvalidRequestInputs;
1029 case CSSMERR_TP_INVALID_RESPONSE_VECTOR:
1030 return errSecInvalidResponseVector;
1031 case CSSMERR_TP_INVALID_STOP_ON_POLICY:
1032 return errSecInvalidStopOnPolicy;
1033 case CSSMERR_TP_INVALID_TUPLE:
1034 return errSecInvalidTuple;
1035 case CSSMERR_TP_NOT_SIGNER:
1036 return errSecNotSigner;
1037 case CSSMERR_TP_NOT_TRUSTED:
1038 return errSecNotTrusted;
1039 case CSSMERR_TP_NO_DEFAULT_AUTHORITY:
1040 return errSecNoDefaultAuthority;
1041 case CSSMERR_TP_REJECTED_FORM:
1042 return errSecRejectedForm;
1043 case CSSMERR_TP_REQUEST_LOST:
1044 return errSecRequestLost;
1045 case CSSMERR_TP_REQUEST_REJECTED:
1046 return errSecRequestRejected;
1047 case CSSMERR_TP_UNSUPPORTED_ADDR_TYPE:
1048 return errSecUnsupportedAddressType;
1049 case CSSMERR_TP_UNSUPPORTED_SERVICE:
1050 return errSecUnsupportedService;
1051 case CSSMERR_TP_INVALID_TUPLEGROUP:
1052 return errSecInvalidTupleGroup;
1053 case CSSMERR_AC_INVALID_BASE_ACLS:
1054 return errSecInvalidBaseACLs;
1055 case CSSMERR_AC_INVALID_TUPLE_CREDENTIALS:
1056 return errSecInvalidTupleCredendtials;
1057 case CSSMERR_AC_INVALID_ENCODING:
1058 return errSecInvalidEncoding;
1059 case CSSMERR_AC_INVALID_VALIDITY_PERIOD:
1060 return errSecInvalidValidityPeriod;
1061 case CSSMERR_AC_INVALID_REQUESTOR:
1062 return errSecInvalidRequestor;
1063 case CSSMERR_AC_INVALID_REQUEST_DESCRIPTOR:
1064 return errSecRequestDescriptor;
1065 case CSSMERR_CL_INVALID_BUNDLE_INFO:
1066 return errSecInvalidBundleInfo;
1067 case CSSMERR_CL_INVALID_CRL_INDEX:
1068 return errSecInvalidCRLIndex;
1069 case CSSMERR_CL_NO_FIELD_VALUES:
1070 return errSecNoFieldValues;
1071 case CSSMERR_DL_UNSUPPORTED_FIELD_FORMAT:
1072 return errSecUnsupportedFieldFormat;
1073 case CSSMERR_DL_UNSUPPORTED_INDEX_INFO:
1074 return errSecUnsupportedIndexInfo;
1075 case CSSMERR_DL_UNSUPPORTED_LOCALITY:
1076 return errSecUnsupportedLocality;
1077 case CSSMERR_DL_UNSUPPORTED_NUM_ATTRIBUTES:
1078 return errSecUnsupportedNumAttributes;
1079 case CSSMERR_DL_UNSUPPORTED_NUM_INDEXES:
1080 return errSecUnsupportedNumIndexes;
1081 case CSSMERR_DL_UNSUPPORTED_NUM_RECORDTYPES:
1082 return errSecUnsupportedNumRecordTypes;
1083 case CSSMERR_DL_FIELD_SPECIFIED_MULTIPLE:
1084 return errSecFieldSpecifiedMultiple;
1085 case CSSMERR_DL_INCOMPATIBLE_FIELD_FORMAT:
1086 return errSecIncompatibleFieldFormat;
1087 case CSSMERR_DL_INVALID_PARSING_MODULE:
1088 return errSecInvalidParsingModule;
1089 case CSSMERR_DL_DB_LOCKED:
1090 return errSecDatabaseLocked;
1091 case CSSMERR_DL_DATASTORE_IS_OPEN:
1092 return errSecDatastoreIsOpen;
1093 case CSSMERR_DL_MISSING_VALUE:
1094 return errSecMissingValue;
1095 case CSSMERR_DL_UNSUPPORTED_QUERY_LIMITS:
1096 return errSecUnsupportedQueryLimits;
1097 case CSSMERR_DL_UNSUPPORTED_NUM_SELECTION_PREDS:
1098 return errSecUnsupportedNumSelectionPreds;
1099 case CSSMERR_DL_UNSUPPORTED_OPERATOR:
1100 return errSecUnsupportedOperator;
1101 case CSSMERR_DL_INVALID_DB_LOCATION:
1102 return errSecInvalidDBLocation;
1103 case CSSMERR_DL_INVALID_ACCESS_REQUEST:
1104 return errSecInvalidAccessRequest;
1105 case CSSMERR_DL_INVALID_INDEX_INFO:
1106 return errSecInvalidIndexInfo;
1107 case CSSMERR_DL_INVALID_NEW_OWNER:
1108 return errSecInvalidNewOwner;
1109 case CSSMERR_DL_INVALID_MODIFY_MODE:
1110 return errSecInvalidModifyMode;
1111 case CSSMERR_DL_RECORD_MODIFIED:
1112 return errSecRecordModified;
1113 case CSSMERR_DL_ENDOFDATA:
1114 return errSecEndOfData;
1115 case CSSMERR_DL_INVALID_VALUE:
1116 return errSecInvalidValue;
1117 case CSSMERR_DL_MULTIPLE_VALUES_UNSUPPORTED:
1118 return errSecMultipleValuesUnsupported;
1119 default:
1120 return osStatus;
1121 }
1122 }