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