]> git.saurik.com Git - apple/security.git/blob - libsecurity_smime/lib/SecCmsEncoder.h
Security-58286.270.3.0.1.tar.gz
[apple/security.git] / libsecurity_smime / lib / SecCmsEncoder.h
1 /*
2 * Copyright (c) 2004,2008,2010 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
24 /*!
25 @header SecCmsEncoder.h
26 @Copyright (c) 2004,2008,2010 Apple Inc. All Rights Reserved.
27
28 @availability 10.4 and later
29 @abstract CMS message encoding
30 @discussion The functions here implement functions for encoding
31 Cryptographic Message Syntax (CMS) objects as described
32 in rfc3369.
33 A SecCmsEncoder object is used to encode CMS messages into BER.
34 */
35
36 #ifndef _SECURITY_SECCMSENCODER_H_
37 #define _SECURITY_SECCMSENCODER_H_ 1
38
39 #include <Security/SecCmsBase.h>
40 #include <CoreFoundation/CFData.h>
41
42
43 #if defined(__cplusplus)
44 extern "C" {
45 #endif
46
47
48 /*! @functiongroup Streaming interface */
49 /*!
50 @function
51 @abstract Set up encoding of a CMS message.
52 @param cmsg The SecCmsMessageRef to be encoded.
53 @param outputfn callback function for delivery of BER-encoded output will
54 not be called if NULL.
55 @param outputarg first argument passed to outputfn when it is called.
56 @param outBer If non-NULL, a CFMutableDataRef to which the
57 BER-encoded output will be appended.
58 @param pwfn callback function for getting token password for enveloped
59 data content with a password recipient.
60 @param pwfn_arg first argument passed to pwfn when it is called.
61 @param encrypt_key_cb callback function for getting bulk key for encryptedData content.
62 @param encrypt_key_cb_arg first argument passed to encrypt_key_cb when it is
63 called.
64 @result On success a pointer to a SecCmsMessage containing the decoded message
65 is returned. On failure returns NULL. Call PR_GetError() to find out what
66 went wrong in this case.
67 @availability 10.4 and later
68 */
69 extern OSStatus
70 SecCmsEncoderCreate(SecCmsMessageRef cmsg,
71 SecCmsContentCallback outputfn, void *outputarg,
72 CFMutableDataRef outBer,
73 PK11PasswordFunc pwfn, void *pwfn_arg,
74 SecCmsGetDecryptKeyCallback encrypt_key_cb, void *encrypt_key_cb_arg,
75 SecCmsEncoderRef *outEncoder);
76
77 /*!
78 @function
79 @abstract Take content data delivery from the user
80 @param encoder encoder context
81 @param data content data
82 @param len length of content data
83 @result On success 0 is returned. On failure returns non zero. Call
84 PR_GetError() to find out what went wrong in this case.
85 @availability 10.4 and later
86 */
87 extern OSStatus
88 SecCmsEncoderUpdate(SecCmsEncoderRef encoder, const void *data, CFIndex len);
89
90 /*!
91 @function
92 @abstract Abort a (presumably failed) encoding process.
93 @param encoder Pointer to a SecCmsEncoderContext created with SecCmsEncoderCreate().
94 @availability 10.4 and later
95 */
96 extern void
97 SecCmsEncoderDestroy(SecCmsEncoderRef encoder);
98
99 /*!
100 @function
101 @abstract Signal the end of data.
102 @discussion Walks down the chain of encoders and the finishes them from the
103 innermost out.
104 @param encoder Pointer to a SecCmsEncoder created with SecCmsEncoderCreate().
105 @result On success 0 is returned. On failure returns non zero. Call
106 PR_GetError() to find out what went wrong in this case.
107 @availability 10.4 and later
108 */
109 extern OSStatus
110 SecCmsEncoderFinish(SecCmsEncoderRef encoder);
111
112 /*! @functiongroup One shot interface */
113 /*!
114 @function
115 @abstract BER Encode a CMS message.
116 @param cmsg The SecCmsMessageRef to be encoded.
117 @param input The inner content of the message.
118 @param outBer A CFMutableDataRef to which the
119 BER-encoded output will be appended.
120 @discussion BER Encode a CMS message, with input being the plaintext message and outBer being the output, stored in arena's pool.
121 */
122 extern OSStatus
123 SecCmsMessageEncode(SecCmsMessageRef cmsg, const SecAsn1Item *input,
124 CFMutableDataRef outBer);
125
126
127 #if defined(__cplusplus)
128 }
129 #endif
130
131 #endif /* _SECURITY_SECCMSENCODER_H_ */