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