TrustCore SDK NanoCert API reference  version 7.0
pkcs5.h
Go to the documentation of this file.
1 /*
2  * pkcs5.h
3  *
4  * PKCS #5 Factory Header
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  */
18 #ifndef __PPKCS5_HEADER__
19 #define __PPKCS5_HEADER__
20 
21 #if defined(__ENABLE_MOCANA_CRYPTO_INTERFACE__)
22 #include "../crypto_interface/crypto_interface_pkcs5_priv.h"
23 #endif
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 enum hashFunc
30 {
31  md2Encryption = 2,
32  md4Encryption = 3,
33  md5Encryption = 4,
34  sha1Encryption = 5,
35  sha256Encryption = 11,
36  sha384Encryption = 12,
37  sha512Encryption = 13,
38  sha224Encryption = 14
39 };
40 
41 enum encFunc
42 {
43  nilEncryption = 0,
44  tdesEncryption = 1,
45  twoKeyTdesEncryption = 2,
46  desEncryption = 3,
47  rc4Encryption = 4,
48  rc2Encryption = 5,
49  rc2EkbEncryption = 6,
50  bfEncryption = 7,
51  aesEncryption = 8,
52  aesCtrEncryption = 9
53 };
54 
55 /*------------------------------------------------------------------*/
56 
57 #ifdef __ENABLE_MOCANA_PKCS5__
58 
59 #define MOC_MIN_800_132_SALT_LEN 16
60 #define MOC_MIN_800_132_KEY_LEN 14
61 #define MOC_MIN_800_132_ITERATION_COUNT 1000
62 
66 MOC_EXTERN const ubyte pkcs5_root_OID[]; /* 1.2.840.113549.1.5 */
67 MOC_EXTERN const ubyte pkcs5_PBKDF2_OID[]; /* 1.2.840.113549.1.5.12 */
68 MOC_EXTERN const ubyte pkcs5_PBES2_OID[]; /* 1.2.840.113549.1.5.13 */
133 MOC_EXTERN MSTATUS PKCS5_CreateKey_PBKDF1(MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pSalt, ubyte4 saltLen,
134  ubyte4 iterationCount, enum hashFunc hashingFunction,
135  const ubyte *pPassword, ubyte4 passwordLen,
136  ubyte4 dkLen, ubyte *pRetDerivedKey);
137 
204 MOC_EXTERN MSTATUS PKCS5_CreateKey_PBKDF2(MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pSalt, ubyte4 saltLen,
205  ubyte4 iterationCount, ubyte rsaAlgoId,
206  const ubyte *pPassword, ubyte4 passwordLen,
207  ubyte4 dkLen, ubyte *pRetDerivedKey);
208 
238 MOC_EXTERN MSTATUS PKCS5_decrypt( MOC_SYM(hwAccelDescr hwAccelCtx)
239  ubyte subType, CStream cs,
240  ASN1_ITEMPTR pPBEParam, ASN1_ITEMPTR pEncrypted,
241  const ubyte* password, sbyte4 passwordLen,
242  ubyte** privateKeyInfo,
243  sbyte4* privateKeyInfoLen);
244 
272 MOC_EXTERN MSTATUS PKCS5_decryptV2( MOC_SYM(hwAccelDescr hwAccelCtx)
273  const ubyte *pAsn1PBE, ubyte4 pbeLen,
274  ubyte *pData, ubyte4 dataLen,
275  const ubyte *pPassword, sbyte4 passwordLen,
276  ubyte *pPrivateKeyInfo, ubyte4 privKeyInfoBufferLen,
277  ubyte4 *pPrivKeyInfoLen);
278 
326 MOC_EXTERN MSTATUS PKCS5_encryptV1( MOC_SYM(hwAccelDescr hwAccelCtx)
327  ubyte pkcs5SubType,
328  const ubyte* password, ubyte4 passwordLen,
329  const ubyte* salt, ubyte4 saltLen,
330  ubyte4 iterCount,
331  ubyte* plainText, ubyte4 ptLen);
332 
402 MOC_EXTERN MSTATUS PKCS5_encryptV2( MOC_SYM(hwAccelDescr hwAccelCtx)
403  const BulkEncryptionAlgo* pAlgo, ubyte rsaAlgoId,
404  ubyte4 keyLength, sbyte4 effectiveKeyBits,
405  const ubyte* password, ubyte4 passwordLen,
406  const ubyte* salt, ubyte4 saltLen,
407  ubyte4 iterCount, const ubyte* iv,
408  ubyte* plainText, ubyte4 ptLen);
409 
410 
469 MOC_EXTERN MSTATUS PKCS5_encryptV2_Alt(
470  MOC_SYM(hwAccelDescr hwAccelCtx)
471  ubyte encryptionAlgo, ubyte digestAlg,
472  ubyte4 keyLength, sbyte4 effectiveKeyBits,
473  const ubyte *pPassword, ubyte4 passwordLen,
474  const ubyte *pSalt, ubyte4 saltLen,
475  ubyte4 iterCount, const ubyte *pIv,
476  ubyte *pPlainText, ubyte4 ptLen,
477  ubyte *pCipherText, ubyte4 ctBufferLen,
478  ubyte4 *pCtLen);
479 
480 #endif
481 
482 #ifdef __cplusplus
483 }
484 #endif
485 
486 
487 #endif /* __PPKCS5_HEADER__ */
488 
MOC_EXTERN MSTATUS PKCS5_decryptV2(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte *pAsn1PBE, ubyte4 pbeLen, ubyte *pData, ubyte4 dataLen, const ubyte *pPassword, sbyte4 passwordLen, ubyte *pPrivateKeyInfo, ubyte4 privKeyInfoBufferLen, ubyte4 *pPrivKeyInfoLen)
Decrypt data that is PKCS5 V2 encrypted and in a raw buffer form.
MOC_EXTERN MSTATUS PKCS5_encryptV1(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte pkcs5SubType, const ubyte *password, ubyte4 passwordLen, const ubyte *salt, ubyte4 saltLen, ubyte4 iterCount, ubyte *plainText, ubyte4 ptLen)
Encrypt a plaintext buffer with PBES1 encryption as defined in RFC 2898.
MOC_EXTERN MSTATUS PKCS5_encryptV2(MOC_SYM(hwAccelDescr hwAccelCtx) const BulkEncryptionAlgo *pAlgo, ubyte rsaAlgoId, ubyte4 keyLength, sbyte4 effectiveKeyBits, const ubyte *password, ubyte4 passwordLen, const ubyte *salt, ubyte4 saltLen, ubyte4 iterCount, const ubyte *iv, ubyte *plainText, ubyte4 ptLen)
Encrypt a plaintext buffer with PBES2 encryption as defined in RFC 2898.
MOC_EXTERN MSTATUS PKCS5_decrypt(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte subType, CStream cs, ASN1_ITEMPTR pPBEParam, ASN1_ITEMPTR pEncrypted, const ubyte *password, sbyte4 passwordLen, ubyte **privateKeyInfo, sbyte4 *privateKeyInfoLen)
Decrypt data that is PKCS5 encrypted.
MOC_EXTERN MSTATUS PKCS5_CreateKey_PBKDF1(MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pSalt, ubyte4 saltLen, ubyte4 iterationCount, enum hashFunc hashingFunction, const ubyte *pPassword, ubyte4 passwordLen, ubyte4 dkLen, ubyte *pRetDerivedKey)
Generate a key based on the RFC 2898 PBKDF1 key generation method.
MOC_EXTERN MSTATUS PKCS5_CreateKey_PBKDF2(MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pSalt, ubyte4 saltLen, ubyte4 iterationCount, ubyte rsaAlgoId, const ubyte *pPassword, ubyte4 passwordLen, ubyte4 dkLen, ubyte *pRetDerivedKey)
Generate a key based on the RFC 2898 PBKDF2 key generation method.
MOC_EXTERN MSTATUS PKCS5_encryptV2_Alt(ubyte encryptionAlgo, ubyte digestAlg, ubyte4 keyLength, sbyte4 effectiveKeyBits, const ubyte *pPassword, ubyte4 passwordLen, const ubyte *pSalt, ubyte4 saltLen, ubyte4 iterCount, const ubyte *pIv, ubyte *pPlainText, ubyte4 ptLen, ubyte *pCipherText, ubyte4 ctBufferLen, ubyte4 *pCtLen)
Encrypt a plaintext buffer with PBES2 encryption as defined in RFC 2898.
Structure to hold function pointers to symmetric key cipher methods.
Definition: crypto.h:48