]> git.saurik.com Git - apple/security.git/blob - Security/libsecurity_cssm/lib/cssmcspi.h
Security-57031.40.6.tar.gz
[apple/security.git] / Security / libsecurity_cssm / lib / cssmcspi.h
1 /*
2 * Copyright (c) 1999-2001,2004,2011,2014 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 * cssmcspi.h -- Service Provider Interface for
24 * Cryptographic Service Provider Modules
25 */
26
27 #ifndef _CSSMCSPI_H_
28 #define _CSSMCSPI_H_ 1
29
30 #include <Security/cssmspi.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 typedef struct cssm_spi_csp_funcs {
37 CSSM_RETURN (CSSMCSPI *EventNotify)
38 (CSSM_CSP_HANDLE CSPHandle,
39 CSSM_CONTEXT_EVENT Event,
40 CSSM_CC_HANDLE CCHandle,
41 const CSSM_CONTEXT *Context);
42 CSSM_RETURN (CSSMCSPI *QuerySize)
43 (CSSM_CSP_HANDLE CSPHandle,
44 CSSM_CC_HANDLE CCHandle,
45 const CSSM_CONTEXT *Context,
46 CSSM_BOOL Encrypt,
47 uint32 QuerySizeCount,
48 CSSM_QUERY_SIZE_DATA_PTR DataBlock);
49 CSSM_RETURN (CSSMCSPI *SignData)
50 (CSSM_CSP_HANDLE CSPHandle,
51 CSSM_CC_HANDLE CCHandle,
52 const CSSM_CONTEXT *Context,
53 const CSSM_DATA *DataBufs,
54 uint32 DataBufCount,
55 CSSM_ALGORITHMS DigestAlgorithm,
56 CSSM_DATA_PTR Signature);
57 CSSM_RETURN (CSSMCSPI *SignDataInit)
58 (CSSM_CSP_HANDLE CSPHandle,
59 CSSM_CC_HANDLE CCHandle,
60 const CSSM_CONTEXT *Context);
61 CSSM_RETURN (CSSMCSPI *SignDataUpdate)
62 (CSSM_CSP_HANDLE CSPHandle,
63 CSSM_CC_HANDLE CCHandle,
64 const CSSM_DATA *DataBufs,
65 uint32 DataBufCount);
66 CSSM_RETURN (CSSMCSPI *SignDataFinal)
67 (CSSM_CSP_HANDLE CSPHandle,
68 CSSM_CC_HANDLE CCHandle,
69 CSSM_DATA_PTR Signature);
70 CSSM_RETURN (CSSMCSPI *VerifyData)
71 (CSSM_CSP_HANDLE CSPHandle,
72 CSSM_CC_HANDLE CCHandle,
73 const CSSM_CONTEXT *Context,
74 const CSSM_DATA *DataBufs,
75 uint32 DataBufCount,
76 CSSM_ALGORITHMS DigestAlgorithm,
77 const CSSM_DATA *Signature);
78 CSSM_RETURN (CSSMCSPI *VerifyDataInit)
79 (CSSM_CSP_HANDLE CSPHandle,
80 CSSM_CC_HANDLE CCHandle,
81 const CSSM_CONTEXT *Context);
82 CSSM_RETURN (CSSMCSPI *VerifyDataUpdate)
83 (CSSM_CSP_HANDLE CSPHandle,
84 CSSM_CC_HANDLE CCHandle,
85 const CSSM_DATA *DataBufs,
86 uint32 DataBufCount);
87 CSSM_RETURN (CSSMCSPI *VerifyDataFinal)
88 (CSSM_CSP_HANDLE CSPHandle,
89 CSSM_CC_HANDLE CCHandle,
90 const CSSM_DATA *Signature);
91 CSSM_RETURN (CSSMCSPI *DigestData)
92 (CSSM_CSP_HANDLE CSPHandle,
93 CSSM_CC_HANDLE CCHandle,
94 const CSSM_CONTEXT *Context,
95 const CSSM_DATA *DataBufs,
96 uint32 DataBufCount,
97 CSSM_DATA_PTR Digest);
98 CSSM_RETURN (CSSMCSPI *DigestDataInit)
99 (CSSM_CSP_HANDLE CSPHandle,
100 CSSM_CC_HANDLE CCHandle,
101 const CSSM_CONTEXT *Context);
102 CSSM_RETURN (CSSMCSPI *DigestDataUpdate)
103 (CSSM_CSP_HANDLE CSPHandle,
104 CSSM_CC_HANDLE CCHandle,
105 const CSSM_DATA *DataBufs,
106 uint32 DataBufCount);
107 CSSM_RETURN (CSSMCSPI *DigestDataClone)
108 (CSSM_CSP_HANDLE CSPHandle,
109 CSSM_CC_HANDLE CCHandle,
110 CSSM_CC_HANDLE ClonedCCHandle);
111 CSSM_RETURN (CSSMCSPI *DigestDataFinal)
112 (CSSM_CSP_HANDLE CSPHandle,
113 CSSM_CC_HANDLE CCHandle,
114 CSSM_DATA_PTR Digest);
115 CSSM_RETURN (CSSMCSPI *GenerateMac)
116 (CSSM_CSP_HANDLE CSPHandle,
117 CSSM_CC_HANDLE CCHandle,
118 const CSSM_CONTEXT *Context,
119 const CSSM_DATA *DataBufs,
120 uint32 DataBufCount,
121 CSSM_DATA_PTR Mac);
122 CSSM_RETURN (CSSMCSPI *GenerateMacInit)
123 (CSSM_CSP_HANDLE CSPHandle,
124 CSSM_CC_HANDLE CCHandle,
125 const CSSM_CONTEXT *Context);
126 CSSM_RETURN (CSSMCSPI *GenerateMacUpdate)
127 (CSSM_CSP_HANDLE CSPHandle,
128 CSSM_CC_HANDLE CCHandle,
129 const CSSM_DATA *DataBufs,
130 uint32 DataBufCount);
131 CSSM_RETURN (CSSMCSPI *GenerateMacFinal)
132 (CSSM_CSP_HANDLE CSPHandle,
133 CSSM_CC_HANDLE CCHandle,
134 CSSM_DATA_PTR Mac);
135 CSSM_RETURN (CSSMCSPI *VerifyMac)
136 (CSSM_CSP_HANDLE CSPHandle,
137 CSSM_CC_HANDLE CCHandle,
138 const CSSM_CONTEXT *Context,
139 const CSSM_DATA *DataBufs,
140 uint32 DataBufCount,
141 const CSSM_DATA *Mac);
142 CSSM_RETURN (CSSMCSPI *VerifyMacInit)
143 (CSSM_CSP_HANDLE CSPHandle,
144 CSSM_CC_HANDLE CCHandle,
145 const CSSM_CONTEXT *Context);
146 CSSM_RETURN (CSSMCSPI *VerifyMacUpdate)
147 (CSSM_CSP_HANDLE CSPHandle,
148 CSSM_CC_HANDLE CCHandle,
149 const CSSM_DATA *DataBufs,
150 uint32 DataBufCount);
151 CSSM_RETURN (CSSMCSPI *VerifyMacFinal)
152 (CSSM_CSP_HANDLE CSPHandle,
153 CSSM_CC_HANDLE CCHandle,
154 const CSSM_DATA *Mac);
155 CSSM_RETURN (CSSMCSPI *EncryptData)
156 (CSSM_CSP_HANDLE CSPHandle,
157 CSSM_CC_HANDLE CCHandle,
158 const CSSM_CONTEXT *Context,
159 const CSSM_DATA *ClearBufs,
160 uint32 ClearBufCount,
161 CSSM_DATA_PTR CipherBufs,
162 uint32 CipherBufCount,
163 CSSM_SIZE *bytesEncrypted,
164 CSSM_DATA_PTR RemData,
165 CSSM_PRIVILEGE Privilege);
166 CSSM_RETURN (CSSMCSPI *EncryptDataInit)
167 (CSSM_CSP_HANDLE CSPHandle,
168 CSSM_CC_HANDLE CCHandle,
169 const CSSM_CONTEXT *Context,
170 CSSM_PRIVILEGE Privilege);
171 CSSM_RETURN (CSSMCSPI *EncryptDataUpdate)
172 (CSSM_CSP_HANDLE CSPHandle,
173 CSSM_CC_HANDLE CCHandle,
174 const CSSM_DATA *ClearBufs,
175 uint32 ClearBufCount,
176 CSSM_DATA_PTR CipherBufs,
177 uint32 CipherBufCount,
178 CSSM_SIZE *bytesEncrypted);
179 CSSM_RETURN (CSSMCSPI *EncryptDataFinal)
180 (CSSM_CSP_HANDLE CSPHandle,
181 CSSM_CC_HANDLE CCHandle,
182 CSSM_DATA_PTR RemData);
183 CSSM_RETURN (CSSMCSPI *DecryptData)
184 (CSSM_CSP_HANDLE CSPHandle,
185 CSSM_CC_HANDLE CCHandle,
186 const CSSM_CONTEXT *Context,
187 const CSSM_DATA *CipherBufs,
188 uint32 CipherBufCount,
189 CSSM_DATA_PTR ClearBufs,
190 uint32 ClearBufCount,
191 CSSM_SIZE *bytesDecrypted,
192 CSSM_DATA_PTR RemData,
193 CSSM_PRIVILEGE Privilege);
194 CSSM_RETURN (CSSMCSPI *DecryptDataInit)
195 (CSSM_CSP_HANDLE CSPHandle,
196 CSSM_CC_HANDLE CCHandle,
197 const CSSM_CONTEXT *Context,
198 CSSM_PRIVILEGE Privilege);
199 CSSM_RETURN (CSSMCSPI *DecryptDataUpdate)
200 (CSSM_CSP_HANDLE CSPHandle,
201 CSSM_CC_HANDLE CCHandle,
202 const CSSM_DATA *CipherBufs,
203 uint32 CipherBufCount,
204 CSSM_DATA_PTR ClearBufs,
205 uint32 ClearBufCount,
206 CSSM_SIZE *bytesDecrypted);
207 CSSM_RETURN (CSSMCSPI *DecryptDataFinal)
208 (CSSM_CSP_HANDLE CSPHandle,
209 CSSM_CC_HANDLE CCHandle,
210 CSSM_DATA_PTR RemData);
211 CSSM_RETURN (CSSMCSPI *QueryKeySizeInBits)
212 (CSSM_CSP_HANDLE CSPHandle,
213 CSSM_CC_HANDLE CCHandle,
214 const CSSM_CONTEXT *Context,
215 const CSSM_KEY *Key,
216 CSSM_KEY_SIZE_PTR KeySize);
217 CSSM_RETURN (CSSMCSPI *GenerateKey)
218 (CSSM_CSP_HANDLE CSPHandle,
219 CSSM_CC_HANDLE CCHandle,
220 const CSSM_CONTEXT *Context,
221 uint32 KeyUsage,
222 uint32 KeyAttr,
223 const CSSM_DATA *KeyLabel,
224 const CSSM_RESOURCE_CONTROL_CONTEXT *CredAndAclEntry,
225 CSSM_KEY_PTR Key,
226 CSSM_PRIVILEGE Privilege);
227 CSSM_RETURN (CSSMCSPI *GenerateKeyPair)
228 (CSSM_CSP_HANDLE CSPHandle,
229 CSSM_CC_HANDLE CCHandle,
230 const CSSM_CONTEXT *Context,
231 uint32 PublicKeyUsage,
232 uint32 PublicKeyAttr,
233 const CSSM_DATA *PublicKeyLabel,
234 CSSM_KEY_PTR PublicKey,
235 uint32 PrivateKeyUsage,
236 uint32 PrivateKeyAttr,
237 const CSSM_DATA *PrivateKeyLabel,
238 const CSSM_RESOURCE_CONTROL_CONTEXT *CredAndAclEntry,
239 CSSM_KEY_PTR PrivateKey,
240 CSSM_PRIVILEGE Privilege);
241 CSSM_RETURN (CSSMCSPI *GenerateRandom)
242 (CSSM_CSP_HANDLE CSPHandle,
243 CSSM_CC_HANDLE CCHandle,
244 const CSSM_CONTEXT *Context,
245 CSSM_DATA_PTR RandomNumber);
246 CSSM_RETURN (CSSMCSPI *GenerateAlgorithmParams)
247 (CSSM_CSP_HANDLE CSPHandle,
248 CSSM_CC_HANDLE CCHandle,
249 const CSSM_CONTEXT *Context,
250 uint32 ParamBits,
251 CSSM_DATA_PTR Param,
252 uint32 *NumberOfUpdatedAttibutes,
253 CSSM_CONTEXT_ATTRIBUTE_PTR *UpdatedAttributes);
254 CSSM_RETURN (CSSMCSPI *WrapKey)
255 (CSSM_CSP_HANDLE CSPHandle,
256 CSSM_CC_HANDLE CCHandle,
257 const CSSM_CONTEXT *Context,
258 const CSSM_ACCESS_CREDENTIALS *AccessCred,
259 const CSSM_KEY *Key,
260 const CSSM_DATA *DescriptiveData,
261 CSSM_WRAP_KEY_PTR WrappedKey,
262 CSSM_PRIVILEGE Privilege);
263 CSSM_RETURN (CSSMCSPI *UnwrapKey)
264 (CSSM_CSP_HANDLE CSPHandle,
265 CSSM_CC_HANDLE CCHandle,
266 const CSSM_CONTEXT *Context,
267 const CSSM_KEY *PublicKey,
268 const CSSM_WRAP_KEY *WrappedKey,
269 uint32 KeyUsage,
270 uint32 KeyAttr,
271 const CSSM_DATA *KeyLabel,
272 const CSSM_RESOURCE_CONTROL_CONTEXT *CredAndAclEntry,
273 CSSM_KEY_PTR UnwrappedKey,
274 CSSM_DATA_PTR DescriptiveData,
275 CSSM_PRIVILEGE Privilege);
276 CSSM_RETURN (CSSMCSPI *DeriveKey)
277 (CSSM_CSP_HANDLE CSPHandle,
278 CSSM_CC_HANDLE CCHandle,
279 const CSSM_CONTEXT *Context,
280 CSSM_DATA_PTR Param,
281 uint32 KeyUsage,
282 uint32 KeyAttr,
283 const CSSM_DATA *KeyLabel,
284 const CSSM_RESOURCE_CONTROL_CONTEXT *CredAndAclEntry,
285 CSSM_KEY_PTR DerivedKey);
286 CSSM_RETURN (CSSMCSPI *FreeKey)
287 (CSSM_CSP_HANDLE CSPHandle,
288 const CSSM_ACCESS_CREDENTIALS *AccessCred,
289 CSSM_KEY_PTR KeyPtr,
290 CSSM_BOOL Delete);
291 CSSM_RETURN (CSSMCSPI *PassThrough)
292 (CSSM_CSP_HANDLE CSPHandle,
293 CSSM_CC_HANDLE CCHandle,
294 const CSSM_CONTEXT *Context,
295 uint32 PassThroughId,
296 const void *InData,
297 void **OutData);
298 CSSM_RETURN (CSSMCSPI *Login)
299 (CSSM_CSP_HANDLE CSPHandle,
300 const CSSM_ACCESS_CREDENTIALS *AccessCred,
301 const CSSM_DATA *LoginName,
302 const void *Reserved);
303 CSSM_RETURN (CSSMCSPI *Logout)
304 (CSSM_CSP_HANDLE CSPHandle);
305 CSSM_RETURN (CSSMCSPI *ChangeLoginAcl)
306 (CSSM_CSP_HANDLE CSPHandle,
307 const CSSM_ACCESS_CREDENTIALS *AccessCred,
308 const CSSM_ACL_EDIT *AclEdit);
309 CSSM_RETURN (CSSMCSPI *ObtainPrivateKeyFromPublicKey)
310 (CSSM_CSP_HANDLE CSPHandle,
311 const CSSM_KEY *PublicKey,
312 CSSM_KEY_PTR PrivateKey);
313 CSSM_RETURN (CSSMCSPI *RetrieveUniqueId)
314 (CSSM_CSP_HANDLE CSPHandle,
315 CSSM_DATA_PTR UniqueID);
316 CSSM_RETURN (CSSMCSPI *RetrieveCounter)
317 (CSSM_CSP_HANDLE CSPHandle,
318 CSSM_DATA_PTR Counter);
319 CSSM_RETURN (CSSMCSPI *VerifyDevice)
320 (CSSM_CSP_HANDLE CSPHandle,
321 const CSSM_DATA *DeviceCert);
322 CSSM_RETURN (CSSMCSPI *GetTimeValue)
323 (CSSM_CSP_HANDLE CSPHandle,
324 CSSM_ALGORITHMS TimeAlgorithm,
325 CSSM_DATA *TimeData);
326 CSSM_RETURN (CSSMCSPI *GetOperationalStatistics)
327 (CSSM_CSP_HANDLE CSPHandle,
328 CSSM_CSP_OPERATIONAL_STATISTICS *Statistics);
329 CSSM_RETURN (CSSMCSPI *GetLoginAcl)
330 (CSSM_CSP_HANDLE CSPHandle,
331 const CSSM_STRING *SelectionTag,
332 uint32 *NumberOfAclInfos,
333 CSSM_ACL_ENTRY_INFO_PTR *AclInfos);
334 CSSM_RETURN (CSSMCSPI *GetKeyAcl)
335 (CSSM_CSP_HANDLE CSPHandle,
336 const CSSM_KEY *Key,
337 const CSSM_STRING *SelectionTag,
338 uint32 *NumberOfAclInfos,
339 CSSM_ACL_ENTRY_INFO_PTR *AclInfos);
340 CSSM_RETURN (CSSMCSPI *ChangeKeyAcl)
341 (CSSM_CSP_HANDLE CSPHandle,
342 const CSSM_ACCESS_CREDENTIALS *AccessCred,
343 const CSSM_ACL_EDIT *AclEdit,
344 const CSSM_KEY *Key);
345 CSSM_RETURN (CSSMCSPI *GetKeyOwner)
346 (CSSM_CSP_HANDLE CSPHandle,
347 const CSSM_KEY *Key,
348 CSSM_ACL_OWNER_PROTOTYPE_PTR Owner);
349 CSSM_RETURN (CSSMCSPI *ChangeKeyOwner)
350 (CSSM_CSP_HANDLE CSPHandle,
351 const CSSM_ACCESS_CREDENTIALS *AccessCred,
352 const CSSM_KEY *Key,
353 const CSSM_ACL_OWNER_PROTOTYPE *NewOwner);
354 CSSM_RETURN (CSSMCSPI *GetLoginOwner)
355 (CSSM_CSP_HANDLE CSPHandle,
356 CSSM_ACL_OWNER_PROTOTYPE_PTR Owner);
357 CSSM_RETURN (CSSMCSPI *ChangeLoginOwner)
358 (CSSM_CSP_HANDLE CSPHandle,
359 const CSSM_ACCESS_CREDENTIALS *AccessCred,
360 const CSSM_ACL_OWNER_PROTOTYPE *NewOwner);
361 } CSSM_SPI_CSP_FUNCS DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER, *CSSM_SPI_CSP_FUNCS_PTR DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;
362
363 #ifdef __cplusplus
364 }
365 #endif
366
367 #endif /* _CSSMCSPI_H_ */