|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 #ifndef _SECPKCS5_H_ |
|
5 #define _SECPKCS5_H_ |
|
6 #include "seccomon.h" |
|
7 #include "secmodt.h" |
|
8 |
|
9 /* used for V2 PKCS 12 Draft Spec */ |
|
10 typedef enum { |
|
11 pbeBitGenIDNull = 0, |
|
12 pbeBitGenCipherKey = 0x01, |
|
13 pbeBitGenCipherIV = 0x02, |
|
14 pbeBitGenIntegrityKey = 0x03 |
|
15 } PBEBitGenID; |
|
16 |
|
17 typedef struct PBEBitGenContextStr PBEBitGenContext; |
|
18 |
|
19 SEC_BEGIN_PROTOS |
|
20 |
|
21 /* private */ |
|
22 SECAlgorithmID * |
|
23 sec_pkcs5CreateAlgorithmID(SECOidTag algorithm, SECOidTag cipherAlgorithm, |
|
24 SECOidTag prfAlg, SECOidTag *pPbeAlgorithm, |
|
25 int keyLengh, SECItem *salt, int iteration); |
|
26 |
|
27 /* Get the initialization vector. The password is passed in, hashing |
|
28 * is performed, and the initialization vector is returned. |
|
29 * algid is a pointer to a PBE algorithm ID |
|
30 * pwitem is the password |
|
31 * If an error occurs or the algorithm id is not a PBE algrithm, |
|
32 * NULL is returned. Otherwise, the iv is returned in a secitem. |
|
33 */ |
|
34 SECItem * |
|
35 SEC_PKCS5GetIV(SECAlgorithmID *algid, SECItem *pwitem, PRBool faulty3DES); |
|
36 |
|
37 SECOidTag SEC_PKCS5GetCryptoAlgorithm(SECAlgorithmID *algid); |
|
38 PRBool SEC_PKCS5IsAlgorithmPBEAlg(SECAlgorithmID *algid); |
|
39 PRBool SEC_PKCS5IsAlgorithmPBEAlgTag(SECOidTag algTag); |
|
40 SECOidTag SEC_PKCS5GetPBEAlgorithm(SECOidTag algTag, int keyLen); |
|
41 int SEC_PKCS5GetKeyLength(SECAlgorithmID *algid); |
|
42 |
|
43 /********************************************************************** |
|
44 * Deprecated PBE functions. Use the PBE functions in pk11func.h |
|
45 * instead. |
|
46 **********************************************************************/ |
|
47 |
|
48 PBEBitGenContext * |
|
49 PBE_CreateContext(SECOidTag hashAlgorithm, PBEBitGenID bitGenPurpose, |
|
50 SECItem *pwitem, SECItem *salt, unsigned int bitsNeeded, |
|
51 unsigned int iterations); |
|
52 |
|
53 void |
|
54 PBE_DestroyContext(PBEBitGenContext *context); |
|
55 |
|
56 |
|
57 SECItem * |
|
58 PBE_GenerateBits(PBEBitGenContext *context); |
|
59 |
|
60 SEC_END_PROTOS |
|
61 |
|
62 #endif /* _SECPKS5_H_ */ |