~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/pkcs7/p7local.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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/
 
6
 * 
 
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.
 
11
 * 
 
12
 * The Original Code is the Netscape security libraries.
 
13
 * 
 
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
 
17
 * Rights Reserved.
 
18
 * 
 
19
 * Contributor(s):
 
20
 * 
 
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
 
31
 * GPL.
 
32
 */
 
33
 
 
34
/*
 
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.
 
39
 *
 
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!
 
44
 *
 
45
 * $Id: p7local.h,v 1.1 2000/03/31 19:16:07 relyea%netscape.com Exp $
 
46
 */
 
47
 
 
48
#ifndef _P7LOCAL_H_
 
49
#define _P7LOCAL_H_
 
50
 
 
51
#include "secpkcs7.h"
 
52
#include "secasn1t.h"
 
53
 
 
54
extern const SEC_ASN1Template sec_PKCS7ContentInfoTemplate[];
 
55
 
 
56
/* opaque objects */
 
57
typedef struct sec_pkcs7_cipher_object sec_PKCS7CipherObject;
 
58
 
 
59
 
 
60
/************************************************************************/
 
61
SEC_BEGIN_PROTOS
 
62
 
 
63
/*
 
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...)
 
69
 */
 
70
extern SEC_PKCS7Attribute *sec_PKCS7FindAttribute (SEC_PKCS7Attribute **attrs,
 
71
                                                   SECOidTag oidtag,
 
72
                                                   PRBool only);
 
73
/*
 
74
 * Return the single attribute value, doing some sanity checking first:
 
75
 * - Multiple values are *not* expected.
 
76
 * - Empty values are *not* expected.
 
77
 */
 
78
extern SECItem *sec_PKCS7AttributeValue (SEC_PKCS7Attribute *attr);
 
79
 
 
80
/*
 
81
 * Encode a set of attributes (found in "src").
 
82
 */
 
83
extern SECItem *sec_PKCS7EncodeAttributes (PRArenaPool *poolp,
 
84
                                           SECItem *dest, void *src);
 
85
 
 
86
/*
 
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).
 
90
 */
 
91
extern SECStatus sec_PKCS7ReorderAttributes (SEC_PKCS7Attribute **attrs);
 
92
 
 
93
 
 
94
/*
 
95
 * Create a context for decrypting, based on the given key and algorithm.
 
96
 */
 
97
extern sec_PKCS7CipherObject *
 
98
sec_PKCS7CreateDecryptObject (PK11SymKey *key, SECAlgorithmID *algid);
 
99
 
 
100
/*
 
101
 * Create a context for encrypting, based on the given key and algorithm,
 
102
 * and fill in the algorithm id.
 
103
 */
 
104
extern sec_PKCS7CipherObject *
 
105
sec_PKCS7CreateEncryptObject (PRArenaPool *poolp, PK11SymKey *key,
 
106
                              SECOidTag algtag, SECAlgorithmID *algid);
 
107
 
 
108
/*
 
109
 * Destroy the given decryption or encryption object.
 
110
 */
 
111
extern void sec_PKCS7DestroyDecryptObject (sec_PKCS7CipherObject *obj);
 
112
extern void sec_PKCS7DestroyEncryptObject (sec_PKCS7CipherObject *obj);
 
113
 
 
114
/*
 
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).
 
121
 *
 
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
 
128
 * will be stored.
 
129
 */
 
130
extern unsigned int sec_PKCS7DecryptLength (sec_PKCS7CipherObject *obj,
 
131
                                            unsigned int input_len,
 
132
                                            PRBool final);
 
133
extern unsigned int sec_PKCS7EncryptLength (sec_PKCS7CipherObject *obj,
 
134
                                            unsigned int input_len,
 
135
                                            PRBool final);
 
136
 
 
137
/*
 
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.
 
143
 */ 
 
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,
 
150
                                   PRBool final);
 
151
 
 
152
/*
 
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.
 
158
 */ 
 
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,
 
165
                                   PRBool final);
 
166
 
 
167
/* return the correct kea template based on the template selector. skipjack
 
168
 * does not have the extra IV.
 
169
 */
 
170
const SEC_ASN1Template * 
 
171
sec_pkcs7_get_kea_template(SECKEATemplateSelector whichTemplate);
 
172
 
 
173
/************************************************************************/
 
174
SEC_END_PROTOS
 
175
 
 
176
#endif /* _P7LOCAL_H_ */