]> git.saurik.com Git - apple/security.git/blob - AppleCSP/AppleCSP/pkcs_7_8.h
669ceb0d569c9f063fcaa8442c79891c7ea8562a
[apple/security.git] / AppleCSP / AppleCSP / pkcs_7_8.h
1 /*
2 * Copyright (c) 2000-2001 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 //
20 // pkcs_7_8.h - encode/decode key blobs in PKCS7 and
21 // PKCS8 format.
22 //
23
24 #ifndef _PKCS_7_8_H_
25 #define _PKCS_7_8_H_
26
27 #include <Security/cssmtype.h>
28 #include <Security/utilities.h>
29 #include <Security/cssmalloc.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /*
36 * Given a symmetric CssmKey in raw format, and its encrypted blob,
37 * cook up a PKCS-7 encoded blob.
38 */
39 void cspEncodePkcs7(
40 CSSM_ALGORITHMS alg, // encryption alg, used by PKCS7
41 CSSM_ENCRYPT_MODE mode, // ditto
42 const CssmData &encryptedBlob,
43 CssmData &encodedBlob, // mallocd and RETURNED
44 CssmAllocator &allocator);
45
46 /*
47 * Given a symmetric key in (encrypted, encoded) PKCS-7 format,
48 * obtain its encrypted key blob.
49 */
50 void cspDecodePkcs7(
51 const CssmKey &wrappedKey, // for inferring format
52 CssmData &decodedBlob, // mallocd and RETURNED
53 CSSM_KEYBLOB_FORMAT &format, // RETURNED
54 CssmAllocator &allocator);
55
56 /*
57 * Given an asymmetric CssmKey in raw format, and its encrypted blob,
58 * cook up a PKCS-8 encoded blob.
59 */
60 void cspEncodePkcs8(
61 CSSM_ALGORITHMS alg, // encryption alg, used by PKCS8
62 CSSM_ENCRYPT_MODE mode, // ditto
63 const CssmData &encryptedBlob,
64 CssmData &encodedBlob, // mallocd and RETURNED
65 CssmAllocator &allocator);
66
67 /*
68 * Given a an asymmetric key in (encrypted, encoded) PKCS-8 format,
69 * obtain its encrypted key blob.
70 */
71 void cspDecodePkcs8(
72 const CssmKey &wrappedKey, // for inferring format
73 CssmData &decodedBlob, // mallocd and RETURNED
74 CSSM_KEYBLOB_FORMAT &format, // RETURNED
75 CssmAllocator &allocator);
76
77 #ifdef __cplusplus
78 }
79 #endif
80
81 #endif /* _PKCS_7_8_H_ */