~ubuntu-branches/ubuntu/trusty/xulrunner/trusty

« back to all changes in this revision

Viewing changes to security/nss-fips/lib/pkcs7/p7local.h

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2008-08-25 13:04:18 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20080825130418-ck1i2ms384tzb9m0
Tags: 1.8.1.16+nobinonly-0ubuntu1
* New upstream release (taken from upstream CVS), LP: #254618.
* Fix MFSA 2008-35, MFSA 2008-34, MFSA 2008-33, MFSA 2008-32, MFSA 2008-31,
  MFSA 2008-30, MFSA 2008-29, MFSA 2008-28, MFSA 2008-27, MFSA 2008-25,
  MFSA 2008-24, MFSA 2008-23, MFSA 2008-22, MFSA 2008-21, MFSA 2008-26 also
  known as CVE-2008-2933, CVE-2008-2785, CVE-2008-2811, CVE-2008-2810,
  CVE-2008-2809, CVE-2008-2808, CVE-2008-2807, CVE-2008-2806, CVE-2008-2805,
  CVE-2008-2803, CVE-2008-2802, CVE-2008-2801, CVE-2008-2800, CVE-2008-2798.
* Drop 89_bz419350_attachment_306066 patch, merged upstream.
* Bump Standards-Version to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ***** BEGIN LICENSE BLOCK *****
 
2
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
3
 *
 
4
 * The contents of this file are subject to the Mozilla Public License Version
 
5
 * 1.1 (the "License"); you may not use this file except in compliance with
 
6
 * the License. You may obtain a copy of the License at
 
7
 * http://www.mozilla.org/MPL/
 
8
 *
 
9
 * Software distributed under the License is distributed on an "AS IS" basis,
 
10
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
11
 * for the specific language governing rights and limitations under the
 
12
 * License.
 
13
 *
 
14
 * The Original Code is the Netscape security libraries.
 
15
 *
 
16
 * The Initial Developer of the Original Code is
 
17
 * Netscape Communications Corporation.
 
18
 * Portions created by the Initial Developer are Copyright (C) 1994-2000
 
19
 * the Initial Developer. All Rights Reserved.
 
20
 *
 
21
 * Contributor(s):
 
22
 *
 
23
 * Alternatively, the contents of this file may be used under the terms of
 
24
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
25
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
26
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
27
 * of those above. If you wish to allow use of your version of this file only
 
28
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
29
 * use your version of this file under the terms of the MPL, indicate your
 
30
 * decision by deleting the provisions above and replace them with the notice
 
31
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
32
 * the provisions above, a recipient may use your version of this file under
 
33
 * the terms of any one of the MPL, the GPL or the LGPL.
 
34
 *
 
35
 * ***** END LICENSE BLOCK ***** */
 
36
 
 
37
/*
 
38
 * Support routines for PKCS7 implementation, none of which are exported.
 
39
 * This file should only contain things that are needed by both the
 
40
 * encoding/creation side *and* the decoding/decryption side.  Anything
 
41
 * else should just be static routines in the appropriate file.
 
42
 *
 
43
 * Do not export this file!  If something in here is really needed outside
 
44
 * of pkcs7 code, first try to add a PKCS7 interface which will do it for
 
45
 * you.  If that has a problem, then just move out what you need, changing
 
46
 * its name as appropriate!
 
47
 *
 
48
 * $Id: p7local.h,v 1.2 2004/04/25 15:03:13 gerv%gerv.net Exp $
 
49
 */
 
50
 
 
51
#ifndef _P7LOCAL_H_
 
52
#define _P7LOCAL_H_
 
53
 
 
54
#include "secpkcs7.h"
 
55
#include "secasn1t.h"
 
56
 
 
57
extern const SEC_ASN1Template sec_PKCS7ContentInfoTemplate[];
 
58
 
 
59
/* opaque objects */
 
60
typedef struct sec_pkcs7_cipher_object sec_PKCS7CipherObject;
 
61
 
 
62
 
 
63
/************************************************************************/
 
64
SEC_BEGIN_PROTOS
 
65
 
 
66
/*
 
67
 * Look through a set of attributes and find one that matches the
 
68
 * specified object ID.  If "only" is true, then make sure that
 
69
 * there is not more than one attribute of the same type.  Otherwise,
 
70
 * just return the first one found. (XXX Does anybody really want
 
71
 * that first-found behavior?  It was like that when I found it...)
 
72
 */
 
73
extern SEC_PKCS7Attribute *sec_PKCS7FindAttribute (SEC_PKCS7Attribute **attrs,
 
74
                                                   SECOidTag oidtag,
 
75
                                                   PRBool only);
 
76
/*
 
77
 * Return the single attribute value, doing some sanity checking first:
 
78
 * - Multiple values are *not* expected.
 
79
 * - Empty values are *not* expected.
 
80
 */
 
81
extern SECItem *sec_PKCS7AttributeValue (SEC_PKCS7Attribute *attr);
 
