1RSA_GET0_KEY(3)                     OpenSSL                    RSA_GET0_KEY(3)
2
3
4

NAME

6       RSA_set0_key, RSA_set0_factors, RSA_set0_crt_params, RSA_get0_key,
7       RSA_get0_factors, RSA_get0_crt_params, RSA_get0_n, RSA_get0_e,
8       RSA_get0_d, RSA_get0_p, RSA_get0_q, RSA_get0_dmp1, RSA_get0_dmq1,
9       RSA_get0_iqmp, RSA_get0_pss_params, RSA_clear_flags, RSA_test_flags,
10       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 - Routines for getting and
13       setting data in an RSA object
14

SYNOPSIS

16        #include <openssl/rsa.h>
17
18        int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
19        int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
20        int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
21        void RSA_get0_key(const RSA *r,
22                          const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);
23        void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
24        void RSA_get0_crt_params(const RSA *r,
25                                 const BIGNUM **dmp1, const BIGNUM **dmq1,
26                                 const BIGNUM **iqmp);
27        const BIGNUM *RSA_get0_n(const RSA *d);
28        const BIGNUM *RSA_get0_e(const RSA *d);
29        const BIGNUM *RSA_get0_d(const RSA *d);
30        const BIGNUM *RSA_get0_p(const RSA *d);
31        const BIGNUM *RSA_get0_q(const RSA *d);
32        const BIGNUM *RSA_get0_dmp1(const RSA *r);
33        const BIGNUM *RSA_get0_dmq1(const RSA *r);
34        const BIGNUM *RSA_get0_iqmp(const RSA *r);
35        const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r);
36        void RSA_clear_flags(RSA *r, int flags);
37        int RSA_test_flags(const RSA *r, int flags);
38        void RSA_set_flags(RSA *r, int flags);
39        ENGINE *RSA_get0_engine(RSA *r);
40        int RSA_get_multi_prime_extra_count(const RSA *r);
41        int RSA_get0_multi_prime_factors(const RSA *r, const BIGNUM *primes[]);
42        int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[],
43                                            const BIGNUM *coeffs[]);
44        int RSA_set0_multi_prime_params(RSA *r, BIGNUM *primes[], BIGNUM *exps[],
45                                       BIGNUM *coeffs[], int pnum);
46        int RSA_get_version(RSA *r);
47

DESCRIPTION

