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