]> git.saurik.com Git - apple/security.git/blob - libsecurity_smime/lib/SecCmsMessage.h
Security-58286.270.3.0.1.tar.gz
[apple/security.git] / libsecurity_smime / lib / SecCmsMessage.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 SecCmsMessage.h
26 @Copyright (c) 2004,2008,2010 Apple Inc. All Rights Reserved.
27
28 @availability 10.4 and later
29 @abstract CMS message object interfaces
30 @abstract Interfaces of the CMS implementation.
31 @discussion A SecCmsMessage represent a Cryptographic Message
32 Syntax (CMS) object as described in rfc3369.
33 It can be encoded using a SecCmsEncoder into BER
34 data or obtained from a SecCmsDecoder and examined
35 using the functions below.
36 */
37
38 #ifndef _SECURITY_SECCMSMESSAGE_H_
39 #define _SECURITY_SECCMSMESSAGE_H_ 1
40
41 #include <Security/SecCmsBase.h>
42
43
44 #if defined(__cplusplus)
45 extern "C" {
46 #endif
47
48
49 /*!
50 @function
51 @abstract Create a CMS message object.
52 @result A pointer to a newly created SecCmsMessage. When finished using
53 this the caller should call SecCmsMessageDestroy(). On failure
54 returns NULL. In this case call PR_GetError() to find out what went
55 wrong.
56 */
57 extern SecCmsMessageRef
58 SecCmsMessageCreate(void);
59
60 /*!
61 @function
62 @abstract Destroy a CMS message and all of its sub-pieces.
63 @param cmsg Pointer to a SecCmsMessage object.
64 */
65 extern void
66 SecCmsMessageDestroy(SecCmsMessageRef cmsg);
67
68 /*!
69 @function
70 @abstract Return a copy of the given message.
71 @discussion The copy may be virtual or may be real -- either way, the
72 result needs to be passed to SecCmsMessageDestroy later (as does the
73 original).
74 @param cmsg Pointer to a SecCmsMessage object.
75 */
76 extern SecCmsMessageRef
77 SecCmsMessageCopy(SecCmsMessageRef cmsg);
78
79 /*!
80 @function
81 @abstract Return a pointer to the top level contentInfo.
82 */
83 extern SecCmsContentInfoRef
84 SecCmsMessageGetContentInfo(SecCmsMessageRef cmsg);
85
86 /*!
87 @function
88 @abstract Return a pointer to the actual content.
89 @discussion In the case of those types which are encrypted, this returns the *plain* content.
90 In case of nested contentInfos, this descends and retrieves the innermost content.
91 */
92 extern const SecAsn1Item *
93 SecCmsMessageGetContent(SecCmsMessageRef cmsg);
94
95 /*!
96 @function
97 @abstract Count number of levels of CMS content objects in this message.
98 @discussion CMS data content objects do not count.
99 */
100 extern int
101 SecCmsMessageContentLevelCount(SecCmsMessageRef cmsg);
102
103 /*!
104 @function
105 @abstract Find content level #n.
106 @discussion CMS data content objects do not count.
107 */
108 extern SecCmsContentInfoRef
109 SecCmsMessageContentLevel(SecCmsMessageRef cmsg, int n);
110
111 /*!
112 @function
113 @abstract See if message contains certs along the way.
114 */
115 extern Boolean
116 SecCmsMessageContainsCertsOrCrls(SecCmsMessageRef cmsg);
117
118 /*!
119 @function
120 @abstract See if message contains a encrypted submessage.
121 */
122 extern Boolean
123 SecCmsMessageIsEncrypted(SecCmsMessageRef cmsg);
124
125 /*!
126 @function
127 @abstract See if message contains a signed submessage
128 @discussion If the CMS message has a SignedData with a signature (not just a SignedData)
129 return true; false otherwise. This can/should be called before calling
130 VerifySignature, which will always indicate failure if no signature is
131 present, but that does not mean there even was a signature!
132 Note that the content itself can be empty (detached content was sent
133 another way); it is the presence of the signature that matters.
134 */
135 extern Boolean
136 SecCmsMessageIsSigned(SecCmsMessageRef cmsg);
137
138 /*!
139 @function
140 @abstract See if content is empty.
141 @result Returns PR_TRUE is innermost content length is < minLen
142 @discussion XXX need the encrypted content length (why?)
143 */
144 extern Boolean
145 SecCmsMessageIsContentEmpty(SecCmsMessageRef cmsg, unsigned int minLen);
146
147
148 #if defined(__cplusplus)
149 }
150 #endif
151
152 #endif /* _SECURITY_SECCMSMESSAGE_H_ */