RSA_get0_key.pod 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. =pod
  2. =head1 NAME
  3. RSA_set0_key, RSA_set0_factors, RSA_set0_crt_params, RSA_get0_key,
  4. RSA_get0_factors, RSA_get0_crt_params,
  5. RSA_get0_n, RSA_get0_e, RSA_get0_d, RSA_get0_p, RSA_get0_q,
  6. RSA_get0_dmp1, RSA_get0_dmq1, RSA_get0_iqmp, RSA_get0_pss_params,
  7. RSA_clear_flags,
  8. RSA_test_flags, RSA_set_flags, RSA_get0_engine, RSA_get_multi_prime_extra_count,
  9. RSA_get0_multi_prime_factors, RSA_get0_multi_prime_crt_params,
  10. RSA_set0_multi_prime_params, RSA_get_version
  11. - Routines for getting and setting data in an RSA object
  12. =head1 SYNOPSIS
  13. #include <openssl/rsa.h>
  14. Deprecated since OpenSSL 3.0, can be hidden entirely by defining
  15. B<OPENSSL_API_COMPAT> with a suitable version value, see
  16. L<openssl_user_macros(7)>:
  17. int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
  18. int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
  19. int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
  20. void RSA_get0_key(const RSA *r,
  21. const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);
  22. void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
  23. void RSA_get0_crt_params(const RSA *r,
  24. const BIGNUM **dmp1, const BIGNUM **dmq1,
  25. const BIGNUM **iqmp);
  26. const BIGNUM *RSA_get0_n(const RSA *d);
  27. const BIGNUM *RSA_get0_e(const RSA *d);
  28. const BIGNUM *RSA_get0_d(const RSA *d);
  29. const BIGNUM *RSA_get0_p(const RSA *d);
  30. const BIGNUM *RSA_get0_q(const RSA *d);
  31. const BIGNUM *RSA_get0_dmp1(const RSA *r);
  32. const BIGNUM *RSA_get0_dmq1(const RSA *r);
  33. const BIGNUM *RSA_get0_iqmp(const RSA *r);
  34. const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r);
  35. void RSA_clear_flags(RSA *r, int flags);
  36. int RSA_test_flags(const RSA *r, int flags);
  37. void RSA_set_flags(RSA *r, int flags);
  38. ENGINE *RSA_get0_engine(RSA *r);
  39. int RSA_get_multi_prime_extra_count(const RSA *r);
  40. int RSA_get0_multi_prime_factors(const RSA *r, const BIGNUM *primes[]);
  41. int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[],
  42. const BIGNUM *coeffs[]);
  43. int RSA_set0_multi_prime_params(RSA *r, BIGNUM *primes[], BIGNUM *exps[],
  44. BIGNUM *coeffs[], int pnum);
  45. int RSA_get_version(RSA *r);
  46. =head1 DESCRIPTION
  47. All of the functions described on this page are deprecated.
  48. Applications should instead use L<EVP_PKEY_get_bn_param(3)> for any methods that
  49. return a B<BIGNUM>. Refer to L<EVP_PKEY-DH(7)> for more infomation.
  50. An RSA object contains the components for the public and private key,
  51. B<n>, B<e>, B<d>, B<p>, B<q>, B<dmp1>, B<dmq1> and B<iqmp>. B<n> is
  52. the modulus common to both public and private key, B<e> is the public
  53. exponent and B<d> is the private exponent. B<p>, B<q>, B<dmp1>,
  54. B<dmq1> and B<iqmp> are the factors for the second representation of a
  55. private key (see PKCS#1 section 3 Key Types), where B<p> and B<q> are
  56. the first and second factor of B<n> and B<dmp1>, B<dmq1> and B<iqmp>
  57. are the exponents and coefficient for CRT calculations.
  58. For multi-prime RSA (defined in RFC 8017), there are also one or more
  59. 'triplet' in an RSA object. A triplet contains three members, B<r>, B<d>
  60. and B<t>. B<r> is the additional prime besides B<p> and B<q>. B<d> and
  61. B<t> are the exponent and coefficient for CRT calculations.
  62. The B<n>, B<e> and B<d> parameters can be obtained by calling
  63. RSA_get0_key(). If they have not been set yet, then B<*n>, B<*e> and
  64. B<*d> will be set to NULL. Otherwise, they are set to pointers to
  65. their respective values. These point directly to the internal
  66. representations of the values and therefore should not be freed
  67. by the caller.
  68. The B<n>, B<e> and B<d> parameter values can be set by calling
  69. RSA_set0_key() and passing the new values for B<n>, B<e> and B<d> as
  70. parameters to the function. The values B<n> and B<e> must be non-NULL
  71. the first time this function is called on a given RSA object. The
  72. value B<d> may be NULL. On subsequent calls any of these values may be
  73. NULL which means the corresponding RSA field is left untouched.
  74. Calling this function transfers the memory management of the values to
  75. the RSA object, and therefore the values that have been passed in
  76. should not be freed by the caller after this function has been called.
  77. In a similar fashion, the B<p> and B<q> parameters can be obtained and
  78. set with RSA_get0_factors() and RSA_set0_factors(), and the B<dmp1>,
  79. B<dmq1> and B<iqmp> parameters can be obtained and set with
  80. RSA_get0_crt_params() and RSA_set0_crt_params().
  81. For RSA_get0_key(), RSA_get0_factors(), and RSA_get0_crt_params(),
  82. NULL value BIGNUM ** output parameters are permitted. The functions
  83. ignore NULL parameters but return values for other, non-NULL, parameters.
  84. For multi-prime RSA, RSA_get0_multi_prime_factors() and RSA_get0_multi_prime_params()
  85. can be used to obtain other primes and related CRT parameters. The
  86. return values are stored in an array of B<BIGNUM *>. RSA_set0_multi_prime_params()
  87. sets a collect of multi-prime 'triplet' members (prime, exponent and coefficient)
  88. into an RSA object.
  89. Any of the values B<n>, B<e>, B<d>, B<p>, B<q>, B<dmp1>, B<dmq1>, and B<iqmp> can also be
  90. retrieved separately by the corresponding function
  91. RSA_get0_n(), RSA_get0_e(), RSA_get0_d(), RSA_get0_p(), RSA_get0_q(),
  92. RSA_get0_dmp1(), RSA_get0_dmq1(), and RSA_get0_iqmp(), respectively.
  93. RSA_get0_pss_params() is used to retrieve the RSA-PSS parameters.
  94. RSA_set_flags() sets the flags in the B<flags> parameter on the RSA
  95. object. Multiple flags can be passed in one go (bitwise ORed together).
  96. Any flags that are already set are left set. RSA_test_flags() tests to
  97. see whether the flags passed in the B<flags> parameter are currently
  98. set in the RSA object. Multiple flags can be tested in one go. All
  99. flags that are currently set are returned, or zero if none of the
  100. flags are set. RSA_clear_flags() clears the specified flags within the
  101. RSA object.
  102. RSA_get0_engine() returns a handle to the ENGINE that has been set for
  103. this RSA object, or NULL if no such ENGINE has been set.
  104. RSA_get_version() returns the version of an RSA object B<r>.
  105. =head1 NOTES
  106. Values retrieved with RSA_get0_key() are owned by the RSA object used
  107. in the call and may therefore I<not> be passed to RSA_set0_key(). If
  108. needed, duplicate the received value using BN_dup() and pass the
  109. duplicate. The same applies to RSA_get0_factors() and RSA_set0_factors()
  110. as well as RSA_get0_crt_params() and RSA_set0_crt_params().
  111. The caller should obtain the size by calling RSA_get_multi_prime_extra_count()
  112. in advance and allocate sufficient buffer to store the return values before
  113. calling RSA_get0_multi_prime_factors() and RSA_get0_multi_prime_params().
  114. RSA_set0_multi_prime_params() always clears the original multi-prime
  115. triplets in RSA object B<r> and assign the new set of triplets into it.
  116. =head1 RETURN VALUES
  117. RSA_set0_key(), RSA_set0_factors(), RSA_set0_crt_params() and
  118. RSA_set0_multi_prime_params() return 1 on success or 0 on failure.
  119. RSA_get0_n(), RSA_get0_e(), RSA_get0_d(), RSA_get0_p(), RSA_get0_q(),
  120. RSA_get0_dmp1(), RSA_get0_dmq1(), and RSA_get0_iqmp()
  121. return the respective value.
  122. RSA_get0_pss_params() returns a B<RSA_PSS_PARAMS> pointer, or NULL if
  123. there is none.
  124. RSA_get0_multi_prime_factors() and RSA_get0_multi_prime_crt_params() return
  125. 1 on success or 0 on failure.
  126. RSA_get_multi_prime_extra_count() returns two less than the number of primes
  127. in use, which is 0 for traditional RSA and the number of extra primes for
  128. multi-prime RSA.
  129. RSA_get_version() returns B<RSA_ASN1_VERSION_MULTI> for multi-prime RSA and
  130. B<RSA_ASN1_VERSION_DEFAULT> for normal two-prime RSA, as defined in RFC 8017.
  131. RSA_test_flags() returns the current state of the flags in the RSA object.
  132. RSA_get0_engine() returns the ENGINE set for the RSA object or NULL if no
  133. ENGINE has been set.
  134. =head1 SEE ALSO
  135. L<RSA_new(3)>, L<RSA_size(3)>
  136. =head1 HISTORY
  137. The RSA_get0_pss_params() function was added in OpenSSL 1.1.1e.
  138. The
  139. RSA_get_multi_prime_extra_count(), RSA_get0_multi_prime_factors(),
  140. RSA_get0_multi_prime_crt_params(), RSA_set0_multi_prime_params(),
  141. and RSA_get_version() functions were added in OpenSSL 1.1.1.
  142. Other functions described here were added in OpenSSL 1.1.0.
  143. All of these functions were deprecated in OpenSSL 3.0.
  144. =head1 COPYRIGHT
  145. Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
  146. Licensed under the Apache License 2.0 (the "License"). You may not use
  147. this file except in compliance with the License. You can obtain a copy
  148. in the file LICENSE in the source distribution or at
  149. L<https://www.openssl.org/source/license.html>.
  150. =cut