82
 
 
83
/*
 
84
 * Encode a set of attributes (found in "src").
 
85
 */
 
86
extern SECItem *sec_PKCS7EncodeAttributes (PRArenaPool *poolp,
 
87
                                           SECItem *dest, void *src);
 
88
 
 
89
/*
 
90
 * Make sure that the order of the attributes guarantees valid DER
 
91
 * (which must be in lexigraphically ascending order for a SET OF);
 
92
 * if reordering is necessary it will be done in place (in attrs).
 
93
 */
 
94
extern SECStatus sec_PKCS7ReorderAttributes (SEC_PKCS7Attribute **attrs);
 
95
 
 
96
 
 
97
/*
 
98
 * Create a context for decrypting, based on the given key and algorithm.
 
99
 */
 
100
extern sec_PKCS7CipherObject *
 
101
sec_PKCS7CreateDecryptObject (PK11SymKey *key, SECAlgorithmID *algid);
 
102
 
 
103
/*
 
104
 * Create a context for encrypting, based on the given key and algorithm,
 
105
 * and fill in the algorithm id.
 
106
 */
 
107
extern sec_PKCS7CipherObject *
 
108
sec_PKCS7CreateEncryptObject (PRArenaPool *poolp, PK11SymKey *key,
 
109
                              SECOidTag algtag, SECAlgorithmID *algid);
 
110
 
 
111
/*
 
112
 * Destroy the given decryption or encryption object.
 
113
 */
 
114
extern void sec_PKCS7DestroyDecryptObject (sec_PKCS7CipherObject *obj);
 
115
extern void sec_PKCS7DestroyEncryptObject (sec_PKCS7CipherObject *obj);
 
116
 
 
117
/*
 
118
 * What will be the output length of the next call to encrypt/decrypt?
 
119
 * Result can be used to perform memory allocations.  Note that the amount
 
120
 * is exactly accurate only when not doing a block cipher or when final
 
121
 * is false, otherwise it is an upper bound on the amount because until
 
122
 * we see the data we do not know how many padding bytes there are
 
123
 * (always between 1 and the cipher block size).
 
124
 *
 
125
 * Note that this can return zero, which does not mean that the cipher
 
126
 * operation can be skipped!  (It simply means that there are not enough
 
127
 * bytes to make up an entire block; the bytes will be reserved until
 
128
 * there are enough to encrypt/decrypt at least one block.)  However,
 
129
 * if zero is returned it *does* mean that no output buffer need be
 
130
 * passed in to the subsequent cipher operation, as no output bytes
 
131
 * will be stored.
 
132
 */
 
133
extern unsigned int sec_PKCS7DecryptLength (sec_PKCS7CipherObject *obj,
 
134
                                            unsigned int input_len,
 
135
                                            PRBool final);
 
136
extern unsigned int sec_PKCS7EncryptLength (sec_PKCS7CipherObject *obj,
 
137
                                            unsigned int input_len,
 
138
                                            PRBool final);
 
139
 
 
140
/*
 
141
 * Decrypt a given length of input buffer (starting at "input" and
 
142
 * containing "input_len" bytes), placing the decrypted bytes in
 
143
 * "output" and storing the output length in "*output_len_p".
 
144
 * "obj" is the return value from sec_PKCS7CreateDecryptObject.
 
145
 * When "final" is true, this is the last of the data to be decrypted.
 
146
 */ 
 
147
extern SECStatus sec_PKCS7Decrypt (sec_PKCS7CipherObject *obj,
 
148
                                   unsigned char *output,
 
149
                                   unsigned int *output_len_p,
 
150
                                   unsigned int max_output_len,
 
151
                                   const unsigned char *input,
 
152
                                   unsigned int input_len,
 
153
                                   PRBool final);
 
154
 
 
155
/*
 
156
 * Encrypt a given length of input buffer (starting at "input" and
 
157
 * containing "input_len" bytes), placing the encrypted bytes in
 
158
 * "output" and storing the output length in "*output_len_p".
 
159
 * "obj" is the return value from sec_PKCS7CreateEncryptObject.
 
160
 * When "final" is true, this is the last of the data to be encrypted.
 
161
 */ 
 
162
extern SECStatus sec_PKCS7Encrypt (sec_PKCS7CipherObject *obj,
 
163
                                   unsigned char *output,
 
164
                                   unsigned int *output_len_p,
 
165
                                   unsigned int max_output_len,
 
166
                                   const unsigned char *input,
 
167
                                   unsigned int input_len,
 
168
                                   PRBool final);
 
169
 
 
170
/* return the correct kea template based on the template selector. skipjack
 
171
 * does not have the extra IV.
 
172
 */
 
173
const SEC_ASN1Template * 
 
174
sec_pkcs7_get_kea_template(SECKEATemplateSelector whichTemplate);
 
175
 
 
176
/************************************************************************/
 
177
SEC_END_PROTOS
 
178
 
 
179
#endif /* _P7LOCAL_H_ */