1 | =pod
|
---|
2 |
|
---|
3 | =head1 NAME
|
---|
4 |
|
---|
5 | RSA_set_default_method, RSA_get_default_method, RSA_set_method,
|
---|
6 | RSA_get_method, RSA_PKCS1_OpenSSL, RSA_flags,
|
---|
7 | RSA_new_method - select RSA method
|
---|
8 |
|
---|
9 | =head1 SYNOPSIS
|
---|
10 |
|
---|
11 | #include <openssl/rsa.h>
|
---|
12 |
|
---|
13 | The following functions have been deprecated since OpenSSL 3.0, and can be
|
---|
14 | hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
|
---|
15 | see L<openssl_user_macros(7)>:
|
---|
16 |
|
---|
17 | void RSA_set_default_method(const RSA_METHOD *meth);
|
---|
18 |
|
---|
19 | const RSA_METHOD *RSA_get_default_method(void);
|
---|
20 |
|
---|
21 | int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
|
---|
22 |
|
---|
23 | const RSA_METHOD *RSA_get_method(const RSA *rsa);
|
---|
24 |
|
---|
25 | const RSA_METHOD *RSA_PKCS1_OpenSSL(void);
|
---|
26 |
|
---|
27 | int RSA_flags(const RSA *rsa);
|
---|
28 |
|
---|
29 | RSA *RSA_new_method(ENGINE *engine);
|
---|
30 |
|
---|
31 | =head1 DESCRIPTION
|
---|
32 |
|
---|
33 | All of the functions described on this page are deprecated.
|
---|
34 | Applications should instead use the OSSL_PROVIDER APIs.
|
---|
35 |
|
---|
36 | An B<RSA_METHOD> specifies the functions that OpenSSL uses for RSA
|
---|
37 | operations. By modifying the method, alternative implementations such as
|
---|
38 | hardware accelerators may be used. IMPORTANT: See the NOTES section for
|
---|
39 | important information about how these RSA API functions are affected by the
|
---|
40 | use of B<ENGINE> API calls.
|
---|
41 |
|
---|
42 | Initially, the default RSA_METHOD is the OpenSSL internal implementation,
|
---|
43 | as returned by RSA_PKCS1_OpenSSL().
|
---|
44 |
|
---|
45 | RSA_set_default_method() makes B<meth> the default method for all RSA
|
---|
46 | structures created later.
|
---|
47 | B<NB>: This is true only whilst no ENGINE has
|
---|
48 | been set as a default for RSA, so this function is no longer recommended.
|
---|
49 | This function is not thread-safe and should not be called at the same time
|
---|
50 | as other OpenSSL functions.
|
---|
51 |
|
---|
52 | RSA_get_default_method() returns a pointer to the current default
|
---|
53 | RSA_METHOD. However, the meaningfulness of this result is dependent on
|
---|
54 | whether the ENGINE API is being used, so this function is no longer
|
---|
55 | recommended.
|
---|
56 |
|
---|
57 | RSA_set_method() selects B<meth> to perform all operations using the key
|
---|
58 | B<rsa>. This will replace the RSA_METHOD used by the RSA key and if the
|
---|
59 | previous method was supplied by an ENGINE, the handle to that ENGINE will
|
---|
60 | be released during the change. It is possible to have RSA keys that only
|
---|
61 | work with certain RSA_METHOD implementations (e.g. from an ENGINE module
|
---|
62 | that supports embedded hardware-protected keys), and in such cases
|
---|
63 | attempting to change the RSA_METHOD for the key can have unexpected
|
---|
64 | results.
|
---|
65 |
|
---|
66 | RSA_get_method() returns a pointer to the RSA_METHOD being used by B<rsa>.
|
---|
67 | This method may or may not be supplied by an ENGINE implementation, but if
|
---|
68 | it is, the return value can only be guaranteed to be valid as long as the
|
---|
69 | RSA key itself is valid and does not have its implementation changed by
|
---|
70 | RSA_set_method().
|
---|
71 |
|
---|
72 | RSA_flags() returns the B<flags> that are set for B<rsa>'s current
|
---|
73 | RSA_METHOD. See the BUGS section.
|
---|
74 |
|
---|
75 | RSA_new_method() allocates and initializes an RSA structure so that
|
---|
76 | B<engine> will be used for the RSA operations. If B<engine> is NULL, the
|
---|
77 | default ENGINE for RSA operations is used, and if no default ENGINE is set,
|
---|
78 | the RSA_METHOD controlled by RSA_set_default_method() is used.
|
---|
79 |
|
---|
80 | RSA_flags() returns the B<flags> that are set for B<rsa>'s current method.
|
---|
81 |
|
---|
82 | RSA_new_method() allocates and initializes an B<RSA> structure so that
|
---|
83 | B<method> will be used for the RSA operations. If B<method> is B<NULL>,
|
---|
84 | the default method is used.
|
---|
85 |
|
---|
86 | =head1 THE RSA_METHOD STRUCTURE
|
---|
87 |
|
---|
88 | typedef struct rsa_meth_st
|
---|
89 | {
|
---|
90 | /* name of the implementation */
|
---|
91 | const char *name;
|
---|
92 |
|
---|
93 | /* encrypt */
|
---|
94 | int (*rsa_pub_enc)(int flen, unsigned char *from,
|
---|
95 | unsigned char *to, RSA *rsa, int padding);
|
---|
96 |
|
---|
97 | /* verify arbitrary data */
|
---|
98 | int (*rsa_pub_dec)(int flen, unsigned char *from,
|
---|
99 | unsigned char *to, RSA *rsa, int padding);
|
---|
100 |
|
---|
101 | /* sign arbitrary data */
|
---|
102 | int (*rsa_priv_enc)(int flen, unsigned char *from,
|
---|
103 | unsigned char *to, RSA *rsa, int padding);
|
---|
104 |
|
---|
105 | /* decrypt */
|
---|
106 | int (*rsa_priv_dec)(int flen, unsigned char *from,
|
---|
107 | unsigned char *to, RSA *rsa, int padding);
|
---|
108 |
|
---|
109 | /* compute r0 = r0 ^ I mod rsa->n (May be NULL for some implementations) */
|
---|
110 | int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa);
|
---|
111 |
|
---|
112 | /* compute r = a ^ p mod m (May be NULL for some implementations) */
|
---|
113 | int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
|
---|
114 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
---|
115 |
|
---|
116 | /* called at RSA_new */
|
---|
117 | int (*init)(RSA *rsa);
|
---|
118 |
|
---|
119 | /* called at RSA_free */
|
---|
120 | int (*finish)(RSA *rsa);
|
---|
121 |
|
---|
122 | /*
|
---|
123 | * RSA_FLAG_EXT_PKEY - rsa_mod_exp is called for private key
|
---|
124 | * operations, even if p,q,dmp1,dmq1,iqmp
|
---|
125 | * are NULL
|
---|
126 | * RSA_METHOD_FLAG_NO_CHECK - don't check pub/private match
|
---|
127 | */
|
---|
128 | int flags;
|
---|
129 |
|
---|
130 | char *app_data; /* ?? */
|
---|
131 |
|
---|
132 | int (*rsa_sign)(int type,
|
---|
133 | const unsigned char *m, unsigned int m_length,
|
---|
134 | unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
|
---|
135 | int (*rsa_verify)(int dtype,
|
---|
136 | const unsigned char *m, unsigned int m_length,
|
---|
137 | const unsigned char *sigbuf, unsigned int siglen,
|
---|
138 | const RSA *rsa);
|
---|
139 | /* keygen. If NULL built-in RSA key generation will be used */
|
---|
140 | int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
|
---|
141 |
|
---|
142 | } RSA_METHOD;
|
---|
143 |
|
---|
144 | =head1 RETURN VALUES
|
---|
145 |
|
---|
146 | RSA_PKCS1_OpenSSL(), RSA_PKCS1_null_method(), RSA_get_default_method()
|
---|
147 | and RSA_get_method() return pointers to the respective RSA_METHODs.
|
---|
148 |
|
---|
149 | RSA_set_default_method() returns no value.
|
---|
150 |
|
---|
151 | RSA_set_method() returns a pointer to the old RSA_METHOD implementation
|
---|
152 | that was replaced. However, this return value should probably be ignored
|
---|
153 | because if it was supplied by an ENGINE, the pointer could be invalidated
|
---|
154 | at any time if the ENGINE is unloaded (in fact it could be unloaded as a
|
---|
155 | result of the RSA_set_method() function releasing its handle to the
|
---|
156 | ENGINE). For this reason, the return type may be replaced with a B<void>
|
---|
157 | declaration in a future release.
|
---|
158 |
|
---|
159 | RSA_new_method() returns NULL and sets an error code that can be obtained
|
---|
160 | by L<ERR_get_error(3)> if the allocation fails. Otherwise
|
---|
161 | it returns a pointer to the newly allocated structure.
|
---|
162 |
|
---|
163 | =head1 BUGS
|
---|
164 |
|
---|
165 | The behaviour of RSA_flags() is a mis-feature that is left as-is for now
|
---|
166 | to avoid creating compatibility problems. RSA functionality, such as the
|
---|
167 | encryption functions, are controlled by the B<flags> value in the RSA key
|
---|
168 | itself, not by the B<flags> value in the RSA_METHOD attached to the RSA key
|
---|
169 | (which is what this function returns). If the flags element of an RSA key
|
---|
170 | is changed, the changes will be honoured by RSA functionality but will not
|
---|
171 | be reflected in the return value of the RSA_flags() function - in effect
|
---|
172 | RSA_flags() behaves more like an RSA_default_flags() function (which does
|
---|
173 | not currently exist).
|
---|
174 |
|
---|
175 | =head1 SEE ALSO
|
---|
176 |
|
---|
177 | L<RSA_new(3)>
|
---|
178 |
|
---|
179 | =head1 HISTORY
|
---|
180 |
|
---|
181 | All of these functions were deprecated in OpenSSL 3.0.
|
---|
182 |
|
---|
183 | The RSA_null_method(), which was a partial attempt to avoid patent issues,
|
---|
184 | was replaced to always return NULL in OpenSSL 1.1.1.
|
---|
185 |
|
---|
186 | =head1 COPYRIGHT
|
---|
187 |
|
---|
188 | Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
|
---|
189 |
|
---|
190 | Licensed under the Apache License 2.0 (the "License"). You may not use
|
---|
191 | this file except in compliance with the License. You can obtain a copy
|
---|
192 | in the file LICENSE in the source distribution or at
|
---|
193 | L<https://www.openssl.org/source/license.html>.
|
---|
194 |
|
---|
195 | =cut
|
---|