diff options
Diffstat (limited to 'src/lib/libcrypto/man/RSA_set_method.3')
| -rw-r--r-- | src/lib/libcrypto/man/RSA_set_method.3 | 339 |
1 files changed, 339 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/RSA_set_method.3 b/src/lib/libcrypto/man/RSA_set_method.3 new file mode 100644 index 0000000000..d7a2756b70 --- /dev/null +++ b/src/lib/libcrypto/man/RSA_set_method.3 | |||
| @@ -0,0 +1,339 @@ | |||
| 1 | .Dd $Mdocdate: November 4 2016 $ | ||
| 2 | .Dt RSA_SET_METHOD 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm RSA_set_default_method , | ||
| 6 | .Nm RSA_get_default_method , | ||
| 7 | .Nm RSA_set_method , | ||
| 8 | .Nm RSA_get_method , | ||
| 9 | .Nm RSA_PKCS1_SSLeay , | ||
| 10 | .Nm RSA_null_method , | ||
| 11 | .Nm RSA_flags , | ||
| 12 | .Nm RSA_new_method , | ||
| 13 | .Nm RSA_get_default_openssl_method , | ||
| 14 | .Nm RSA_set_default_openssl_method | ||
| 15 | .Nd select RSA method | ||
| 16 | .Sh SYNOPSIS | ||
| 17 | .In openssl/rsa.h | ||
| 18 | .Ft void | ||
| 19 | .Fo RSA_set_default_method | ||
| 20 | .Fa "const RSA_METHOD *meth" | ||
| 21 | .Fc | ||
| 22 | .Ft RSA_METHOD * | ||
| 23 | .Fn RSA_get_default_method void | ||
| 24 | .Ft int | ||
| 25 | .Fo RSA_set_method | ||
| 26 | .Fa "RSA *rsa" | ||
| 27 | .Fa "const RSA_METHOD *meth" | ||
| 28 | .Fc | ||
| 29 | .Ft RSA_METHOD * | ||
| 30 | .Fo RSA_get_method | ||
| 31 | .Fa "const RSA *rsa" | ||
| 32 | .Fc | ||
| 33 | .Ft RSA_METHOD * | ||
| 34 | .Fn RSA_PKCS1_SSLeay void | ||
| 35 | .Ft RSA_METHOD * | ||
| 36 | .Fn RSA_null_method void | ||
| 37 | .Ft int | ||
| 38 | .Fo RSA_flags | ||
| 39 | .Fa "const RSA *rsa" | ||
| 40 | .Fc | ||
| 41 | .Ft RSA * | ||
| 42 | .Fo RSA_new_method | ||
| 43 | .Fa "RSA_METHOD *meth" | ||
| 44 | .Fc | ||
| 45 | .Sh DESCRIPTION | ||
| 46 | An | ||
| 47 | .Vt RSA_METHOD | ||
| 48 | specifies the functions that OpenSSL uses for RSA operations. | ||
| 49 | By modifying the method, alternative implementations such as hardware | ||
| 50 | accelerators may be used. | ||
| 51 | See the | ||
| 52 | .Sx CAVEATS | ||
| 53 | section for how these RSA API functions are affected by the use of | ||
| 54 | .Xr engine 3 | ||
| 55 | API calls. | ||
| 56 | .Pp | ||
| 57 | Initially, the default | ||
| 58 | .Vt RSA_METHOD | ||
| 59 | is the OpenSSL internal implementation, as returned by | ||
| 60 | .Fn RSA_PKCS1_SSLeay . | ||
| 61 | .Pp | ||
| 62 | .Fn RSA_set_default_method | ||
| 63 | makes | ||
| 64 | .Fa meth | ||
| 65 | the default method for all | ||
| 66 | .Vt RSA | ||
| 67 | structures created later. | ||
| 68 | .Sy NB : | ||
| 69 | This is true only whilst no | ||
| 70 | .Vt ENGINE | ||
| 71 | has been set as a default for RSA, so this function is no longer | ||
| 72 | recommended. | ||
| 73 | .Pp | ||
| 74 | .Fn RSA_get_default_method | ||
| 75 | returns a pointer to the current default | ||
| 76 | .Vt RSA_METHOD . | ||
| 77 | However, the meaningfulness of this result is dependent on whether | ||
| 78 | the | ||
| 79 | .Xr engine 3 | ||
| 80 | API is being used, so this function is no longer recommended. | ||
| 81 | .Pp | ||
| 82 | .Fn RSA_set_method | ||
| 83 | selects | ||
| 84 | .Fa meth | ||
| 85 | to perform all operations using the key | ||
| 86 | .Fa rsa . | ||
| 87 | This will replace the | ||
| 88 | .Vt RSA_METHOD | ||
| 89 | used by the RSA key, and if the previous method was supplied by an | ||
| 90 | .Vt ENGINE , | ||
| 91 | the handle to that | ||
| 92 | .Vt ENGINE | ||
| 93 | will be released during the change. | ||
| 94 | It is possible to have RSA keys that only work with certain | ||
| 95 | .Vt RSA_METHOD | ||
| 96 | implementations (eg. from an | ||
| 97 | .Vt ENGINE | ||
| 98 | module that supports embedded hardware-protected keys), | ||
| 99 | and in such cases attempting to change the | ||
| 100 | .Vt RSA_METHOD | ||
| 101 | for the key can have unexpected results. | ||
| 102 | .Pp | ||
| 103 | .Fn RSA_get_method | ||
| 104 | returns a pointer to the | ||
| 105 | .Vt RSA_METHOD | ||
| 106 | being used by | ||
| 107 | .Fa rsa . | ||
| 108 | This method may or may not be supplied by an | ||
| 109 | .Vt ENGINE | ||
| 110 | implementation, but if it is, the return value can only be guaranteed | ||
| 111 | to be valid as long as the RSA key itself is valid and does not | ||
| 112 | have its implementation changed by | ||
| 113 | .Fn RSA_set_method . | ||
| 114 | .Pp | ||
| 115 | .Fn RSA_flags | ||
| 116 | returns the flags that are set for the current | ||
| 117 | .Vt RSA_METHOD | ||
| 118 | of | ||
| 119 | .Fa rsa . | ||
| 120 | See the | ||
| 121 | .Sx BUGS | ||
| 122 | section. | ||
| 123 | .Pp | ||
| 124 | .Fn RSA_new_method | ||
| 125 | allocates and initializes an | ||
| 126 | .Vt RSA | ||
| 127 | structure so that | ||
| 128 | .Fa meth | ||
| 129 | will be used for the RSA operations. | ||
| 130 | If | ||
| 131 | .Sy engine | ||
| 132 | is NULL, the default ENGINE for RSA operations is used, and if no | ||
| 133 | default ENGINE is set, the RSA_METHOD controlled by | ||
| 134 | .Fn RSA_set_default_method | ||
| 135 | is used. | ||
| 136 | .Pp | ||
| 137 | .Fn RSA_flags | ||
| 138 | returns the | ||
| 139 | .Sy flags | ||
| 140 | that are set for | ||
| 141 | .Fa rsa Ns 's | ||
| 142 | current method. | ||
| 143 | .Pp | ||
| 144 | .Fn RSA_new_method | ||
| 145 | allocates and initializes an | ||
| 146 | .Vt RSA | ||
| 147 | structure so that | ||
| 148 | .Fa meth | ||
| 149 | will be used for the RSA operations. | ||
| 150 | If | ||
| 151 | .Fa meth | ||
| 152 | is | ||
| 153 | .Dv NULL , | ||
| 154 | the default method is used. | ||
| 155 | .Sh THE RSA_METHOD STRUCTURE | ||
| 156 | .Bd -literal | ||
| 157 | typedef struct rsa_meth_st | ||
| 158 | { | ||
| 159 | /* name of the implementation */ | ||
| 160 | const char *name; | ||
| 161 | |||
| 162 | /* encrypt */ | ||
| 163 | int (*rsa_pub_enc)(int flen, unsigned char *from, | ||
| 164 | unsigned char *to, RSA *rsa, int padding); | ||
| 165 | |||
| 166 | /* verify arbitrary data */ | ||
| 167 | int (*rsa_pub_dec)(int flen, unsigned char *from, | ||
| 168 | unsigned char *to, RSA *rsa, int padding); | ||
| 169 | |||
| 170 | /* sign arbitrary data */ | ||
| 171 | int (*rsa_priv_enc)(int flen, unsigned char *from, | ||
| 172 | unsigned char *to, RSA *rsa, int padding); | ||
| 173 | |||
| 174 | /* decrypt */ | ||
| 175 | int (*rsa_priv_dec)(int flen, unsigned char *from, | ||
| 176 | unsigned char *to, RSA *rsa, int padding); | ||
| 177 | |||
| 178 | /* compute r0 = r0 ^ I mod rsa->n (May be NULL for some | ||
| 179 | implementations) */ | ||
| 180 | int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa); | ||
| 181 | |||
| 182 | /* compute r = a ^ p mod m (May be NULL for some implementations) */ | ||
| 183 | int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p, | ||
| 184 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | ||
| 185 | |||
| 186 | /* called at RSA_new */ | ||
| 187 | int (*init)(RSA *rsa); | ||
| 188 | |||
| 189 | /* called at RSA_free */ | ||
| 190 | int (*finish)(RSA *rsa); | ||
| 191 | |||
| 192 | /* RSA_FLAG_EXT_PKEY - rsa_mod_exp is called for private key | ||
| 193 | * operations, even if p,q,dmp1,dmq1,iqmp | ||
| 194 | * are NULL | ||
| 195 | * RSA_FLAG_SIGN_VER - enable rsa_sign and rsa_verify | ||
| 196 | * RSA_METHOD_FLAG_NO_CHECK - don't check pub/private match | ||
| 197 | */ | ||
| 198 | int flags; | ||
| 199 | |||
| 200 | char *app_data; /* ?? */ | ||
| 201 | |||
| 202 | /* sign. For backward compatibility, this is used only | ||
| 203 | * if (flags & RSA_FLAG_SIGN_VER) | ||
| 204 | */ | ||
| 205 | int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len, | ||
| 206 | unsigned char *sigret, unsigned int *siglen, RSA *rsa); | ||
| 207 | |||
| 208 | /* verify. For backward compatibility, this is used only | ||
| 209 | * if (flags & RSA_FLAG_SIGN_VER) | ||
| 210 | */ | ||
| 211 | int (*rsa_verify)(int type, unsigned char *m, unsigned int m_len, | ||
| 212 | unsigned char *sigbuf, unsigned int siglen, RSA *rsa); | ||
| 213 | |||
| 214 | } RSA_METHOD; | ||
| 215 | .Ed | ||
| 216 | .Sh RETURN VALUES | ||
| 217 | .Fn RSA_PKCS1_SSLeay , | ||
| 218 | .Fn RSA_null_method , | ||
| 219 | .Fn RSA_get_default_method | ||
| 220 | and | ||
| 221 | .Fn RSA_get_method | ||
| 222 | return pointers to the respective | ||
| 223 | .Vt RSA_METHOD . | ||
| 224 | .Pp | ||
| 225 | .Fn RSA_set_method | ||
| 226 | returns a pointer to the old | ||
| 227 | .Vt RSA_METHOD | ||
| 228 | implementation that was replaced. | ||
| 229 | However, this return value should probably be ignored because if it was | ||
| 230 | supplied by an | ||
| 231 | .Vt ENGINE , | ||
| 232 | the pointer could be invalidated at any time if the | ||
| 233 | .Vt ENGINE | ||
| 234 | is unloaded. | ||
| 235 | In fact, it could be unloaded as a result of the | ||
| 236 | .Fn RSA_set_method | ||
| 237 | function releasing its handle to the | ||
| 238 | .Vt ENGINE . | ||
| 239 | For this reason, the return type may be replaced with a | ||
| 240 | .Vt void | ||
| 241 | declaration in a future release. | ||
| 242 | .Pp | ||
| 243 | .Fn RSA_new_method | ||
| 244 | returns | ||
| 245 | .Dv NULL | ||
| 246 | and sets an error code that can be obtained by | ||
| 247 | .Xr ERR_get_error 3 | ||
| 248 | if the allocation fails. | ||
| 249 | Otherwise it returns a pointer to the newly allocated structure. | ||
| 250 | .Sh SEE ALSO | ||
| 251 | .Xr rsa 3 , | ||
| 252 | .Xr RSA_new 3 | ||
| 253 | .Sh HISTORY | ||
| 254 | .Fn RSA_new_method | ||
| 255 | and | ||
| 256 | .Fn RSA_set_default_method | ||
| 257 | appeared in SSLeay 0.8. | ||
| 258 | .Fn RSA_get_default_method , | ||
| 259 | .Fn RSA_set_method , | ||
| 260 | and | ||
| 261 | .Fn RSA_get_method | ||
| 262 | as well as the | ||
| 263 | .Fa rsa_sign | ||
| 264 | and | ||
| 265 | .Fa rsa_verify | ||
| 266 | components of | ||
| 267 | .Vt RSA_METHOD | ||
| 268 | were added in OpenSSL 0.9.4. | ||
| 269 | .Pp | ||
| 270 | .Fn RSA_set_default_openssl_method | ||
| 271 | and | ||
| 272 | .Fn RSA_get_default_openssl_method | ||
| 273 | replaced | ||
| 274 | .Fn RSA_set_default_method | ||
| 275 | and | ||
| 276 | .Fn RSA_get_default_method | ||
| 277 | respectively, and | ||
| 278 | .Fn RSA_set_method | ||
| 279 | and | ||
| 280 | .Fn RSA_new_method | ||
| 281 | were altered to use | ||
| 282 | .Vt ENGINE Ns s | ||
| 283 | rather than | ||
| 284 | .Vt RSA_METHOD Ns s | ||
| 285 | during development of the | ||
| 286 | .Xr engine 3 | ||
| 287 | version of OpenSSL 0.9.6. | ||
| 288 | For 0.9.7, the handling of defaults in the | ||
| 289 | .Xr engine 3 | ||
| 290 | API was restructured so that this change was reversed, and behaviour | ||
| 291 | of the other functions resembled more closely the previous behaviour. | ||
| 292 | The behaviour of defaults in the | ||
| 293 | .Xr engine 3 | ||
| 294 | API now transparently overrides the behaviour of defaults in the | ||
| 295 | RSA API without requiring changing these function prototypes. | ||
| 296 | .Sh CAVEATS | ||
| 297 | As of version 0.9.7, | ||
| 298 | .Vt RSA_METHOD | ||
| 299 | implementations are grouped together with other algorithmic APIs (eg.\& | ||
| 300 | .Vt DSA_METHOD , | ||
| 301 | .Vt EVP_CIPHER , | ||
| 302 | etc.) into | ||
| 303 | .Vt ENGINE | ||
| 304 | modules. | ||
| 305 | If a default | ||
| 306 | .Vt ENGINE | ||
| 307 | is specified for RSA functionality using an | ||
| 308 | .Xr engine 3 | ||
| 309 | API function, that will override any RSA defaults set using the RSA | ||
| 310 | API, ie.\& | ||
| 311 | .Fn RSA_set_default_method . | ||
| 312 | For this reason, the | ||
| 313 | .Xr engine 3 | ||
| 314 | API is the recommended way to control default implementations for | ||
| 315 | use in RSA and other cryptographic algorithms. | ||
| 316 | .Sh BUGS | ||
| 317 | The behaviour of | ||
| 318 | .Fn RSA_flags | ||
| 319 | is a mis-feature that is left as-is for now to avoid creating | ||
| 320 | compatibility problems. | ||
| 321 | RSA functionality, such as the encryption functions, are controlled by | ||
| 322 | the | ||
| 323 | .Fa flags | ||
| 324 | value in the | ||
| 325 | .Vt RSA | ||
| 326 | key itself, not by the | ||
| 327 | .Fa flags | ||
| 328 | value in the | ||
| 329 | .Vt RSA_METHOD | ||
| 330 | attached to the RSA key (which is what this function returns). | ||
| 331 | If the flags element of an | ||
| 332 | .Vt RSA | ||
| 333 | key is changed, the changes will be honoured by RSA functionality | ||
| 334 | but will not be reflected in the return value of the | ||
| 335 | .Fn RSA_flags | ||
| 336 | function - in effect | ||
| 337 | .Fn RSA_flags | ||
| 338 | behaves more like a RSA_default_flags() function, which does not | ||
| 339 | currently exist. | ||
