tomcrypt/src/headers/tomcrypt_pkcs.h

99 lines
4.2 KiB
C
Raw Normal View History

2014-01-03 15:16:59 +01:00
/* PKCS Header Info */
2004-05-12 20:42:16 +00:00
2014-01-03 15:16:59 +01:00
/* ===> PKCS #1 -- RSA Cryptography <=== */
2007-07-20 17:48:02 +00:00
#ifdef LTC_PKCS_1
2004-05-12 20:42:16 +00:00
2006-11-17 14:21:24 +00:00
enum ltc_pkcs_1_v1_5_blocks
{
2014-01-03 15:16:59 +01:00
LTC_PKCS_1_EMSA = 1, /* Block type 1 (PKCS #1 v1.5 signature padding) */
LTC_PKCS_1_EME = 2 /* Block type 2 (PKCS #1 v1.5 encryption padding) */
2006-11-17 14:21:24 +00:00
};
enum ltc_pkcs_1_paddings
{
2014-01-03 15:16:59 +01:00
LTC_PKCS_1_V1_5 = 1, /* PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */
LTC_PKCS_1_OAEP = 2, /* PKCS #1 v2.0 encryption padding */
LTC_PKCS_1_PSS = 3 /* PKCS #1 v2.1 signature padding */
2006-11-17 14:21:24 +00:00
};
2005-11-18 05:15:37 +00:00
int pkcs_1_mgf1( int hash_idx,
const unsigned char *seed, unsigned long seedlen,
2004-05-12 20:42:16 +00:00
unsigned char *mask, unsigned long masklen);
2005-08-01 16:36:47 +00:00
int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out);
int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen);
2004-05-31 02:36:47 +00:00
2006-11-17 14:21:24 +00:00
/* *** v1.5 padding */
2012-07-26 14:43:15 +02:00
int pkcs_1_v1_5_encode(const unsigned char *msg,
2006-11-17 14:21:24 +00:00
unsigned long msglen,
int block_type,
unsigned long modulus_bitlen,
2012-07-26 14:43:15 +02:00
prng_state *prng,
2006-11-17 14:21:24 +00:00
int prng_idx,
2012-07-26 14:43:15 +02:00
unsigned char *out,
2006-11-17 14:21:24 +00:00
unsigned long *outlen);
2012-07-26 14:43:15 +02:00
int pkcs_1_v1_5_decode(const unsigned char *msg,
2006-11-17 14:21:24 +00:00
unsigned long msglen,
int block_type,
unsigned long modulus_bitlen,
2012-07-26 14:43:15 +02:00
unsigned char *out,
2006-11-17 14:21:24 +00:00
unsigned long *outlen,
int *is_valid);
2005-06-09 00:08:13 +00:00
/* *** v2.1 padding */
2004-05-12 20:42:16 +00:00
int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
const unsigned char *lparam, unsigned long lparamlen,
2004-05-31 02:36:47 +00:00
unsigned long modulus_bitlen, prng_state *prng,
int prng_idx, int hash_idx,
2004-05-12 20:42:16 +00:00
unsigned char *out, unsigned long *outlen);
int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
const unsigned char *lparam, unsigned long lparamlen,
unsigned long modulus_bitlen, int hash_idx,
2004-05-31 02:36:47 +00:00
unsigned char *out, unsigned long *outlen,
int *res);
2004-05-12 20:42:16 +00:00
int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
2012-07-26 14:43:15 +02:00
unsigned long saltlen, prng_state *prng,
2004-05-31 02:36:47 +00:00
int prng_idx, int hash_idx,
2004-05-12 20:42:16 +00:00
unsigned long modulus_bitlen,
unsigned char *out, unsigned long *outlen);
int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
const unsigned char *sig, unsigned long siglen,
unsigned long saltlen, int hash_idx,
unsigned long modulus_bitlen, int *res);
2007-07-20 17:48:02 +00:00
#endif /* LTC_PKCS_1 */
2004-05-12 20:42:16 +00:00
2014-01-03 15:16:59 +01:00
/* ===> PKCS #5 -- Password Based Cryptography <=== */
2007-07-20 17:48:02 +00:00
#ifdef LTC_PKCS_5
2004-05-12 20:42:16 +00:00
/* Algorithm #1 (old) */
2012-07-26 14:43:15 +02:00
int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
const unsigned char *salt,
2004-05-12 20:42:16 +00:00
int iteration_count, int hash_idx,
unsigned char *out, unsigned long *outlen);
/* Algorithm #1 - OpenSSL-compatible variant for arbitrarily-long keys.
Compatible with EVP_BytesToKey() */
int pkcs_5_alg1_openssl(const unsigned char *password,
unsigned long password_len,
const unsigned char *salt,
int iteration_count, int hash_idx,
unsigned char *out, unsigned long *outlen);
2004-05-12 20:42:16 +00:00
/* Algorithm #2 (new) */
2012-07-26 14:43:15 +02:00
int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
2004-05-12 20:42:16 +00:00
const unsigned char *salt, unsigned long salt_len,
int iteration_count, int hash_idx,
unsigned char *out, unsigned long *outlen);
2014-01-03 22:04:50 +01:00
int pkcs_5_test (void);
2007-07-20 17:48:02 +00:00
#endif /* LTC_PKCS_5 */
2005-06-09 00:08:13 +00:00
/* $Source$ */
/* $Revision$ */
/* $Date$ */