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_clear_flags, RSA_test_flags, RSA_set_flags,
10       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        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

DESCRIPTION

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

NOTES

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

RETURN VALUES

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

SEE ALSO

153       RSA_new(3), RSA_size(3)
154

HISTORY

156       The RSA_get_multi_prime_extra_count(), RSA_get0_multi_prime_factors(),
157       RSA_get0_multi_prime_crt_params(), RSA_set0_multi_prime_params(), and
158       RSA_get_version() functions were added in OpenSSL 1.1.1.
159
160       Other functions described here were added in OpenSSL 1.1.0.
161
163       Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
164
165       Licensed under the OpenSSL license (the "License").  You may not use
166       this file except in compliance with the License.  You can obtain a copy
167       in the file LICENSE in the source distribution or at
168       <https://www.openssl.org/source/license.html>.
169
170
171
1721.1.1c                            2019-05-28                   RSA_GET0_KEY(3)
Impressum