2
* The contents of this file are subject to the Mozilla Public
3
* License Version 1.1 (the "License"); you may not use this file
4
* except in compliance with the License. You may obtain a copy of
5
* the License at http://www.mozilla.org/MPL/
7
* Software distributed under the License is distributed on an "AS
8
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
* implied. See the License for the specific language governing
10
* rights and limitations under the License.
12
* The Original Code is the Netscape security libraries.
14
* The Initial Developer of the Original Code is Netscape
15
* Communications Corporation. Portions created by Netscape are
16
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
21
* Alternatively, the contents of this file may be used under the
22
* terms of the GNU General Public License Version 2 or later (the
23
* "GPL"), in which case the provisions of the GPL are applicable
24
* instead of those above. If you wish to allow use of your
25
* version of this file only under the terms of the GPL and not to
26
* allow others to use your version of this file under the MPL,
27
* indicate your decision by deleting the provisions above and
28
* replace them with the notice and other provisions required by
29
* the GPL. If you do not delete the provisions above, a recipient
30
* may use your version of this file under either the MPL or the
35
* Header for pkcs7 types.
37
* $Id: pkcs7t.h,v 1.4 2002/03/14 04:12:23 wtc%netscape.com Exp $
51
typedef struct SEC_PKCS7DecoderContextStr SEC_PKCS7DecoderContext;
52
typedef struct SEC_PKCS7EncoderContextStr SEC_PKCS7EncoderContext;
54
/* legacy defines that haven't been active for years */
55
typedef void *(*SECKEYGetPasswordKey)(void *arg, void *handle);
58
/* Non-opaque objects. NOTE, though: I want them to be treated as
59
* opaque as much as possible. If I could hide them completely,
60
* I would. (I tried, but ran into trouble that was taking me too
61
* much time to get out of.) I still intend to try to do so.
62
* In fact, the only type that "outsiders" should even *name* is
63
* SEC_PKCS7ContentInfo, and they should not reference its fields.
65
/* rjr: PKCS #11 cert handling (pk11cert.c) does use SEC_PKCS7RecipientInfo's.
66
* This is because when we search the recipient list for the cert and key we
67
* want, we need to invert the order of the loops we used to have. The old
70
* For each recipient {
71
* find_cert = PK11_Find_AllCert(recipient->issuerSN);
72
* [which unrolls to... ]
75
* search slot for cert;
79
* the new loop searchs all the recipients at once on a slot. this allows
80
* PKCS #11 to order slots in such a way that logout slots don't get checked
81
* if we can find the cert on a logged in slot. This eliminates lots of
82
* spurious password prompts when smart cards are installed... so why this
83
* comment? If you make SEC_PKCS7RecipientInfo completely opaque, you need
84
* to provide a non-opaque list of issuerSN's (the only field PKCS#11 needs
85
* and fix up pk11cert.c first. NOTE: Only S/MIME calls this special PKCS #11
88
typedef struct SEC_PKCS7ContentInfoStr SEC_PKCS7ContentInfo;
89
typedef struct SEC_PKCS7SignedDataStr SEC_PKCS7SignedData;
90
typedef struct SEC_PKCS7EncryptedContentInfoStr SEC_PKCS7EncryptedContentInfo;
91
typedef struct SEC_PKCS7EnvelopedDataStr SEC_PKCS7EnvelopedData;
92
typedef struct SEC_PKCS7SignedAndEnvelopedDataStr
93
SEC_PKCS7SignedAndEnvelopedData;
94
typedef struct SEC_PKCS7SignerInfoStr SEC_PKCS7SignerInfo;
95
typedef struct SEC_PKCS7RecipientInfoStr SEC_PKCS7RecipientInfo;
96
typedef struct SEC_PKCS7DigestedDataStr SEC_PKCS7DigestedData;
97
typedef struct SEC_PKCS7EncryptedDataStr SEC_PKCS7EncryptedData;
98
typedef struct SEC_PKCS7SMIMEKEAParametersStr SEC_PKCS7SMIMEKEAParameters;
100
* The following is not actually a PKCS7 type, but for now it is only
101
* used by PKCS7, so we have adopted it. If someone else *ever* needs
102
* it, its name should be changed and it should be moved out of here.
103
* Do not dare to use it without doing so!
105
typedef struct SEC_PKCS7AttributeStr SEC_PKCS7Attribute;
107
struct SEC_PKCS7ContentInfoStr {
108
PRArenaPool *poolp; /* local; not part of encoding */
109
PRBool created; /* local; not part of encoding */
110
int refCount; /* local; not part of encoding */
111
SECOidData *contentTypeTag; /* local; not part of encoding */
112
SECKEYGetPasswordKey pwfn; /* local; not part of encoding */
113
void *pwfn_arg; /* local; not part of encoding */
117
SEC_PKCS7DigestedData *digestedData;
118
SEC_PKCS7EncryptedData *encryptedData;
119
SEC_PKCS7EnvelopedData *envelopedData;
120
SEC_PKCS7SignedData *signedData;
121
SEC_PKCS7SignedAndEnvelopedData *signedAndEnvelopedData;
125
struct SEC_PKCS7SignedDataStr {
127
SECAlgorithmID **digestAlgorithms;
128
SEC_PKCS7ContentInfo contentInfo;
130
CERTSignedCrl **crls;
131
SEC_PKCS7SignerInfo **signerInfos;
132
SECItem **digests; /* local; not part of encoding */
133
CERTCertificate **certs; /* local; not part of encoding */
134
CERTCertificateList **certLists; /* local; not part of encoding */
136
#define SEC_PKCS7_SIGNED_DATA_VERSION 1 /* what we *create* */
138
struct SEC_PKCS7EncryptedContentInfoStr {
139
SECOidData *contentTypeTag; /* local; not part of encoding */
141
SECAlgorithmID contentEncAlg;
143
SECItem plainContent; /* local; not part of encoding */
144
/* bytes not encrypted, but encoded */
145
int keysize; /* local; not part of encoding */
146
/* size of bulk encryption key
147
* (only used by creation code) */
148
SECOidTag encalg; /* local; not part of encoding */
149
/* oid tag of encryption algorithm
150
* (only used by creation code) */
153
struct SEC_PKCS7EnvelopedDataStr {
155
SEC_PKCS7RecipientInfo **recipientInfos;
156
SEC_PKCS7EncryptedContentInfo encContentInfo;
158
#define SEC_PKCS7_ENVELOPED_DATA_VERSION 0 /* what we *create* */
160
struct SEC_PKCS7SignedAndEnvelopedDataStr {
162
SEC_PKCS7RecipientInfo **recipientInfos;
163
SECAlgorithmID **digestAlgorithms;
164
SEC_PKCS7EncryptedContentInfo encContentInfo;
166
CERTSignedCrl **crls;
167
SEC_PKCS7SignerInfo **signerInfos;
168
SECItem **digests; /* local; not part of encoding */
169
CERTCertificate **certs; /* local; not part of encoding */
170
CERTCertificateList **certLists; /* local; not part of encoding */
171
PK11SymKey *sigKey; /* local; not part of encoding */
173
#define SEC_PKCS7_SIGNED_AND_ENVELOPED_DATA_VERSION 1 /* what we *create* */
175
struct SEC_PKCS7SignerInfoStr {
177
CERTIssuerAndSN *issuerAndSN;
178
SECAlgorithmID digestAlg;
179
SEC_PKCS7Attribute **authAttr;
180
SECAlgorithmID digestEncAlg;
182
SEC_PKCS7Attribute **unAuthAttr;
183
CERTCertificate *cert; /* local; not part of encoding */
184
CERTCertificateList *certList; /* local; not part of encoding */
186
#define SEC_PKCS7_SIGNER_INFO_VERSION 1 /* what we *create* */
188
struct SEC_PKCS7RecipientInfoStr {
190
CERTIssuerAndSN *issuerAndSN;
191
SECAlgorithmID keyEncAlg;
193
CERTCertificate *cert; /* local; not part of encoding */
195
#define SEC_PKCS7_RECIPIENT_INFO_VERSION 0 /* what we *create* */
197
struct SEC_PKCS7DigestedDataStr {
199
SECAlgorithmID digestAlg;
200
SEC_PKCS7ContentInfo contentInfo;
203
#define SEC_PKCS7_DIGESTED_DATA_VERSION 0 /* what we *create* */
205
struct SEC_PKCS7EncryptedDataStr {
207
SEC_PKCS7EncryptedContentInfo encContentInfo;
209
#define SEC_PKCS7_ENCRYPTED_DATA_VERSION 0 /* what we *create* */
212
* See comment above about this type not really belonging to PKCS7.
214
struct SEC_PKCS7AttributeStr {
215
/* The following fields make up an encoded Attribute: */
217
SECItem **values; /* data may or may not be encoded */
218
/* The following fields are not part of an encoded Attribute: */
220
PRBool encoded; /* when true, values are encoded */
223
/* An enumerated type used to select templates based on the encryption
224
scenario and data specifics. */
228
SECKEAUsesSkipjack = 0,
229
SECKEAUsesNonSkipjack = 1,
230
SECKEAUsesNonSkipjackWithPaddedEncKey = 2
231
} SECKEATemplateSelector;
233
/* ### mwelch - S/MIME KEA parameters. These don't really fit here,
234
but I cannot think of a more appropriate place at this time. */
235
struct SEC_PKCS7SMIMEKEAParametersStr {
236
SECItem originatorKEAKey; /* sender KEA key (encrypted?) */
237
SECItem originatorRA; /* random number generated by sender */
238
SECItem nonSkipjackIV; /* init'n vector for SkipjackCBC64
239
decryption of KEA key if Skipjack
240
is not the bulk algorithm used on
242
SECItem bulkKeySize; /* if Skipjack is not the bulk
243
algorithm used on the message,
244
and the size of the bulk encryption
245
key is not the same as that of
246
originatorKEAKey (due to padding
247
perhaps), this field will contain
248
the real size of the bulk encryption
253
* Type of function passed to SEC_PKCS7Decode or SEC_PKCS7DecoderStart.
254
* If specified, this is where the content bytes (only) will be "sent"
255
* as they are recovered during the decoding.
257
* XXX Should just combine this with SEC_PKCS7EncoderContentCallback type
258
* and use a simpler, common name.
260
typedef void (* SEC_PKCS7DecoderContentCallback)(void *arg,
265
* Type of function passed to SEC_PKCS7Encode or SEC_PKCS7EncoderStart.
266
* This is where the encoded bytes will be "sent".
268
* XXX Should just combine this with SEC_PKCS7DecoderContentCallback type
269
* and use a simpler, common name.
271
typedef void (* SEC_PKCS7EncoderOutputCallback)(void *arg,
277
* Type of function passed to SEC_PKCS7Decode or SEC_PKCS7DecoderStart
278
* to retrieve the decryption key. This function is inteded to be
279
* used for EncryptedData content info's which do not have a key available
280
* in a certificate, etc.
282
typedef PK11SymKey * (* SEC_PKCS7GetDecryptKeyCallback)(void *arg,
283
SECAlgorithmID *algid);
286
* Type of function passed to SEC_PKCS7Decode or SEC_PKCS7DecoderStart.
287
* This function in intended to be used to verify that decrypting a
288
* particular crypto algorithm is allowed. Content types which do not
289
* require decryption will not need the callback. If the callback
290
* is not specified for content types which require decryption, the
291
* decryption will be disallowed.
293
typedef PRBool (* SEC_PKCS7DecryptionAllowedCallback)(SECAlgorithmID *algid,
294
PK11SymKey *bulkkey);
296
#endif /* _PKCS7T_H_ */