Path: blob/master/libs/tomcrypt/src/headers/tomcrypt_pkcs.h
5971 views
/* LibTomCrypt, modular cryptographic library -- Tom St Denis1*2* LibTomCrypt is a library that provides various cryptographic3* algorithms in a highly modular and flexible manner.4*5* The library is free for all purposes without any express6* guarantee it works.7*/89/* PKCS Header Info */1011/* ===> PKCS #1 -- RSA Cryptography <=== */12#ifdef LTC_PKCS_11314enum ltc_pkcs_1_v1_5_blocks15{16LTC_PKCS_1_EMSA = 1, /* Block type 1 (PKCS #1 v1.5 signature padding) */17LTC_PKCS_1_EME = 2 /* Block type 2 (PKCS #1 v1.5 encryption padding) */18};1920enum ltc_pkcs_1_paddings21{22LTC_PKCS_1_V1_5 = 1, /* PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */23LTC_PKCS_1_OAEP = 2, /* PKCS #1 v2.0 encryption padding */24LTC_PKCS_1_PSS = 3, /* PKCS #1 v2.1 signature padding */25LTC_PKCS_1_V1_5_NA1 = 4 /* PKCS #1 v1.5 padding - No ASN.1 (\sa ltc_pkcs_1_v1_5_blocks) */26};2728int pkcs_1_mgf1( int hash_idx,29const unsigned char *seed, unsigned long seedlen,30unsigned char *mask, unsigned long masklen);3132int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out);33int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen);3435/* *** v1.5 padding */36int pkcs_1_v1_5_encode(const unsigned char *msg,37unsigned long msglen,38int block_type,39unsigned long modulus_bitlen,40prng_state *prng,41int prng_idx,42unsigned char *out,43unsigned long *outlen);4445int pkcs_1_v1_5_decode(const unsigned char *msg,46unsigned long msglen,47int block_type,48unsigned long modulus_bitlen,49unsigned char *out,50unsigned long *outlen,51int *is_valid);5253/* *** v2.1 padding */54int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,55const unsigned char *lparam, unsigned long lparamlen,56unsigned long modulus_bitlen, prng_state *prng,57int prng_idx, int hash_idx,58unsigned char *out, unsigned long *outlen);5960int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,61const unsigned char *lparam, unsigned long lparamlen,62unsigned long modulus_bitlen, int hash_idx,63unsigned char *out, unsigned long *outlen,64int *res);6566int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,67unsigned long saltlen, prng_state *prng,68int prng_idx, int hash_idx,69unsigned long modulus_bitlen,70unsigned char *out, unsigned long *outlen);7172int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,73const unsigned char *sig, unsigned long siglen,74unsigned long saltlen, int hash_idx,75unsigned long modulus_bitlen, int *res);7677#endif /* LTC_PKCS_1 */7879/* ===> PKCS #5 -- Password Based Cryptography <=== */80#ifdef LTC_PKCS_58182/* Algorithm #1 (PBKDF1) */83int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,84const unsigned char *salt,85int iteration_count, int hash_idx,86unsigned char *out, unsigned long *outlen);8788/* Algorithm #1 (PBKDF1) - OpenSSL-compatible variant for arbitrarily-long keys.89Compatible with EVP_BytesToKey() */90int pkcs_5_alg1_openssl(const unsigned char *password,91unsigned long password_len,92const unsigned char *salt,93int iteration_count, int hash_idx,94unsigned char *out, unsigned long *outlen);9596/* Algorithm #2 (PBKDF2) */97int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,98const unsigned char *salt, unsigned long salt_len,99int iteration_count, int hash_idx,100unsigned char *out, unsigned long *outlen);101102int pkcs_5_test (void);103#endif /* LTC_PKCS_5 */104105106