comparison libtomcrypt/src/headers/tomcrypt_pkcs.h @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
comparison
equal deleted inserted replaced
1470:8bba51a55704 1471:6dba84798cd5
1 /* LTC_PKCS Header Info */ 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
2 *
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
5 *
6 * The library is free for all purposes without any express
7 * guarantee it works.
8 */
2 9
3 /* ===> LTC_PKCS #1 -- RSA Cryptography <=== */ 10 /* PKCS Header Info */
11
12 /* ===> PKCS #1 -- RSA Cryptography <=== */
4 #ifdef LTC_PKCS_1 13 #ifdef LTC_PKCS_1
5 14
6 enum ltc_pkcs_1_v1_5_blocks 15 enum ltc_pkcs_1_v1_5_blocks
7 { 16 {
8 LTC_LTC_PKCS_1_EMSA = 1, /* Block type 1 (LTC_PKCS #1 v1.5 signature padding) */ 17 LTC_PKCS_1_EMSA = 1, /* Block type 1 (PKCS #1 v1.5 signature padding) */
9 LTC_LTC_PKCS_1_EME = 2 /* Block type 2 (LTC_PKCS #1 v1.5 encryption padding) */ 18 LTC_PKCS_1_EME = 2 /* Block type 2 (PKCS #1 v1.5 encryption padding) */
10 }; 19 };
11 20
12 enum ltc_pkcs_1_paddings 21 enum ltc_pkcs_1_paddings
13 { 22 {
14 LTC_LTC_PKCS_1_V1_5 = 1, /* LTC_PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */ 23 LTC_PKCS_1_V1_5 = 1, /* PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */
15 LTC_LTC_PKCS_1_OAEP = 2, /* LTC_PKCS #1 v2.0 encryption padding */ 24 LTC_PKCS_1_OAEP = 2, /* PKCS #1 v2.0 encryption padding */
16 LTC_LTC_PKCS_1_PSS = 3 /* LTC_PKCS #1 v2.1 signature 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) */
17 }; 27 };
18 28
19 int pkcs_1_mgf1( int hash_idx, 29 int pkcs_1_mgf1( int hash_idx,
20 const unsigned char *seed, unsigned long seedlen, 30 const unsigned char *seed, unsigned long seedlen,
21 unsigned char *mask, unsigned long masklen); 31 unsigned char *mask, unsigned long masklen);
22 32
23 int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out); 33 int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out);
24 int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen); 34 int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen);
25 35
26 /* *** v1.5 padding */ 36 /* *** v1.5 padding */
27 int pkcs_1_v1_5_encode(const unsigned char *msg, 37 int pkcs_1_v1_5_encode(const unsigned char *msg,
28 unsigned long msglen, 38 unsigned long msglen,
29 int block_type, 39 int block_type,
30 unsigned long modulus_bitlen, 40 unsigned long modulus_bitlen,
31 prng_state *prng, 41 prng_state *prng,
32 int prng_idx, 42 int prng_idx,
33 unsigned char *out, 43 unsigned char *out,
34 unsigned long *outlen); 44 unsigned long *outlen);
35 45
36 int pkcs_1_v1_5_decode(const unsigned char *msg, 46 int pkcs_1_v1_5_decode(const unsigned char *msg,
37 unsigned long msglen, 47 unsigned long msglen,
38 int block_type, 48 int block_type,
39 unsigned long modulus_bitlen, 49 unsigned long modulus_bitlen,
40 unsigned char *out, 50 unsigned char *out,
41 unsigned long *outlen, 51 unsigned long *outlen,
42 int *is_valid); 52 int *is_valid);
43 53
44 /* *** v2.1 padding */ 54 /* *** v2.1 padding */
45 int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen, 55 int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
53 unsigned long modulus_bitlen, int hash_idx, 63 unsigned long modulus_bitlen, int hash_idx,
54 unsigned char *out, unsigned long *outlen, 64 unsigned char *out, unsigned long *outlen,
55 int *res); 65 int *res);
56 66
57 int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen, 67 int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
58 unsigned long saltlen, prng_state *prng, 68 unsigned long saltlen, prng_state *prng,
59 int prng_idx, int hash_idx, 69 int prng_idx, int hash_idx,
60 unsigned long modulus_bitlen, 70 unsigned long modulus_bitlen,
61 unsigned char *out, unsigned long *outlen); 71 unsigned char *out, unsigned long *outlen);
62 72
63 int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen, 73 int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
65 unsigned long saltlen, int hash_idx, 75 unsigned long saltlen, int hash_idx,
66 unsigned long modulus_bitlen, int *res); 76 unsigned long modulus_bitlen, int *res);
67 77
68 #endif /* LTC_PKCS_1 */ 78 #endif /* LTC_PKCS_1 */
69 79
70 /* ===> LTC_PKCS #5 -- Password Based Cryptography <=== */ 80 /* ===> PKCS #5 -- Password Based Cryptography <=== */
71 #ifdef LTC_PKCS_5 81 #ifdef LTC_PKCS_5
72 82
73 /* Algorithm #1 (old) */ 83 /* Algorithm #1 (PBKDF1) */
74 int pkcs_5_alg1(const unsigned char *password, unsigned long password_len, 84 int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
75 const unsigned char *salt, 85 const unsigned char *salt,
76 int iteration_count, int hash_idx, 86 int iteration_count, int hash_idx,
77 unsigned char *out, unsigned long *outlen); 87 unsigned char *out, unsigned long *outlen);
78 88
79 /* Algorithm #2 (new) */ 89 /* Algorithm #1 (PBKDF1) - OpenSSL-compatible variant for arbitrarily-long keys.
80 int pkcs_5_alg2(const unsigned char *password, unsigned long password_len, 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);
96
97 /* Algorithm #2 (PBKDF2) */
98 int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
81 const unsigned char *salt, unsigned long salt_len, 99 const unsigned char *salt, unsigned long salt_len,
82 int iteration_count, int hash_idx, 100 int iteration_count, int hash_idx,
83 unsigned char *out, unsigned long *outlen); 101 unsigned char *out, unsigned long *outlen);
84 102
103 int pkcs_5_test (void);
85 #endif /* LTC_PKCS_5 */ 104 #endif /* LTC_PKCS_5 */
86 105
87 /* $Source$ */ 106 /* ref: $Format:%D$ */
88 /* $Revision$ */ 107 /* git commit: $Format:%H$ */
89 /* $Date$ */ 108 /* commit time: $Format:%ai$ */