RSA_get0_key.3ossl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "RSA_GET0_KEY 3ossl"
  58. .TH RSA_GET0_KEY 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. RSA_set0_key, RSA_set0_factors, RSA_set0_crt_params, RSA_get0_key,
  65. RSA_get0_factors, RSA_get0_crt_params,
  66. RSA_get0_n, RSA_get0_e, RSA_get0_d, RSA_get0_p, RSA_get0_q,
  67. RSA_get0_dmp1, RSA_get0_dmq1, RSA_get0_iqmp, RSA_get0_pss_params,
  68. RSA_clear_flags,
  69. RSA_test_flags, RSA_set_flags, RSA_get0_engine, RSA_get_multi_prime_extra_count,
  70. RSA_get0_multi_prime_factors, RSA_get0_multi_prime_crt_params,
  71. RSA_set0_multi_prime_params, RSA_get_version
  72. \&\- Routines for getting and setting data in an RSA object
  73. .SH SYNOPSIS
  74. .IX Header "SYNOPSIS"
  75. .Vb 1
  76. \& #include <openssl/rsa.h>
  77. .Ve
  78. .PP
  79. The following functions have been deprecated since OpenSSL 3.0, and can be
  80. hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
  81. see \fBopenssl_user_macros\fR\|(7):
  82. .PP
  83. .Vb 10
  84. \& int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
  85. \& int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
  86. \& int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
  87. \& void RSA_get0_key(const RSA *r,
  88. \& const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);
  89. \& void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
  90. \& void RSA_get0_crt_params(const RSA *r,
  91. \& const BIGNUM **dmp1, const BIGNUM **dmq1,
  92. \& const BIGNUM **iqmp);
  93. \& const BIGNUM *RSA_get0_n(const RSA *d);
  94. \& const BIGNUM *RSA_get0_e(const RSA *d);
  95. \& const BIGNUM *RSA_get0_d(const RSA *d);
  96. \& const BIGNUM *RSA_get0_p(const RSA *d);
  97. \& const BIGNUM *RSA_get0_q(const RSA *d);
  98. \& const BIGNUM *RSA_get0_dmp1(const RSA *r);
  99. \& const BIGNUM *RSA_get0_dmq1(const RSA *r);
  100. \& const BIGNUM *RSA_get0_iqmp(const RSA *r);
  101. \& const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r);
  102. \& void RSA_clear_flags(RSA *r, int flags);
  103. \& int RSA_test_flags(const RSA *r, int flags);
  104. \& void RSA_set_flags(RSA *r, int flags);
  105. \& ENGINE *RSA_get0_engine(RSA *r);
  106. \& int RSA_get_multi_prime_extra_count(const RSA *r);
  107. \& int RSA_get0_multi_prime_factors(const RSA *r, const BIGNUM *primes[]);
  108. \& int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[],
  109. \& const BIGNUM *coeffs[]);
  110. \& int RSA_set0_multi_prime_params(RSA *r, BIGNUM *primes[], BIGNUM *exps[],
  111. \& BIGNUM *coeffs[], int pnum);
  112. \& int RSA_get_version(RSA *r);
  113. .Ve
  114. .SH DESCRIPTION
  115. .IX Header "DESCRIPTION"
  116. All of the functions described on this page are deprecated.
  117. Applications should instead use \fBEVP_PKEY_get_bn_param\fR\|(3) for any methods that
  118. return a \fBBIGNUM\fR. Refer to \fBEVP_PKEY\-DH\fR\|(7) for more information.
  119. .PP
  120. An RSA object contains the components for the public and private key,
  121. \&\fBn\fR, \fBe\fR, \fBd\fR, \fBp\fR, \fBq\fR, \fBdmp1\fR, \fBdmq1\fR and \fBiqmp\fR. \fBn\fR is
  122. the modulus common to both public and private key, \fBe\fR is the public
  123. exponent and \fBd\fR is the private exponent. \fBp\fR, \fBq\fR, \fBdmp1\fR,
  124. \&\fBdmq1\fR and \fBiqmp\fR are the factors for the second representation of a
  125. private key (see PKCS#1 section 3 Key Types), where \fBp\fR and \fBq\fR are
  126. the first and second factor of \fBn\fR and \fBdmp1\fR, \fBdmq1\fR and \fBiqmp\fR
  127. are the exponents and coefficient for CRT calculations.
  128. .PP
  129. For multi-prime RSA (defined in RFC 8017), there are also one or more
  130. \&'triplet' in an RSA object. A triplet contains three members, \fBr\fR, \fBd\fR
  131. and \fBt\fR. \fBr\fR is the additional prime besides \fBp\fR and \fBq\fR. \fBd\fR and
  132. \&\fBt\fR are the exponent and coefficient for CRT calculations.
  133. .PP
  134. The \fBn\fR, \fBe\fR and \fBd\fR parameters can be obtained by calling
  135. \&\fBRSA_get0_key()\fR. If they have not been set yet, then \fB*n\fR, \fB*e\fR and
  136. \&\fB*d\fR will be set to NULL. Otherwise, they are set to pointers to
  137. their respective values. These point directly to the internal
  138. representations of the values and therefore should not be freed
  139. by the caller.
  140. .PP
  141. The \fBn\fR, \fBe\fR and \fBd\fR parameter values can be set by calling
  142. \&\fBRSA_set0_key()\fR and passing the new values for \fBn\fR, \fBe\fR and \fBd\fR as
  143. parameters to the function. The values \fBn\fR and \fBe\fR must be non-NULL
  144. the first time this function is called on a given RSA object. The
  145. value \fBd\fR may be NULL. On subsequent calls any of these values may be
  146. NULL which means the corresponding RSA field is left untouched.
  147. Calling this function transfers the memory management of the values to
  148. the RSA object, and therefore the values that have been passed in
  149. should not be freed by the caller after this function has been called.
  150. .PP
  151. In a similar fashion, the \fBp\fR and \fBq\fR parameters can be obtained and
  152. set with \fBRSA_get0_factors()\fR and \fBRSA_set0_factors()\fR, and the \fBdmp1\fR,
  153. \&\fBdmq1\fR and \fBiqmp\fR parameters can be obtained and set with
  154. \&\fBRSA_get0_crt_params()\fR and \fBRSA_set0_crt_params()\fR.
  155. .PP
  156. For \fBRSA_get0_key()\fR, \fBRSA_get0_factors()\fR, and \fBRSA_get0_crt_params()\fR,
  157. NULL value BIGNUM ** output parameters are permitted. The functions
  158. ignore NULL parameters but return values for other, non-NULL, parameters.
  159. .PP
  160. For multi-prime RSA, \fBRSA_get0_multi_prime_factors()\fR and \fBRSA_get0_multi_prime_params()\fR
  161. can be used to obtain other primes and related CRT parameters. The
  162. return values are stored in an array of \fBBIGNUM *\fR. \fBRSA_set0_multi_prime_params()\fR
  163. sets a collect of multi-prime 'triplet' members (prime, exponent and coefficient)
  164. into an RSA object.
  165. .PP
  166. Any of the values \fBn\fR, \fBe\fR, \fBd\fR, \fBp\fR, \fBq\fR, \fBdmp1\fR, \fBdmq1\fR, and \fBiqmp\fR can also be
  167. retrieved separately by the corresponding function
  168. \&\fBRSA_get0_n()\fR, \fBRSA_get0_e()\fR, \fBRSA_get0_d()\fR, \fBRSA_get0_p()\fR, \fBRSA_get0_q()\fR,
  169. \&\fBRSA_get0_dmp1()\fR, \fBRSA_get0_dmq1()\fR, and \fBRSA_get0_iqmp()\fR, respectively.
  170. .PP
  171. \&\fBRSA_get0_pss_params()\fR is used to retrieve the RSA-PSS parameters.
  172. .PP
  173. \&\fBRSA_set_flags()\fR sets the flags in the \fBflags\fR parameter on the RSA
  174. object. Multiple flags can be passed in one go (bitwise ORed together).
  175. Any flags that are already set are left set. \fBRSA_test_flags()\fR tests to
  176. see whether the flags passed in the \fBflags\fR parameter are currently
  177. set in the RSA object. Multiple flags can be tested in one go. All
  178. flags that are currently set are returned, or zero if none of the
  179. flags are set. \fBRSA_clear_flags()\fR clears the specified flags within the
  180. RSA object.
  181. .PP
  182. \&\fBRSA_get0_engine()\fR returns a handle to the ENGINE that has been set for
  183. this RSA object, or NULL if no such ENGINE has been set.
  184. .PP
  185. \&\fBRSA_get_version()\fR returns the version of an RSA object \fBr\fR.
  186. .SH NOTES
  187. .IX Header "NOTES"
  188. Values retrieved with \fBRSA_get0_key()\fR are owned by the RSA object used
  189. in the call and may therefore \fInot\fR be passed to \fBRSA_set0_key()\fR. If
  190. needed, duplicate the received value using \fBBN_dup()\fR and pass the
  191. duplicate. The same applies to \fBRSA_get0_factors()\fR and \fBRSA_set0_factors()\fR
  192. as well as \fBRSA_get0_crt_params()\fR and \fBRSA_set0_crt_params()\fR.
  193. .PP
  194. The caller should obtain the size by calling \fBRSA_get_multi_prime_extra_count()\fR
  195. in advance and allocate sufficient buffer to store the return values before
  196. calling \fBRSA_get0_multi_prime_factors()\fR and \fBRSA_get0_multi_prime_params()\fR.
  197. .PP
  198. \&\fBRSA_set0_multi_prime_params()\fR always clears the original multi-prime
  199. triplets in RSA object \fBr\fR and assign the new set of triplets into it.
  200. .SH "RETURN VALUES"
  201. .IX Header "RETURN VALUES"
  202. \&\fBRSA_set0_key()\fR, \fBRSA_set0_factors()\fR, \fBRSA_set0_crt_params()\fR and
  203. \&\fBRSA_set0_multi_prime_params()\fR return 1 on success or 0 on failure.
  204. .PP
  205. \&\fBRSA_get0_n()\fR, \fBRSA_get0_e()\fR, \fBRSA_get0_d()\fR, \fBRSA_get0_p()\fR, \fBRSA_get0_q()\fR,
  206. \&\fBRSA_get0_dmp1()\fR, \fBRSA_get0_dmq1()\fR, and \fBRSA_get0_iqmp()\fR
  207. return the respective value.
  208. .PP
  209. \&\fBRSA_get0_pss_params()\fR returns a \fBRSA_PSS_PARAMS\fR pointer, or NULL if
  210. there is none.
  211. .PP
  212. \&\fBRSA_get0_multi_prime_factors()\fR and \fBRSA_get0_multi_prime_crt_params()\fR return
  213. 1 on success or 0 on failure.
  214. .PP
  215. \&\fBRSA_get_multi_prime_extra_count()\fR returns two less than the number of primes
  216. in use, which is 0 for traditional RSA and the number of extra primes for
  217. multi-prime RSA.
  218. .PP
  219. \&\fBRSA_get_version()\fR returns \fBRSA_ASN1_VERSION_MULTI\fR for multi-prime RSA and
  220. \&\fBRSA_ASN1_VERSION_DEFAULT\fR for normal two-prime RSA, as defined in RFC 8017.
  221. .PP
  222. \&\fBRSA_test_flags()\fR returns the current state of the flags in the RSA object.
  223. .PP
  224. \&\fBRSA_get0_engine()\fR returns the ENGINE set for the RSA object or NULL if no
  225. ENGINE has been set.
  226. .SH "SEE ALSO"
  227. .IX Header "SEE ALSO"
  228. \&\fBRSA_new\fR\|(3), \fBRSA_size\fR\|(3)
  229. .SH HISTORY
  230. .IX Header "HISTORY"
  231. The \fBRSA_get0_pss_params()\fR function was added in OpenSSL 1.1.1e.
  232. .PP
  233. The
  234. \&\fBRSA_get_multi_prime_extra_count()\fR, \fBRSA_get0_multi_prime_factors()\fR,
  235. \&\fBRSA_get0_multi_prime_crt_params()\fR, \fBRSA_set0_multi_prime_params()\fR,
  236. and \fBRSA_get_version()\fR functions were added in OpenSSL 1.1.1.
  237. .PP
  238. Other functions described here were added in OpenSSL 1.1.0.
  239. .PP
  240. All of these functions were deprecated in OpenSSL 3.0.
  241. .SH COPYRIGHT
  242. .IX Header "COPYRIGHT"
  243. Copyright 2016\-2022 The OpenSSL Project Authors. All Rights Reserved.
  244. .PP
  245. Licensed under the Apache License 2.0 (the "License"). You may not use
  246. this file except in compliance with the License. You can obtain a copy
  247. in the file LICENSE in the source distribution or at
  248. <https://www.openssl.org/source/license.html>.