1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
10 /* PKCS Header Info */
12 /* ===> PKCS #1 -- RSA Cryptography <=== */
15 enum ltc_pkcs_1_v1_5_blocks
17 LTC_PKCS_1_EMSA = 1, /* Block type 1 (PKCS #1 v1.5 signature padding) */
18 LTC_PKCS_1_EME = 2 /* Block type 2 (PKCS #1 v1.5 encryption padding) */
21 enum ltc_pkcs_1_paddings
23 LTC_PKCS_1_V1_5 = 1, /* PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */
24 LTC_PKCS_1_OAEP = 2, /* PKCS #1 v2.0 encryption padding */
25 LTC_PKCS_1_PSS = 3, /* PKCS #1 v2.1 signature padding */
26 LTC_PKCS_1_V1_5_NA1 = 4 /* PKCS #1 v1.5 padding - No ASN.1 (\sa ltc_pkcs_1_v1_5_blocks) */
29 int pkcs_1_mgf1( int hash_idx,
30 const unsigned char *seed, unsigned long seedlen,
31 unsigned char *mask, unsigned long masklen);
33 int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out);
34 int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen);
36 /* *** v1.5 padding */
37 int pkcs_1_v1_5_encode(const unsigned char *msg,
40 unsigned long modulus_bitlen,
44 unsigned long *outlen);
46 int pkcs_1_v1_5_decode(const unsigned char *msg,
49 unsigned long modulus_bitlen,
51 unsigned long *outlen,
54 /* *** v2.1 padding */
55 int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
56 const unsigned char *lparam, unsigned long lparamlen,
57 unsigned long modulus_bitlen, prng_state *prng,
58 int prng_idx, int hash_idx,
59 unsigned char *out, unsigned long *outlen);
61 int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
62 const unsigned char *lparam, unsigned long lparamlen,
63 unsigned long modulus_bitlen, int hash_idx,
64 unsigned char *out, unsigned long *outlen,
67 int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
68 unsigned long saltlen, prng_state *prng,
69 int prng_idx, int hash_idx,
70 unsigned long modulus_bitlen,
71 unsigned char *out, unsigned long *outlen);
73 int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
74 const unsigned char *sig, unsigned long siglen,
75 unsigned long saltlen, int hash_idx,
76 unsigned long modulus_bitlen, int *res);
78 #endif /* LTC_PKCS_1 */
80 /* ===> PKCS #5 -- Password Based Cryptography <=== */
83 /* Algorithm #1 (PBKDF1) */
84 int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
85 const unsigned char *salt,
86 int iteration_count, int hash_idx,
87 unsigned char *out, unsigned long *outlen);
89 /* Algorithm #1 (PBKDF1) - OpenSSL-compatible variant for arbitrarily-long keys.
90 Compatible with EVP_BytesToKey() */
91 int pkcs_5_alg1_openssl(const unsigned char *password,
92 unsigned long password_len,
93 const unsigned char *salt,
94 int iteration_count, int hash_idx,
95 unsigned char *out, unsigned long *outlen);
97 /* Algorithm #2 (PBKDF2) */
98 int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
99 const unsigned char *salt, unsigned long salt_len,
100 int iteration_count, int hash_idx,
101 unsigned char *out, unsigned long *outlen);
103 int pkcs_5_test (void);
104 #endif /* LTC_PKCS_5 */
106 /* ref: $Format:%D$ */
107 /* git commit: $Format:%H$ */
108 /* commit time: $Format:%ai$ */