]> pd.if.org Git - zpackage/blob - libtomcrypt/src/headers/tomcrypt_pkcs.h
commit files needed for zpm-fetchurl
[zpackage] / libtomcrypt / src / headers / tomcrypt_pkcs.h
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  */
9
10 /* PKCS Header Info */
11
12 /* ===> PKCS #1 -- RSA Cryptography <=== */
13 #ifdef LTC_PKCS_1
14
15 enum ltc_pkcs_1_v1_5_blocks
16 {
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) */
19 };
20
21 enum ltc_pkcs_1_paddings
22 {
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) */
27 };
28
29 int pkcs_1_mgf1(      int            hash_idx,
30                 const unsigned char *seed, unsigned long seedlen,
31                       unsigned char *mask, unsigned long masklen);
32
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);
35
36 /* *** v1.5 padding */
37 int pkcs_1_v1_5_encode(const unsigned char *msg,
38                              unsigned long  msglen,
39                              int            block_type,
40                              unsigned long  modulus_bitlen,
41                                 prng_state *prng,
42                                        int  prng_idx,
43                              unsigned char *out,
44                              unsigned long *outlen);
45
46 int pkcs_1_v1_5_decode(const unsigned char *msg,
47                              unsigned long  msglen,
48                                        int  block_type,
49                              unsigned long  modulus_bitlen,
50                              unsigned char *out,
51                              unsigned long *outlen,
52                                        int *is_valid);
53
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);
60
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,
65                              int           *res);
66
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);
72
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);
77
78 #endif /* LTC_PKCS_1 */
79
80 /* ===> PKCS #5 -- Password Based Cryptography <=== */
81 #ifdef LTC_PKCS_5
82
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);
88
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);
96
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);
102
103 int pkcs_5_test (void);
104 #endif  /* LTC_PKCS_5 */
105
106 /* ref:         $Format:%D$ */
107 /* git commit:  $Format:%H$ */
108 /* commit time: $Format:%ai$ */