2
0

RSA_meth_new.pod 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. =pod
  2. =head1 NAME
  3. RSA_meth_get0_app_data, RSA_meth_set0_app_data,
  4. RSA_meth_new, RSA_meth_free, RSA_meth_dup, RSA_meth_get0_name,
  5. RSA_meth_set1_name, RSA_meth_get_flags, RSA_meth_set_flags,
  6. RSA_meth_get_pub_enc,
  7. RSA_meth_set_pub_enc, RSA_meth_get_pub_dec, RSA_meth_set_pub_dec,
  8. RSA_meth_get_priv_enc, RSA_meth_set_priv_enc, RSA_meth_get_priv_dec,
  9. RSA_meth_set_priv_dec, RSA_meth_get_mod_exp, RSA_meth_set_mod_exp,
  10. RSA_meth_get_bn_mod_exp, RSA_meth_set_bn_mod_exp, RSA_meth_get_init,
  11. RSA_meth_set_init, RSA_meth_get_finish, RSA_meth_set_finish,
  12. RSA_meth_get_sign, RSA_meth_set_sign, RSA_meth_get_verify,
  13. RSA_meth_set_verify, RSA_meth_get_keygen, RSA_meth_set_keygen,
  14. RSA_meth_get_multi_prime_keygen, RSA_meth_set_multi_prime_keygen
  15. - Routines to build up RSA methods
  16. =head1 SYNOPSIS
  17. #include <openssl/rsa.h>
  18. The following functions have been deprecated since OpenSSL 3.0, and can be
  19. hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
  20. see L<openssl_user_macros(7)>:
  21. RSA_METHOD *RSA_meth_new(const char *name, int flags);
  22. void RSA_meth_free(RSA_METHOD *meth);
  23. RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
  24. const char *RSA_meth_get0_name(const RSA_METHOD *meth);
  25. int RSA_meth_set1_name(RSA_METHOD *meth, const char *name);
  26. int RSA_meth_get_flags(const RSA_METHOD *meth);
  27. int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
  28. void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
  29. int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data);
  30. int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen, const unsigned char *from,
  31. unsigned char *to, RSA *rsa, int padding);
  32. int RSA_meth_set_pub_enc(RSA_METHOD *rsa,
  33. int (*pub_enc)(int flen, const unsigned char *from,
  34. unsigned char *to, RSA *rsa,
  35. int padding));
  36. int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))
  37. (int flen, const unsigned char *from,
  38. unsigned char *to, RSA *rsa, int padding);
  39. int RSA_meth_set_pub_dec(RSA_METHOD *rsa,
  40. int (*pub_dec)(int flen, const unsigned char *from,
  41. unsigned char *to, RSA *rsa,
  42. int padding));
  43. int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen, const unsigned char *from,
  44. unsigned char *to, RSA *rsa,
  45. int padding);
  46. int RSA_meth_set_priv_enc(RSA_METHOD *rsa,
  47. int (*priv_enc)(int flen, const unsigned char *from,
  48. unsigned char *to, RSA *rsa, int padding));
  49. int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen, const unsigned char *from,
  50. unsigned char *to, RSA *rsa,
  51. int padding);
  52. int RSA_meth_set_priv_dec(RSA_METHOD *rsa,
  53. int (*priv_dec)(int flen, const unsigned char *from,
  54. unsigned char *to, RSA *rsa, int padding));
  55. /* Can be null */
  56. int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0, const BIGNUM *i,
  57. RSA *rsa, BN_CTX *ctx);
  58. int RSA_meth_set_mod_exp(RSA_METHOD *rsa,
  59. int (*mod_exp)(BIGNUM *r0, const BIGNUM *i, RSA *rsa,
  60. BN_CTX *ctx));
  61. /* Can be null */
  62. int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))(BIGNUM *r, const BIGNUM *a,
  63. const BIGNUM *p, const BIGNUM *m,
  64. BN_CTX *ctx, BN_MONT_CTX *m_ctx);
  65. int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,
  66. int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a,
  67. const BIGNUM *p, const BIGNUM *m,
  68. BN_CTX *ctx, BN_MONT_CTX *m_ctx));
  69. /* called at new */
  70. int (*RSA_meth_get_init(const RSA_METHOD *meth) (RSA *rsa);
  71. int RSA_meth_set_init(RSA_METHOD *rsa, int (*init (RSA *rsa));
  72. /* called at free */
  73. int (*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa);
  74. int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish)(RSA *rsa));
  75. int (*RSA_meth_get_sign(const RSA_METHOD *meth))(int type, const unsigned char *m,
  76. unsigned int m_length,
  77. unsigned char *sigret,
  78. unsigned int *siglen, const RSA *rsa);
  79. int RSA_meth_set_sign(RSA_METHOD *rsa,
  80. int (*sign)(int type, const unsigned char *m,
  81. unsigned int m_length, unsigned char *sigret,
  82. unsigned int *siglen, const RSA *rsa));
  83. int (*RSA_meth_get_verify(const RSA_METHOD *meth))(int dtype, const unsigned char *m,
  84. unsigned int m_length,
  85. const unsigned char *sigbuf,
  86. unsigned int siglen, const RSA *rsa);
  87. int RSA_meth_set_verify(RSA_METHOD *rsa,
  88. int (*verify)(int dtype, const unsigned char *m,
  89. unsigned int m_length,
  90. const unsigned char *sigbuf,
  91. unsigned int siglen, const RSA *rsa));
  92. int (*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, BIGNUM *e,
  93. BN_GENCB *cb);
  94. int RSA_meth_set_keygen(RSA_METHOD *rsa,
  95. int (*keygen)(RSA *rsa, int bits, BIGNUM *e,
  96. BN_GENCB *cb));
  97. int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits,
  98. int primes, BIGNUM *e,
  99. BN_GENCB *cb);
  100. int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth,
  101. int (*keygen) (RSA *rsa, int bits,
  102. int primes, BIGNUM *e,
  103. BN_GENCB *cb));
  104. =head1 DESCRIPTION
  105. All of the functions described on this page are deprecated.
  106. Applications should instead use the OSSL_PROVIDER APIs.
  107. The B<RSA_METHOD> type is a structure used for the provision of custom
  108. RSA implementations. It provides a set of functions used by OpenSSL
  109. for the implementation of the various RSA capabilities.
  110. RSA_meth_new() creates a new B<RSA_METHOD> structure. It should be
  111. given a unique B<name> and a set of B<flags>. The B<name> should be a
  112. NULL terminated string, which will be duplicated and stored in the
  113. B<RSA_METHOD> object. It is the callers responsibility to free the
  114. original string. The flags will be used during the construction of a
  115. new B<RSA> object based on this B<RSA_METHOD>. Any new B<RSA> object
  116. will have those flags set by default.
  117. RSA_meth_dup() creates a duplicate copy of the B<RSA_METHOD> object
  118. passed as a parameter. This might be useful for creating a new
  119. B<RSA_METHOD> based on an existing one, but with some differences.
  120. RSA_meth_free() destroys an B<RSA_METHOD> structure and frees up any
  121. memory associated with it.
  122. RSA_meth_get0_name() will return a pointer to the name of this
  123. RSA_METHOD. This is a pointer to the internal name string and so
  124. should not be freed by the caller. RSA_meth_set1_name() sets the name
  125. of the RSA_METHOD to B<name>. The string is duplicated and the copy is
  126. stored in the RSA_METHOD structure, so the caller remains responsible
  127. for freeing the memory associated with the name.
  128. RSA_meth_get_flags() returns the current value of the flags associated
  129. with this RSA_METHOD. RSA_meth_set_flags() provides the ability to set
  130. these flags.
  131. The functions RSA_meth_get0_app_data() and RSA_meth_set0_app_data()
  132. provide the ability to associate implementation specific data with the
  133. RSA_METHOD. It is the application's responsibility to free this data
  134. before the RSA_METHOD is freed via a call to RSA_meth_free().
  135. RSA_meth_get_sign() and RSA_meth_set_sign() get and set the function
  136. used for creating an RSA signature respectively. This function will be
  137. called in response to the application calling RSA_sign(). The
  138. parameters for the function have the same meaning as for RSA_sign().
  139. RSA_meth_get_verify() and RSA_meth_set_verify() get and set the
  140. function used for verifying an RSA signature respectively. This
  141. function will be called in response to the application calling
  142. RSA_verify(). The parameters for the function have the same meaning as
  143. for RSA_verify().
  144. RSA_meth_get_mod_exp() and RSA_meth_set_mod_exp() get and set the
  145. function used for CRT computations.
  146. RSA_meth_get_bn_mod_exp() and RSA_meth_set_bn_mod_exp() get and set
  147. the function used for CRT computations, specifically the following
  148. value:
  149. r = a ^ p mod m
  150. Both the mod_exp() and bn_mod_exp() functions are called by the
  151. default OpenSSL method during encryption, decryption, signing and
  152. verification.
  153. RSA_meth_get_init() and RSA_meth_set_init() get and set the function
  154. used for creating a new RSA instance respectively. This function will
  155. be called in response to the application calling RSA_new() (if the
  156. current default RSA_METHOD is this one) or RSA_new_method(). The
  157. RSA_new() and RSA_new_method() functions will allocate the memory for
  158. the new RSA object, and a pointer to this newly allocated structure
  159. will be passed as a parameter to the function. This function may be
  160. NULL.
  161. RSA_meth_get_finish() and RSA_meth_set_finish() get and set the
  162. function used for destroying an instance of an RSA object respectively.
  163. This function will be called in response to the application calling
  164. RSA_free(). A pointer to the RSA to be destroyed is passed as a
  165. parameter. The destroy function should be used for RSA implementation
  166. specific clean up. The memory for the RSA itself should not be freed
  167. by this function. This function may be NULL.
  168. RSA_meth_get_keygen() and RSA_meth_set_keygen() get and set the
  169. function used for generating a new RSA key pair respectively. This
  170. function will be called in response to the application calling
  171. RSA_generate_key_ex(). The parameter for the function has the same
  172. meaning as for RSA_generate_key_ex().
  173. RSA_meth_get_multi_prime_keygen() and RSA_meth_set_multi_prime_keygen() get
  174. and set the function used for generating a new multi-prime RSA key pair
  175. respectively. This function will be called in response to the application calling
  176. RSA_generate_multi_prime_key(). The parameter for the function has the same
  177. meaning as for RSA_generate_multi_prime_key().
  178. RSA_meth_get_pub_enc(), RSA_meth_set_pub_enc(),
  179. RSA_meth_get_pub_dec(), RSA_meth_set_pub_dec(),
  180. RSA_meth_get_priv_enc(), RSA_meth_set_priv_enc(),
  181. RSA_meth_get_priv_dec(), RSA_meth_set_priv_dec() get and set the
  182. functions used for public and private key encryption and decryption.
  183. These functions will be called in response to the application calling
  184. RSA_public_encrypt(), RSA_private_decrypt(), RSA_private_encrypt() and
  185. RSA_public_decrypt() and take the same parameters as those.
  186. =head1 RETURN VALUES
  187. RSA_meth_new() and RSA_meth_dup() return the newly allocated
  188. RSA_METHOD object or NULL on failure.
  189. RSA_meth_get0_name() and RSA_meth_get_flags() return the name and
  190. flags associated with the RSA_METHOD respectively.
  191. All other RSA_meth_get_*() functions return the appropriate function
  192. pointer that has been set in the RSA_METHOD, or NULL if no such
  193. pointer has yet been set.
  194. RSA_meth_set1_name and all RSA_meth_set_*() functions return 1 on
  195. success or 0 on failure.
  196. =head1 SEE ALSO
  197. L<RSA_new(3)>, L<RSA_generate_key_ex(3)>, L<RSA_sign(3)>,
  198. L<RSA_set_method(3)>, L<RSA_size(3)>, L<RSA_get0_key(3)>,
  199. L<RSA_generate_multi_prime_key(3)>
  200. =head1 HISTORY
  201. All of these functions were deprecated in OpenSSL 3.0.
  202. RSA_meth_get_multi_prime_keygen() and RSA_meth_set_multi_prime_keygen() were
  203. added in OpenSSL 1.1.1.
  204. Other functions described here were added in OpenSSL 1.1.0.
  205. =head1 COPYRIGHT
  206. Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
  207. Licensed under the Apache License 2.0 (the "License"). You may not use
  208. this file except in compliance with the License. You can obtain a copy
  209. in the file LICENSE in the source distribution or at
  210. L<https://www.openssl.org/source/license.html>.
  211. =cut