mycrypt_pkcs.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* PKCS Header Info */
  2. /* ===> PKCS #1 -- RSA Cryptography <=== */
  3. #ifdef PKCS_1
  4. int pkcs_1_mgf1(const unsigned char *seed, unsigned long seedlen,
  5. int hash_idx,
  6. unsigned char *mask, unsigned long masklen);
  7. int pkcs_1_i2osp(mp_int *n, unsigned long modulus_len, unsigned char *out);
  8. int pkcs_1_os2ip(mp_int *n, unsigned char *in, unsigned long inlen);
  9. /* *** v2.0 padding */
  10. int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
  11. const unsigned char *lparam, unsigned long lparamlen,
  12. unsigned long modulus_bitlen, prng_state *prng,
  13. int prng_idx, int hash_idx,
  14. unsigned char *out, unsigned long *outlen);
  15. int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
  16. const unsigned char *lparam, unsigned long lparamlen,
  17. unsigned long modulus_bitlen, int hash_idx,
  18. unsigned char *out, unsigned long *outlen,
  19. int *res);
  20. int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
  21. unsigned long saltlen, prng_state *prng,
  22. int prng_idx, int hash_idx,
  23. unsigned long modulus_bitlen,
  24. unsigned char *out, unsigned long *outlen);
  25. int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
  26. const unsigned char *sig, unsigned long siglen,
  27. unsigned long saltlen, int hash_idx,
  28. unsigned long modulus_bitlen, int *res);
  29. /* *** v1.5 padding */
  30. /* encryption padding */
  31. int pkcs_1_v15_es_encode(const unsigned char *msg, unsigned long msglen,
  32. unsigned long modulus_bitlen,
  33. prng_state *prng, int prng_idx,
  34. unsigned char *out, unsigned long *outlen);
  35. /* note "outlen" is fixed, you have to tell this decoder how big
  36. * the original message was. Unlike the OAEP decoder it cannot auto-detect it.
  37. */
  38. int pkcs_1_v15_es_decode(const unsigned char *msg, unsigned long msglen,
  39. unsigned long modulus_bitlen,
  40. unsigned char *out, unsigned long outlen,
  41. int *res);
  42. /* signature padding */
  43. int pkcs_1_v15_sa_encode(const unsigned char *msghash, unsigned long msghashlen,
  44. int hash_idx, unsigned long modulus_bitlen,
  45. unsigned char *out, unsigned long *outlen);
  46. int pkcs_1_v15_sa_decode(const unsigned char *msghash, unsigned long msghashlen,
  47. const unsigned char *sig, unsigned long siglen,
  48. int hash_idx, unsigned long modulus_bitlen,
  49. int *res);
  50. #endif /* PKCS_1 */
  51. /* ===> PKCS #5 -- Password Based Cryptography <=== */
  52. #ifdef PKCS_5
  53. /* Algorithm #1 (old) */
  54. int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
  55. const unsigned char *salt,
  56. int iteration_count, int hash_idx,
  57. unsigned char *out, unsigned long *outlen);
  58. /* Algorithm #2 (new) */
  59. int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
  60. const unsigned char *salt, unsigned long salt_len,
  61. int iteration_count, int hash_idx,
  62. unsigned char *out, unsigned long *outlen);
  63. #endif /* PKCS_5 */