2 * Copyright (c) 2003-2004,2011,2014 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@
27 #ifndef _PKCS7_TEMPLATES_H_
28 #define _PKCS7_TEMPLATES_H_
30 #include <Security/secasn1t.h>
31 #include <Security/cssmtype.h>
32 #include <Security/x509defs.h>
39 * DigestInfo ::= SEQUENCE {
40 * digestAlgorithm DigestAlgorithmIdentifier,
44 * Digest ::= OCTET STRING
47 CSSM_X509_ALGORITHM_IDENTIFIER digestAlgorithm
;
51 extern const SecAsn1Template NSS_P7_DigestInfoTemplate
[];
54 * Uninterpreted ContentInfo, with content stripped from its
55 * EXPLICIT CONTEXT_SPECIFIC wrapper
57 * ContentInfo ::= SEQUENCE {
58 * contentType ContentType,
59 * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
65 } NSS_P7_RawContentInfo
;
67 extern const SecAsn1Template NSS_P7_RawContentInfoTemplate
[];
69 #pragma mark ---- ContentInfo.content types -----
72 * Expand beyond ASN_ANY/CSSM_DATA as needed
74 typedef CSSM_DATA NSS_P7_SignedData
;
75 typedef CSSM_DATA NSS_P7_EnvelData
;
76 typedef CSSM_DATA NSS_P7_SignEnvelData
;
77 typedef CSSM_DATA NSS_P7_DigestedData
;
82 * EncryptedContentInfo ::= SEQUENCE {
83 * contentType ContentType,
84 * contentEncryptionAlgorithm
85 * ContentEncryptionAlgorithmIdentifier,
87 * [0] IMPLICIT EncryptedContent OPTIONAL
90 * EncryptedContent ::= OCTET STRING
95 CSSM_X509_ALGORITHM_IDENTIFIER encrAlg
;
96 CSSM_DATA encrContent
;
97 } NSS_P7_EncrContentInfo
;
100 * EncryptedData ::= SEQUENCE {
102 * encryptedContentInfo EncryptedContentInfo
107 NSS_P7_EncrContentInfo contentInfo
;
108 } NSS_P7_EncryptedData
;
110 extern const SecAsn1Template NSS_P7_EncrContentInfoTemplate
[];
111 extern const SecAsn1Template NSS_P7_EncryptedDataTemplate
[];
112 extern const SecAsn1Template NSS_P7_PtrToEncryptedDataTemplate
[];
114 /* the stub templates for unimplemented contentTypes */
115 #define NSS_P7_PtrToSignedDataTemplate kSecAsn1PointerToAnyTemplate
116 #define NSS_P7_PtrToEnvelDataTemplate kSecAsn1PointerToAnyTemplate
117 #define NSS_P7_PtrToSignEnvelDataTemplate kSecAsn1PointerToAnyTemplate
118 #define NSS_P7_PtrToDigestedDataTemplate kSecAsn1PointerToAnyTemplate
120 #pragma mark ---- decoded ContentInfo -----
123 * For convenience, out dynamic template chooser for ContentInfo.content
124 * drops one of these into the decoded struct. Thus, higher level
125 * code doesn't have to grunge around comparing OIDs to figure out
139 * Decoded ContentInfo. Decoded via SEC_ASN1_DYNAMIC per contentType.
142 CSSM_OID contentType
;
145 CSSM_DATA
*data
; // CSSMOID_PKCS7_Data
146 // contents of Octet String
147 NSS_P7_SignedData
*signedData
;
148 // CSSMOID_PKCS7_SignedData
149 NSS_P7_EnvelData
*envData
; // CSSMOID_PKCS7_EnvelopedData
150 NSS_P7_SignEnvelData
*signEnvelData
;
151 // CSSMOID_PKCS7_SignedAndEnvelopedData
152 NSS_P7_DigestedData
*digestedData
;
153 // CSSMOID_PKCS7_DigestedData
154 NSS_P7_EncryptedData
*encryptData
;
155 //CSSMOID_PKCS7_EncryptedData
158 } NSS_P7_DecodedContentInfo
;
160 extern const SecAsn1Template NSS_P7_DecodedContentInfoTemplate
[];
166 #endif /* _PKCS7_TEMPLATES_H_ */