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
* Support routines for PKCS7 implementation, none of which are exported.
36
* This file should only contain things that are needed by both the
37
* encoding/creation side *and* the decoding/decryption side. Anything
38
* else should just be static routines in the appropriate file.
40
* Do not export this file! If something in here is really needed outside
41
* of pkcs7 code, first try to add a PKCS7 interface which will do it for
42
* you. If that has a problem, then just move out what you need, changing
43
* its name as appropriate!
45
* $Id: p7local.h,v 1.1 2000/03/31 19:16:07 relyea%netscape.com Exp $
54
extern const SEC_ASN1Template sec_PKCS7ContentInfoTemplate[];
57
typedef struct sec_pkcs7_cipher_object sec_PKCS7CipherObject;
60
/************************************************************************/
64
* Look through a set of attributes and find one that matches the
65
* specified object ID. If "only" is true, then make sure that
66
* there is not more than one attribute of the same type. Otherwise,
67
* just return the first one found. (XXX Does anybody really want
68
* that first-found behavior? It was like that when I found it...)
70
extern SEC_PKCS7Attribute *sec_PKCS7FindAttribute (SEC_PKCS7Attribute **attrs,
74
* Return the single attribute value, doing some sanity checking first:
75
* - Multiple values are *not* expected.
76
* - Empty values are *not* expected.
78
extern SECItem *sec_PKCS7AttributeValue (SEC_PKCS7Attribute *attr);
81
* Encode a set of attributes (found in "src").
83
extern SECItem *sec_PKCS7EncodeAttributes (PRArenaPool *poolp,
84
SECItem *dest, void *src);
87
* Make sure that the order of the attributes guarantees valid DER
88
* (which must be in lexigraphically ascending order for a SET OF);
89
* if reordering is necessary it will be done in place (in attrs).
91
extern SECStatus sec_PKCS7ReorderAttributes (SEC_PKCS7Attribute **attrs);
95
* Create a context for decrypting, based on the given key and algorithm.
97
extern sec_PKCS7CipherObject *
98
sec_PKCS7CreateDecryptObject (PK11SymKey *key, SECAlgorithmID *algid);
101
* Create a context for encrypting, based on the given key and algorithm,
102
* and fill in the algorithm id.
104
extern sec_PKCS7CipherObject *
105
sec_PKCS7CreateEncryptObject (PRArenaPool *poolp, PK11SymKey *key,
106
SECOidTag algtag, SECAlgorithmID *algid);
109
* Destroy the given decryption or encryption object.
111
extern void sec_PKCS7DestroyDecryptObject (sec_PKCS7CipherObject *obj);
112
extern void sec_PKCS7DestroyEncryptObject (sec_PKCS7CipherObject *obj);
115
* What will be the output length of the next call to encrypt/decrypt?
116
* Result can be used to perform memory allocations. Note that the amount
117
* is exactly accurate only when not doing a block cipher or when final
118
* is false, otherwise it is an upper bound on the amount because until
119
* we see the data we do not know how many padding bytes there are
120
* (always between 1 and the cipher block size).
122
* Note that this can return zero, which does not mean that the cipher
123
* operation can be skipped! (It simply means that there are not enough
124
* bytes to make up an entire block; the bytes will be reserved until
125
* there are enough to encrypt/decrypt at least one block.) However,
126
* if zero is returned it *does* mean that no output buffer need be
127
* passed in to the subsequent cipher operation, as no output bytes
130
extern unsigned int sec_PKCS7DecryptLength (sec_PKCS7CipherObject *obj,
131
unsigned int input_len,
133
extern unsigned int sec_PKCS7EncryptLength (sec_PKCS7CipherObject *obj,
134
unsigned int input_len,
138
* Decrypt a given length of input buffer (starting at "input" and
139
* containing "input_len" bytes), placing the decrypted bytes in
140
* "output" and storing the output length in "*output_len_p".
141
* "obj" is the return value from sec_PKCS7CreateDecryptObject.
142
* When "final" is true, this is the last of the data to be decrypted.
144
extern SECStatus sec_PKCS7Decrypt (sec_PKCS7CipherObject *obj,
145
unsigned char *output,
146
unsigned int *output_len_p,
147
unsigned int max_output_len,
148
const unsigned char *input,
149
unsigned int input_len,
153
* Encrypt a given length of input buffer (starting at "input" and
154
* containing "input_len" bytes), placing the encrypted bytes in
155
* "output" and storing the output length in "*output_len_p".
156
* "obj" is the return value from sec_PKCS7CreateEncryptObject.
157
* When "final" is true, this is the last of the data to be encrypted.
159
extern SECStatus sec_PKCS7Encrypt (sec_PKCS7CipherObject *obj,
160
unsigned char *output,
161
unsigned int *output_len_p,
162
unsigned int max_output_len,
163
const unsigned char *input,
164
unsigned int input_len,
167
/* return the correct kea template based on the template selector. skipjack
168
* does not have the extra IV.
170
const SEC_ASN1Template *
171
sec_pkcs7_get_kea_template(SECKEATemplateSelector whichTemplate);
173
/************************************************************************/
176
#endif /* _P7LOCAL_H_ */