secpkcs5.h (2551B)
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 SECOidTag SEC_PKCS5GetHashAlgorithm(SECAlgorithmID *algid); 39 40 /* the next 2 maps a PKCS #12 PBE or PKCS #5v1 PBE oid to it's encryption algorithm 41 * and hash algorithms. 42 * All other values map to SEC_OID_UNKNOWN. In most cases you want 43 * to use SEC_PKCS5GetCryptoAlgorithm() with a full SECAlgorithmID which 44 * can handle PKCS #5v2 */ 45 SECOidTag SEC_PKCS5GetCryptoFromAlgTag(SECOidTag algTag); 46 SECOidTag SEC_PKCS5GetHashFromAlgTag(SECOidTag algTag); 47 48 PRBool SEC_PKCS5IsAlgorithmPBEAlg(SECAlgorithmID *algid); 49 PRBool SEC_PKCS5IsAlgorithmPBEAlgTag(SECOidTag algTag); 50 SECOidTag SEC_PKCS5GetPBEAlgorithm(SECOidTag algTag, int keyLen); 51 int SEC_PKCS5GetKeyLength(SECAlgorithmID *algid); 52 53 /********************************************************************** 54 * Deprecated PBE functions. Use the PBE functions in pk11func.h 55 * instead. 56 **********************************************************************/ 57 58 PBEBitGenContext * 59 PBE_CreateContext(SECOidTag hashAlgorithm, PBEBitGenID bitGenPurpose, 60 SECItem *pwitem, SECItem *salt, unsigned int bitsNeeded, 61 unsigned int iterations); 62 63 void 64 PBE_DestroyContext(PBEBitGenContext *context); 65 66 SECItem * 67 PBE_GenerateBits(PBEBitGenContext *context); 68 69 SEC_END_PROTOS 70 71 #endif /* _SECPKS5_H_ */