]>
Commit | Line | Data |
---|---|---|
b1ab9ed8 | 1 | /* |
d8f41ccd | 2 | * Copyright (c) 2003-2004,2011,2014 Apple Inc. All Rights Reserved. |
b1ab9ed8 A |
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 | * pkcs7Templates.h | |
25 | */ | |
26 | ||
27 | #ifndef _PKCS7_TEMPLATES_H_ | |
28 | #define _PKCS7_TEMPLATES_H_ | |
29 | ||
30 | #include <Security/secasn1t.h> | |
31 | #include <Security/cssmtype.h> | |
32 | #include <Security/x509defs.h> | |
33 | ||
34 | #ifdef __cplusplus | |
35 | extern "C" { | |
36 | #endif | |
37 | ||
38 | /* | |
39 | * DigestInfo ::= SEQUENCE { | |
40 | * digestAlgorithm DigestAlgorithmIdentifier, | |
41 | * digest Digest | |
42 | * } | |
43 | * | |
44 | * Digest ::= OCTET STRING | |
45 | */ | |
46 | typedef struct { | |
47 | CSSM_X509_ALGORITHM_IDENTIFIER digestAlgorithm; | |
48 | CSSM_DATA digest; | |
49 | } NSS_P7_DigestInfo; | |
50 | ||
51 | extern const SecAsn1Template NSS_P7_DigestInfoTemplate[]; | |
52 | ||
53 | /* | |
54 | * Uninterpreted ContentInfo, with content stripped from its | |
55 | * EXPLICIT CONTEXT_SPECIFIC wrapper | |
56 | * | |
57 | * ContentInfo ::= SEQUENCE { | |
58 | * contentType ContentType, | |
59 | * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL | |
60 | * } | |
61 | */ | |
62 | typedef struct { | |
63 | CSSM_OID contentType; | |
64 | CSSM_DATA content; | |
65 | } NSS_P7_RawContentInfo; | |
66 | ||
67 | extern const SecAsn1Template NSS_P7_RawContentInfoTemplate[]; | |
68 | ||
69 | #pragma mark ---- ContentInfo.content types ----- | |
70 | ||
71 | /* | |
72 | * Expand beyond ASN_ANY/CSSM_DATA as needed | |
73 | */ | |
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; | |
78 | ||
79 | /* EncryptedData */ | |
80 | ||
81 | /* | |
82 | * EncryptedContentInfo ::= SEQUENCE { | |
83 | * contentType ContentType, | |
84 | * contentEncryptionAlgorithm | |
85 | * ContentEncryptionAlgorithmIdentifier, | |
86 | * encryptedContent | |
87 | * [0] IMPLICIT EncryptedContent OPTIONAL | |
88 | * } | |
89 | * | |
90 | * EncryptedContent ::= OCTET STRING | |
91 | */ | |
92 | ||
93 | typedef struct { | |
94 | CSSM_OID contentType; | |
95 | CSSM_X509_ALGORITHM_IDENTIFIER encrAlg; | |
96 | CSSM_DATA encrContent; | |
97 | } NSS_P7_EncrContentInfo; | |
98 | ||
99 | /* | |
100 | * EncryptedData ::= SEQUENCE { | |
101 | * version Version, | |
102 | * encryptedContentInfo EncryptedContentInfo | |
103 | * } | |
104 | */ | |
105 | typedef struct { | |
106 | CSSM_DATA version; | |
107 | NSS_P7_EncrContentInfo contentInfo; | |
108 | } NSS_P7_EncryptedData; | |
109 | ||
110 | extern const SecAsn1Template NSS_P7_EncrContentInfoTemplate[]; | |
111 | extern const SecAsn1Template NSS_P7_EncryptedDataTemplate[]; | |
112 | extern const SecAsn1Template NSS_P7_PtrToEncryptedDataTemplate[]; | |
113 | ||
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 | |
119 | ||
120 | #pragma mark ---- decoded ContentInfo ----- | |
121 | ||
122 | /* | |
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 | |
126 | * what's there. | |
127 | */ | |
128 | typedef enum { | |
129 | CT_None = 0, | |
130 | CT_Data, | |
131 | CT_SignedData, | |
132 | CT_EnvData, | |
133 | CT_SignedEnvData, | |
134 | CT_DigestData, | |
135 | CT_EncryptedData | |
136 | } NSS_P7_CI_Type; | |
137 | ||
138 | /* | |
139 | * Decoded ContentInfo. Decoded via SEC_ASN1_DYNAMIC per contentType. | |
140 | */ | |
141 | typedef struct { | |
142 | CSSM_OID contentType; | |
143 | NSS_P7_CI_Type type; | |
144 | union { | |
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 | |
156 | ||
157 | } content; | |
158 | } NSS_P7_DecodedContentInfo; | |
159 | ||
160 | extern const SecAsn1Template NSS_P7_DecodedContentInfoTemplate[]; | |
161 | ||
162 | #ifdef __cplusplus | |
163 | } | |
164 | #endif | |
165 | ||
166 | #endif /* _PKCS7_TEMPLATES_H_ */ | |
167 |