2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
23 #include <Security/KCUtilities.h>
24 #include <Security/cssmerrno.h>
29 OSStatus
GetKeychainErrFromCSSMErr( OSStatus cssmError
)
31 if (CSSM_ERR_IS_CONVERTIBLE(cssmError
))
33 switch (CSSM_ERRCODE(cssmError
))
35 // CONVERTIBLE ERROR CODES.
36 case CSSM_ERRCODE_SERVICE_NOT_AVAILABLE
:
37 return errSecNotAvailable
;
38 case CSSM_ERRCODE_USER_CANCELED
:
39 return userCanceledErr
;
40 case CSSM_ERRCODE_OPERATION_AUTH_DENIED
:
41 return errSecAuthFailed
;
42 case CSSM_ERRCODE_NO_USER_INTERACTION
:
43 return errSecInteractionNotAllowed
;
44 case CSSM_ERRCODE_OS_ACCESS_DENIED
:
54 // DL SPECIFIC ERROR CODES
55 case CSSMERR_DL_OS_ACCESS_DENIED
:
57 case CSSMERR_DL_RECORD_NOT_FOUND
:
58 return errSecItemNotFound
;
59 case CSSMERR_DL_INVALID_UNIQUE_INDEX_DATA
:
60 return errSecDuplicateItem
;
61 case CSSMERR_DL_DATABASE_CORRUPT
:
62 return errSecInvalidKeychain
;
63 case CSSMERR_DL_DATASTORE_DOESNOT_EXIST
:
64 return errSecNoSuchKeychain
;
65 case CSSMERR_DL_DATASTORE_ALREADY_EXISTS
:
66 return errSecDuplicateKeychain
;
67 case CSSMERR_DL_INVALID_FIELD_NAME
:
68 return errSecNoSuchAttr
;
75 StKCAttribute::StKCAttribute( SecKeychainAttribute
* inPtr
) :
80 StKCAttribute::~StKCAttribute( )
85 StKCItem::StKCItem( SecKeychainItemRef
* inItem
, OSStatus
* result
) :
91 StKCItem::~StKCItem( )
93 // if an error occured and the item is valid, release the item
95 if ( *fResult
!= noErr
&& *fItem
!= NULL
)
99 } // end namespace Security