2 * Copyright (c) 2000-2002 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.
20 SecBase contains common declarations for the Security functions.
23 #ifndef _SECURITY_SECBASE_H_
24 #define _SECURITY_SECBASE_H_
26 #include <CoreFoundation/CFBase.h>
28 #if defined(__cplusplus)
36 @typedef SecKeychainRef
37 @abstract Contains information about a keychain.
39 typedef struct OpaqueSecKeychainRef
*SecKeychainRef
;
42 @typedef SecKeychainItemRef
43 @abstract Contains information about a keychain item.
45 typedef struct OpaqueSecKeychainItemRef
*SecKeychainItemRef
;
48 @typedef SecKeychainSearchRef
49 @abstract Contains information about a keychain search.
51 typedef struct OpaqueSecKeychainSearchRef
*SecKeychainSearchRef
;
54 @typedef SecKeychainAttrType
55 @abstract Represents a keychain attribute type.
57 typedef OSType SecKeychainAttrType
;
60 @struct SecKeychainAttribute
61 @abstract Contains keychain attributes.
62 @field tag A 4-byte attribute tag.
63 @field length The length of the buffer pointed to by data.
64 @field data A pointer to the attribute data.
66 struct SecKeychainAttribute
68 SecKeychainAttrType tag
;
72 typedef struct SecKeychainAttribute SecKeychainAttribute
;
75 @typedef SecKeychainAttributePtr
76 @abstract Represents a pointer to a keychain attribute structure.
78 typedef SecKeychainAttribute
*SecKeychainAttributePtr
;
81 @typedef SecKeychainAttributeList
82 @abstract Represents a list of keychain attributes.
83 @field count An unsigned 32-bit integer that represents the number of keychain attributes in the array.
84 @field attr A pointer to the first keychain attribute in the array.
86 struct SecKeychainAttributeList
89 SecKeychainAttribute
*attr
;
91 typedef struct SecKeychainAttributeList SecKeychainAttributeList
;
94 @typedef SecKeychainStatus
95 @abstract Represents the status of a keychain.
97 typedef UInt32 SecKeychainStatus
;
101 @typedef SecTrustedApplicationRef
102 @abstract Contains information about a trusted application.
104 typedef struct OpaqueSecTrustedApplicationRef
*SecTrustedApplicationRef
;
107 @typedef SecPolicyRef
108 @abstract Contains information about a policy.
110 typedef struct OpaqueSecPolicyRef
*SecPolicyRef
;
113 @typedef SecCertificateRef
114 @abstract Contains information about a certificate.
116 typedef struct OpaqueSecCertificateRef
*SecCertificateRef
;
119 @typedef SecAccessRef
120 @abstract Contains information about an access.
122 typedef struct OpaqueSecAccessRef
*SecAccessRef
;
125 @typedef SecIdentityRef
126 @abstract Contains information about an identity.
128 typedef struct OpaqueSecIdentityRef
*SecIdentityRef
;
132 @abstract Contains information about a key.
134 typedef struct OpaqueSecKeyRef
*SecKeyRef
;
138 @abstract Contains information about an access control list (ACL) entry.
140 typedef struct OpaqueSecTrustRef
*SecACLRef
;
143 @typedef SecKeychainAttributeInfo
144 @abstract Represents an attribute.
145 @field count The number of tag-format pairs in the respective arrays.
146 @field tag A pointer to the first attribute tag in the array.
147 @field format A pointer to the first attribute format in the array.
148 @discussion Each tag and format item form a pair.
150 struct SecKeychainAttributeInfo
156 typedef struct SecKeychainAttributeInfo SecKeychainAttributeInfo
;
159 @enum Security Error Codes
160 @abstract Represents the result codes.
161 @constant errSecNotAvailable No keychain is available.
162 @constant errSecReadOnly Read only error.
163 @constant errSecAuthFailed Authorization/Authentication failed.
164 @constant errSecNoSuchKeychain The keychain does not exist.
165 @constant errSecInvalidKeychain The keychain is not valid.
166 @constant errSecDuplicateKeychain A keychain with the same name already exists.
167 @constant errSecDuplicateCallback The specified callback is already installed.
168 @constant errSecInvalidCallback The specified callback is not valid.
169 @constant errSecDuplicateItem The item already exists.
170 @constant errSecItemNotFound The item cannot be found.
171 @constant errSecBufferTooSmall The buffer is too small.
172 @constant errSecDataTooLarge The data is too large.
173 @constant errSecNoSuchAttr The attribute does not exist.
174 @constant errSecInvalidItemRef The item reference is invalid.
175 @constant errSecInvalidSearchRef The search reference is invalid.
176 @constant errSecNoSuchClass The keychain item class does not exist.
177 @constant errSecNoDefaultKeychain A default keychain does not exist.
178 @constant errSecInteractionNotAllowed Interaction is not allowed with the Security Server.
179 @constant errSecReadOnlyAttr The attribute is read only.
180 @constant errSecWrongSecVersion The version is incorrect.
181 @constant errSecKeySizeNotAllowed The key size is not allowed.
182 @constant errSecNoStorageModule There is no storage module available.
183 @constant errSecNoCertificateModule There is no certificate module available.
184 @constant errSecNoPolicyModule There is no policy module available.
185 @constant errSecInteractionRequired User interaction is required.
186 @constant errSecDataNotAvailable The data is not available.
187 @constant errSecDataNotModifiable The data is not modifiable.
188 @constant errSecCreateChainFailed The attempt to create a certificate chain failed.
189 @constant errSecACLNotSimple The access control list is not in standard simple form.
190 @constant errSecPolicyNotFound The policy specified cannot be found.
191 @constant errSecInvalidTrustSetting The trust setting is invalid.
192 @constant errSecNoAccessForItem The specified item has no access control.
193 @constant errSecInvalidOwnerEdit Invalid attempt to change the owner of this item.
194 @constant errSecTrustNotAvailable No trust results are available.
195 @discussion The assigned error space is discontinuous: -25240..-25279, -25290..25329.
199 Note: the comments that appear after these errors are used to create SecErrorMessages.strings.
200 The comments must not be multi-line, and should be in a form meaningful to an end user. If
201 a different or additional comment is needed, it can be put in the header doc format, or on a
202 line that does not start with errZZZ.
207 errSecNotAvailable
= -25291, /* No keychain is available. You may need to restart your computer. */
208 errSecReadOnly
= -25292, /* This keychain cannot be modified. */
209 errSecAuthFailed
= -25293, /* The user name or passphrase you entered is not correct. */
210 errSecNoSuchKeychain
= -25294, /* The specified keychain could not be found. */
211 errSecInvalidKeychain
= -25295, /* The specified keychain is not a valid keychain file. */
212 errSecDuplicateKeychain
= -25296, /* A keychain with the same name already exists. */
213 errSecDuplicateCallback
= -25297, /* The specified callback function is already installed. */
214 errSecInvalidCallback
= -25298, /* The specified callback function is not valid. */
215 errSecDuplicateItem
= -25299, /* The specified item already exists in the keychain. */
216 errSecItemNotFound
= -25300, /* The specified item could not be found in the keychain. */
217 errSecBufferTooSmall
= -25301, /* There is not enough memory available to use the specified item. */
218 errSecDataTooLarge
= -25302, /* This item contains information which is too large or in a format that cannot be displayed. */
219 errSecNoSuchAttr
= -25303, /* The specified attribute does not exist. */
220 errSecInvalidItemRef
= -25304, /* The specified item is no longer valid. It may have been deleted from the keychain. */
221 errSecInvalidSearchRef
= -25305, /* Unable to search the current keychain. */
222 errSecNoSuchClass
= -25306, /* The specified item does not appear to be a valid keychain item. */
223 errSecNoDefaultKeychain
= -25307, /* A default keychain could not be found. */
224 errSecInteractionNotAllowed
= -25308, /* User interaction is not allowed. */
225 errSecReadOnlyAttr
= -25309, /* The specified attribute could not be modified. */
226 errSecWrongSecVersion
= -25310, /* This keychain was created by a different version of the system software and cannot be opened. */
227 errSecKeySizeNotAllowed
= -25311, /* This item specifies a key size which is too large. */
228 errSecNoStorageModule
= -25312, /* A required component (data storage module) could not be loaded. You may need to restart your computer. */
229 errSecNoCertificateModule
= -25313, /* A required component (certificate module) could not be loaded. You may need to restart your computer. */
230 errSecNoPolicyModule
= -25314, /* A required component (policy module) could not be loaded. You may need to restart your computer. */
231 errSecInteractionRequired
= -25315, /* User interaction is required, but is currently not allowed. */
232 errSecDataNotAvailable
= -25316, /* The contents of this item cannot be retrieved. */
233 errSecDataNotModifiable
= -25317, /* The contents of this item cannot be modified. */
234 errSecCreateChainFailed
= -25318, /* One or more certificates required to validate this certificate cannot be found. */
235 errSecInvalidPrefsDomain
= -25319, /* The specified preferences domain is not valid. */
237 errSecACLNotSimple
= -25240, /* The specified access control list is not in standard (simple) form. */
238 errSecPolicyNotFound
= -25241, /* The specified policy cannot be found. */
239 errSecInvalidTrustSetting
= -25242, /* The specified trust setting is invalid. */
240 errSecNoAccessForItem
= -25243, /* The specified item has no access control. */
241 errSecInvalidOwnerEdit
= -25244, /* Invalid attempt to change the owner of this item. */
242 errSecTrustNotAvailable
= -25245 /* No trust results are available. */
245 #if defined(__cplusplus)
249 #endif /* !_SECURITY_SECBASE_H_ */