rsa.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef OSSL_INTERNAL_RSA_H
  10. # define OSSL_INTERNAL_RSA_H
  11. # include <openssl/core.h>
  12. # include <openssl/rsa.h>
  13. typedef struct rsa_pss_params_30_st {
  14. int hash_algorithm_nid;
  15. struct {
  16. int algorithm_nid; /* Currently always NID_mgf1 */
  17. int hash_algorithm_nid;
  18. } mask_gen;
  19. unsigned int salt_len;
  20. unsigned int trailer_field;
  21. } RSA_PSS_PARAMS_30;
  22. RSA_PSS_PARAMS_30 *rsa_get0_pss_params_30(RSA *r);
  23. int rsa_pss_params_30_set_defaults(RSA_PSS_PARAMS_30 *rsa_pss_params);
  24. int rsa_pss_params_30_copy(RSA_PSS_PARAMS_30 *to,
  25. const RSA_PSS_PARAMS_30 *from);
  26. int rsa_pss_params_30_is_unrestricted(const RSA_PSS_PARAMS_30 *rsa_pss_params);
  27. int rsa_pss_params_30_set_hashalg(RSA_PSS_PARAMS_30 *rsa_pss_params,
  28. int hashalg_nid);
  29. int rsa_pss_params_30_set_maskgenalg(RSA_PSS_PARAMS_30 *rsa_pss_params,
  30. int maskgenalg_nid);
  31. int rsa_pss_params_30_set_maskgenhashalg(RSA_PSS_PARAMS_30 *rsa_pss_params,
  32. int maskgenhashalg_nid);
  33. int rsa_pss_params_30_set_saltlen(RSA_PSS_PARAMS_30 *rsa_pss_params,
  34. int saltlen);
  35. int rsa_pss_params_30_set_trailerfield(RSA_PSS_PARAMS_30 *rsa_pss_params,
  36. int trailerfield);
  37. int rsa_pss_params_30_hashalg(const RSA_PSS_PARAMS_30 *rsa_pss_params);
  38. int rsa_pss_params_30_maskgenalg(const RSA_PSS_PARAMS_30 *rsa_pss_params);
  39. int rsa_pss_params_30_maskgenhashalg(const RSA_PSS_PARAMS_30 *rsa_pss_params);
  40. int rsa_pss_params_30_saltlen(const RSA_PSS_PARAMS_30 *rsa_pss_params);
  41. int rsa_pss_params_30_trailerfield(const RSA_PSS_PARAMS_30 *rsa_pss_params);
  42. const char *rsa_mgf_nid2name(int mgf);
  43. int rsa_oaeppss_md2nid(const EVP_MD *md);
  44. const char *rsa_oaeppss_nid2name(int md);
  45. RSA *rsa_new_with_ctx(OPENSSL_CTX *libctx);
  46. OPENSSL_CTX *rsa_get0_libctx(RSA *r);
  47. int rsa_set0_all_params(RSA *r, const STACK_OF(BIGNUM) *primes,
  48. const STACK_OF(BIGNUM) *exps,
  49. const STACK_OF(BIGNUM) *coeffs);
  50. int rsa_get0_all_params(RSA *r, STACK_OF(BIGNUM_const) *primes,
  51. STACK_OF(BIGNUM_const) *exps,
  52. STACK_OF(BIGNUM_const) *coeffs);
  53. int rsa_todata(RSA *rsa, OSSL_PARAM_BLD *bld, OSSL_PARAM params[]);
  54. int rsa_fromdata(RSA *rsa, const OSSL_PARAM params[]);
  55. int rsa_pss_params_30_todata(const RSA_PSS_PARAMS_30 *pss, const char *propq,
  56. OSSL_PARAM_BLD *bld, OSSL_PARAM params[]);
  57. int rsa_pss_params_30_fromdata(RSA_PSS_PARAMS_30 *pss_params,
  58. const OSSL_PARAM params[], OPENSSL_CTX *libctx);
  59. int rsa_padding_check_PKCS1_type_2_TLS(OPENSSL_CTX *ctx, unsigned char *to,
  60. size_t tlen, const unsigned char *from,
  61. size_t flen, int client_version,
  62. int alt_version);
  63. int rsa_padding_add_PKCS1_OAEP_mgf1_with_libctx(OPENSSL_CTX *libctx,
  64. unsigned char *to, int tlen,
  65. const unsigned char *from,
  66. int flen,
  67. const unsigned char *param,
  68. int plen, const EVP_MD *md,
  69. const EVP_MD *mgf1md);
  70. int rsa_validate_public(const RSA *key);
  71. int rsa_validate_private(const RSA *key);
  72. int rsa_validate_pairwise(const RSA *key);
  73. int int_rsa_verify(int dtype, const unsigned char *m,
  74. unsigned int m_len, unsigned char *rm,
  75. size_t *prm_len, const unsigned char *sigbuf,
  76. size_t siglen, RSA *rsa);
  77. const unsigned char *rsa_digestinfo_encoding(int md_nid, size_t *len);
  78. const unsigned char *rsa_algorithmidentifier_encoding(int md_nid, size_t *len);
  79. extern const char *rsa_mp_factor_names[];
  80. extern const char *rsa_mp_exp_names[];
  81. extern const char *rsa_mp_coeff_names[];
  82. # if defined(FIPS_MODULE) && !defined(OPENSSL_NO_ACVP_TESTS)
  83. int rsa_acvp_test_gen_params_new(OSSL_PARAM **dst, const OSSL_PARAM src[]);
  84. void rsa_acvp_test_gen_params_free(OSSL_PARAM *dst);
  85. int rsa_acvp_test_set_params(RSA *r, const OSSL_PARAM params[]);
  86. int rsa_acvp_test_get_params(RSA *r, OSSL_PARAM params[]);
  87. typedef struct rsa_acvp_test_st RSA_ACVP_TEST;
  88. void rsa_acvp_test_free(RSA_ACVP_TEST *t);
  89. # else
  90. # define RSA_ACVP_TEST void
  91. # endif
  92. #endif