]> git.saurik.com Git - apple/security.git/blob - Keychain/SecBase.h
Security-176.tar.gz
[apple/security.git] / Keychain / SecBase.h
1 /*
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18 /*!
19 @header SecBase
20 SecBase contains common declarations for the Security functions.
21 */
22
23 #ifndef _SECURITY_SECBASE_H_
24 #define _SECURITY_SECBASE_H_
25
26 #include <CoreFoundation/CFBase.h>
27
28 #if defined(__cplusplus)
29 extern "C" {
30 #endif
31
32 #ifndef __SEC_TYPES__
33 #define __SEC_TYPES__
34
35 /*!
36 @typedef SecKeychainRef
37 @abstract Contains information about a keychain.
38 */
39 typedef struct OpaqueSecKeychainRef *SecKeychainRef;
40
41 /*!
42 @typedef SecKeychainItemRef
43 @abstract Contains information about a keychain item.
44 */
45 typedef struct OpaqueSecKeychainItemRef *SecKeychainItemRef;
46
47 /*!
48 @typedef SecKeychainSearchRef
49 @abstract Contains information about a keychain search.
50 */
51 typedef struct OpaqueSecKeychainSearchRef *SecKeychainSearchRef;
52
53 /*!
54 @typedef SecKeychainAttrType
55 @abstract Represents a keychain attribute type.
56 */
57 typedef OSType SecKeychainAttrType;
58
59 /*!
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.
65 */
66 struct SecKeychainAttribute
67 {
68 SecKeychainAttrType tag;
69 UInt32 length;
70 void *data;
71 };
72 typedef struct SecKeychainAttribute SecKeychainAttribute;
73
74 /*!
75 @typedef SecKeychainAttributePtr
76 @abstract Represents a pointer to a keychain attribute structure.
77 */
78 typedef SecKeychainAttribute *SecKeychainAttributePtr;
79
80 /*!
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.
85 */
86 struct SecKeychainAttributeList
87 {
88 UInt32 count;
89 SecKeychainAttribute *attr;
90 };
91 typedef struct SecKeychainAttributeList SecKeychainAttributeList;
92
93 /*!
94 @typedef SecKeychainStatus
95 @abstract Represents the status of a keychain.
96 */
97 typedef UInt32 SecKeychainStatus;
98 #endif
99
100 /*!
101 @typedef SecTrustedApplicationRef
102 @abstract Contains information about a trusted application.
103 */
104 typedef struct OpaqueSecTrustedApplicationRef *SecTrustedApplicationRef;
105
106 /*!
107 @typedef SecPolicyRef
108 @abstract Contains information about a policy.
109 */
110 typedef struct OpaqueSecPolicyRef *SecPolicyRef;
111
112 /*!
113 @typedef SecCertificateRef
114 @abstract Contains information about a certificate.
115 */
116 typedef struct OpaqueSecCertificateRef *SecCertificateRef;
117
118 /*!
119 @typedef SecAccessRef
120 @abstract Contains information about an access.
121 */
122 typedef struct OpaqueSecAccessRef *SecAccessRef;
123
124 /*!
125 @typedef SecIdentityRef
126 @abstract Contains information about an identity.
127 */
128 typedef struct OpaqueSecIdentityRef *SecIdentityRef;
129
130 /*!
131 @typedef SecKeyRef
132 @abstract Contains information about a key.
133 */
134 typedef struct OpaqueSecKeyRef *SecKeyRef;
135
136 /*!
137 @typedef SecACLRef
138 @abstract Contains information about an access control list (ACL) entry.
139 */
140 typedef struct OpaqueSecTrustRef *SecACLRef;
141
142 /*!
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.
149 */
150 struct SecKeychainAttributeInfo
151 {
152 UInt32 count;
153 UInt32 *tag;
154 UInt32 *format;
155 };
156 typedef struct SecKeychainAttributeInfo SecKeychainAttributeInfo;
157
158 /*!
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.
196 */
197
198 /*
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.
203 */
204
205 enum
206 {
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. */
236
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. */
243 };
244
245 #if defined(__cplusplus)
246 }
247 #endif
248
249 #endif /* !_SECURITY_SECBASE_H_ */