2 * Copyright (c) 2004,2008,2010 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
25 @header SecCmsEncoder.h
26 @Copyright (c) 2004,2008,2010 Apple Inc. All Rights Reserved.
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
33 A SecCmsEncoder object is used to encode CMS messages into BER.
36 #ifndef _SECURITY_SECCMSENCODER_H_
37 #define _SECURITY_SECCMSENCODER_H_ 1
39 #include <Security/SecCmsBase.h>
40 #include <CoreFoundation/CFData.h>
43 #if defined(__cplusplus)
48 /*! @functiongroup Streaming interface */
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
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
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
);
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
88 SecCmsEncoderUpdate(SecCmsEncoderRef encoder
, const void *data
, CFIndex len
);
92 @abstract Abort a (presumably failed) encoding process.
93 @param encoder Pointer to a SecCmsEncoderContext created with SecCmsEncoderCreate().
94 @availability 10.4 and later
97 SecCmsEncoderDestroy(SecCmsEncoderRef encoder
);
101 @abstract Signal the end of data.
102 @discussion Walks down the chain of encoders and the finishes them from the
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
110 SecCmsEncoderFinish(SecCmsEncoderRef encoder
);
112 /*! @functiongroup One shot interface */
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.
123 SecCmsMessageEncode(SecCmsMessageRef cmsg
, const SecAsn1Item
*input
,
124 CFMutableDataRef outBer
);
127 #if defined(__cplusplus)
131 #endif /* _SECURITY_SECCMSENCODER_H_ */