49       An RSA object contains the components for the public and private key,
50       n, e, d, p, q, dmp1, dmq1 and iqmp.  n is the modulus common to both
51       public and private key, e is the public exponent and d is the private
52       exponent.  p, q, dmp1, dmq1 and iqmp are the factors for the second
53       representation of a private key (see PKCS#1 section 3 Key Types), where
54       p and q are the first and second factor of n and dmp1, dmq1 and iqmp
55       are the exponents and coefficient for CRT calculations.
56
57       For multi-prime RSA (defined in RFC 8017), there are also one or more
58       'triplet' in an RSA object. A triplet contains three members, r, d and
59       t. r is the additional prime besides p and q. d and t are the exponent
60       and coefficient for CRT calculations.
61
62       The n, e and d parameters can be obtained by calling RSA_get0_key().
63       If they have not been set yet, then *n, *e and *d will be set to NULL.
64       Otherwise, they are set to pointers to their respective values. These
65       point directly to the internal representations of the values and
66       therefore should not be freed by the caller.
67
68       The n, e and d parameter values can be set by calling RSA_set0_key()
69       and passing the new values for n, e and d as parameters to the
70       function.  The values n and e must be non-NULL the first time this
71       function is called on a given RSA object. The value d may be NULL. On
72       subsequent calls any of these values may be NULL which means the
73       corresponding RSA field is left untouched.  Calling this function
74       transfers the memory management of the values to the RSA object, and
75       therefore the values that have been passed in should not be freed by
76       the caller after this function has been called.
77
78       In a similar fashion, the p and q parameters can be obtained and set
79       with RSA_get0_factors() and RSA_set0_factors(), and the dmp1, dmq1 and
80       iqmp parameters can be obtained and set with RSA_get0_crt_params() and
81       RSA_set0_crt_params().
82
83       For RSA_get0_key(), RSA_get0_factors(), and RSA_get0_crt_params(), NULL
84       value BIGNUM ** output parameters are permitted. The functions ignore
85       NULL parameters but return values for other, non-NULL, parameters.
86
87       For multi-prime RSA, RSA_get0_multi_prime_factors() and
88       RSA_get0_multi_prime_params() can be used to obtain other primes and
89       related CRT parameters. The return values are stored in an array of
90       BIGNUM *. RSA_set0_multi_prime_params() sets a collect of multi-prime
91       'triplet' members (prime, exponent and coefficient) into an RSA object.
92
93       Any of the values n, e, d, p, q, dmp1, dmq1, and iqmp can also be
94       retrieved separately by the corresponding function RSA_get0_n(),
95       RSA_get0_e(), RSA_get0_d(), RSA_get0_p(), RSA_get0_q(),
96       RSA_get0_dmp1(), RSA_get0_dmq1(), and RSA_get0_iqmp(), respectively.
97
98       RSA_get0_pss_params() is used to retrieve the RSA-PSS parameters.
99
100       RSA_set_flags() sets the flags in the flags parameter on the RSA
101       object. Multiple flags can be passed in one go (bitwise ORed together).
102       Any flags that are already set are left set. RSA_test_flags() tests to
103       see whether the flags passed in the flags parameter are currently set
104       in the RSA object. Multiple flags can be tested in one go. All flags
105       that are currently set are returned, or zero if none of the flags are
106       set. RSA_clear_flags() clears the specified flags within the RSA
107       object.
108
109       RSA_get0_engine() returns a handle to the ENGINE that has been set for
110       this RSA object, or NULL if no such ENGINE has been set.
111
112       RSA_get_version() returns the version of an RSA object r.
113

NOTES

115       Values retrieved with RSA_get0_key() are owned by the RSA object used
116       in the call and may therefore not be passed to RSA_set0_key().  If
117       needed, duplicate the received value using BN_dup() and pass the
118       duplicate.  The same applies to RSA_get0_factors() and
119       RSA_set0_factors() as well as RSA_get0_crt_params() and
120       RSA_set0_crt_params().
121
122       The caller should obtain the size by calling
123       RSA_get_multi_prime_extra_count() in advance and allocate sufficient
124       buffer to store the return values before calling
125       RSA_get0_multi_prime_factors() and RSA_get0_multi_prime_params().
126
127       RSA_set0_multi_prime_params() always clears the original multi-prime
128       triplets in RSA object r and assign the new set of triplets into it.
129

RETURN VALUES

131       RSA_set0_key(), RSA_set0_factors(), RSA_set0_crt_params() and
132       RSA_set0_multi_prime_params() return 1 on success or 0 on failure.
133
134       RSA_get0_n(), RSA_get0_e(), RSA_get0_d(), RSA_get0_p(), RSA_get0_q(),
135       RSA_get0_dmp1(), RSA_get0_dmq1(), and RSA_get0_iqmp() return the
136       respective value.
137
138       RSA_get0_multi_prime_factors() and RSA_get0_multi_prime_crt_params()
139       return 1 on success or 0 on failure.
140
141       RSA_get_multi_prime_extra_count() returns two less than the number of
142       primes in use, which is 0 for traditional RSA and the number of extra
143       primes for multi-prime RSA.
144
145       RSA_get_version() returns RSA_ASN1_VERSION_MULTI for multi-prime RSA
146       and RSA_ASN1_VERSION_DEFAULT for normal two-prime RSA, as defined in
147       RFC 8017.
148
149       RSA_test_flags() returns the current state of the flags in the RSA
150       object.
151
152       RSA_get0_engine() returns the ENGINE set for the RSA object or NULL if
153       no ENGINE has been set.
154

SEE ALSO

156       RSA_new(3), RSA_size(3)
157

HISTORY

159       The RSA_get0_pss_params() function was added in OpenSSL 1.1.1e.
160
161       The RSA_get_multi_prime_extra_count(), RSA_get0_multi_prime_factors(),
162       RSA_get0_multi_prime_crt_params(), RSA_set0_multi_prime_params(), and
163       RSA_get_version() functions were added in OpenSSL 1.1.1.
164
165       Other functions described here were added in OpenSSL 1.1.0.
166
168       Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
169
170       Licensed under the OpenSSL license (the "License").  You may not use
171       this file except in compliance with the License.  You can obtain a copy
172       in the file LICENSE in the source distribution or at
173       <https://www.openssl.org/source/license.html>.
174
175
176
1771.1.1g                            2020-04-23                   RSA_GET0_KEY(3)
Impressum