1*b7274ba6Stb.\" $OpenBSD: RSA_set_method.3,v 1.18 2023/11/19 10:34:26 tb Exp $ 2860a60ecSschwarze.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 38974101aSjmc.\" 4860a60ecSschwarze.\" This file was written by Ulf Moeller <ulf@openssl.org> 5860a60ecSschwarze.\" and Geoff Thorpe <geoff@openssl.org>. 6860a60ecSschwarze.\" Copyright (c) 2000, 2002, 2007, 2014 The OpenSSL Project. 7860a60ecSschwarze.\" All rights reserved. 8860a60ecSschwarze.\" 9860a60ecSschwarze.\" Redistribution and use in source and binary forms, with or without 10860a60ecSschwarze.\" modification, are permitted provided that the following conditions 11860a60ecSschwarze.\" are met: 12860a60ecSschwarze.\" 13860a60ecSschwarze.\" 1. Redistributions of source code must retain the above copyright 14860a60ecSschwarze.\" notice, this list of conditions and the following disclaimer. 15860a60ecSschwarze.\" 16860a60ecSschwarze.\" 2. Redistributions in binary form must reproduce the above copyright 17860a60ecSschwarze.\" notice, this list of conditions and the following disclaimer in 18860a60ecSschwarze.\" the documentation and/or other materials provided with the 19860a60ecSschwarze.\" distribution. 20860a60ecSschwarze.\" 21860a60ecSschwarze.\" 3. All advertising materials mentioning features or use of this 22860a60ecSschwarze.\" software must display the following acknowledgment: 23860a60ecSschwarze.\" "This product includes software developed by the OpenSSL Project 24860a60ecSschwarze.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 25860a60ecSschwarze.\" 26860a60ecSschwarze.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 27860a60ecSschwarze.\" endorse or promote products derived from this software without 28860a60ecSschwarze.\" prior written permission. For written permission, please contact 29860a60ecSschwarze.\" openssl-core@openssl.org. 30860a60ecSschwarze.\" 31860a60ecSschwarze.\" 5. Products derived from this software may not be called "OpenSSL" 32860a60ecSschwarze.\" nor may "OpenSSL" appear in their names without prior written 33860a60ecSschwarze.\" permission of the OpenSSL Project. 34860a60ecSschwarze.\" 35860a60ecSschwarze.\" 6. Redistributions of any form whatsoever must retain the following 36860a60ecSschwarze.\" acknowledgment: 37860a60ecSschwarze.\" "This product includes software developed by the OpenSSL Project 38860a60ecSschwarze.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 39860a60ecSschwarze.\" 40860a60ecSschwarze.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 41860a60ecSschwarze.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42860a60ecSschwarze.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 43860a60ecSschwarze.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 44860a60ecSschwarze.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45860a60ecSschwarze.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46860a60ecSschwarze.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47860a60ecSschwarze.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48860a60ecSschwarze.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 49860a60ecSschwarze.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 50860a60ecSschwarze.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51860a60ecSschwarze.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52860a60ecSschwarze.\" 53*b7274ba6Stb.Dd $Mdocdate: November 19 2023 $ 5429ab75b0Sschwarze.Dt RSA_SET_METHOD 3 5529ab75b0Sschwarze.Os 5629ab75b0Sschwarze.Sh NAME 5729ab75b0Sschwarze.Nm RSA_set_default_method , 5829ab75b0Sschwarze.Nm RSA_get_default_method , 5929ab75b0Sschwarze.Nm RSA_set_method , 6029ab75b0Sschwarze.Nm RSA_get_method , 6129ab75b0Sschwarze.Nm RSA_PKCS1_SSLeay , 6229ab75b0Sschwarze.Nm RSA_flags , 63958c08b5Sschwarze.Nm RSA_new_method 6429ab75b0Sschwarze.Nd select RSA method 6529ab75b0Sschwarze.Sh SYNOPSIS 6629ab75b0Sschwarze.In openssl/rsa.h 6729ab75b0Sschwarze.Ft void 6829ab75b0Sschwarze.Fo RSA_set_default_method 6929ab75b0Sschwarze.Fa "const RSA_METHOD *meth" 7029ab75b0Sschwarze.Fc 712b2bdfa4Sschwarze.Ft const RSA_METHOD * 7229ab75b0Sschwarze.Fn RSA_get_default_method void 7329ab75b0Sschwarze.Ft int 7429ab75b0Sschwarze.Fo RSA_set_method 7529ab75b0Sschwarze.Fa "RSA *rsa" 7629ab75b0Sschwarze.Fa "const RSA_METHOD *meth" 7729ab75b0Sschwarze.Fc 782b2bdfa4Sschwarze.Ft const RSA_METHOD * 7929ab75b0Sschwarze.Fo RSA_get_method 8029ab75b0Sschwarze.Fa "const RSA *rsa" 8129ab75b0Sschwarze.Fc 822b2bdfa4Sschwarze.Ft const RSA_METHOD * 8329ab75b0Sschwarze.Fn RSA_PKCS1_SSLeay void 8429ab75b0Sschwarze.Ft int 8529ab75b0Sschwarze.Fo RSA_flags 8629ab75b0Sschwarze.Fa "const RSA *rsa" 8729ab75b0Sschwarze.Fc 8829ab75b0Sschwarze.Ft RSA * 8929ab75b0Sschwarze.Fo RSA_new_method 902b2bdfa4Sschwarze.Fa "ENGINE *engine" 9129ab75b0Sschwarze.Fc 9229ab75b0Sschwarze.Sh DESCRIPTION 9329ab75b0SschwarzeAn 9429ab75b0Sschwarze.Vt RSA_METHOD 952b2bdfa4Sschwarzeobject contains pointers to the functions used for RSA operations. 962b2bdfa4SschwarzeBy default, the internal implementation returned by 972b2bdfa4Sschwarze.Fn RSA_PKCS1_SSLeay 982b2bdfa4Sschwarzeis used. 992b2bdfa4SschwarzeBy selecting another method, alternative implementations 1002b2bdfa4Sschwarzesuch as hardware accelerators may be used. 10129ab75b0Sschwarze.Pp 10229ab75b0Sschwarze.Fn RSA_set_default_method 1032b2bdfa4Sschwarzeselects 10429ab75b0Sschwarze.Fa meth 1052b2bdfa4Sschwarzeas the default method for all 10629ab75b0Sschwarze.Vt RSA 10729ab75b0Sschwarzestructures created later. 10829ab75b0Sschwarze.Pp 10929ab75b0Sschwarze.Fn RSA_get_default_method 110*b7274ba6Stbreturns a pointer to the current default method. 11129ab75b0Sschwarze.Pp 11229ab75b0Sschwarze.Fn RSA_set_method 11329ab75b0Sschwarzeselects 11429ab75b0Sschwarze.Fa meth 11529ab75b0Sschwarzeto perform all operations using the key 11629ab75b0Sschwarze.Fa rsa . 11799647b63SschwarzeThis replaces the previous 11829ab75b0Sschwarze.Vt RSA_METHOD 11999647b63Sschwarzeused by the RSA key, calling the 12099647b63Sschwarze.Fa finish 12199647b63Sschwarzefunction set up with 12299647b63Sschwarze.Xr RSA_meth_set_finish 3 123*b7274ba6Stbif any. 12499647b63SschwarzeIf 12599647b63Sschwarze.Fa meth 12699647b63Sschwarzecontains an 12799647b63Sschwarze.Fa init 12899647b63Sschwarzefunction set up with 12999647b63Sschwarze.Xr RSA_meth_set_init 3 , 13099647b63Sschwarzethat function is called just before returning from 13199647b63Sschwarze.Fn RSA_set_method . 13299647b63Sschwarze.Pp 13329ab75b0SschwarzeIt is possible to have RSA keys that only work with certain 13429ab75b0Sschwarze.Vt RSA_METHOD 135*b7274ba6Stbimplementations, 13629ab75b0Sschwarzeand in such cases attempting to change the 13729ab75b0Sschwarze.Vt RSA_METHOD 13829ab75b0Sschwarzefor the key can have unexpected results. 13929ab75b0Sschwarze.Pp 14029ab75b0Sschwarze.Fn RSA_get_method 14129ab75b0Sschwarzereturns a pointer to the 14229ab75b0Sschwarze.Vt RSA_METHOD 14329ab75b0Sschwarzebeing used by 14429ab75b0Sschwarze.Fa rsa . 14529ab75b0Sschwarze.Pp 14699647b63SschwarzeThe misleadingly named function 14729ab75b0Sschwarze.Fn RSA_flags 14829ab75b0Sschwarzereturns the flags that are set for the current 14929ab75b0Sschwarze.Vt RSA_METHOD 15029ab75b0Sschwarzeof 15129ab75b0Sschwarze.Fa rsa . 15299647b63SschwarzeThe flags used by 15399647b63Sschwarze.Fa rsa 15499647b63Sschwarzeitself can instead be tested with 15599647b63Sschwarze.Xr RSA_test_flags 3 . 15629ab75b0SschwarzeSee the 15729ab75b0Sschwarze.Sx BUGS 15899647b63Sschwarzesection for more details. 15929ab75b0Sschwarze.Pp 16029ab75b0Sschwarze.Fn RSA_new_method 16129ab75b0Sschwarzeallocates and initializes an 16229ab75b0Sschwarze.Vt RSA 163*b7274ba6Stbstructure. 164*b7274ba6StbThe 1652b2bdfa4Sschwarze.Fa engine 166*b7274ba6Stbargument is ignored and 1672b2bdfa4Sschwarzethe default method controlled by 16829ab75b0Sschwarze.Fn RSA_set_default_method 16929ab75b0Sschwarzeis used. 17029ab75b0Sschwarze.Pp 17199647b63SschwarzeThe initial 17299647b63Sschwarze.Fa flags 17399647b63Sschwarzeare copied from the 17499647b63Sschwarze.Vt RSA_METHOD 17599647b63Sschwarzeobject used and will not be affected by later changes to that object, 17699647b63Sschwarzebut may be modified by the optional 17799647b63Sschwarze.Fa init 17899647b63Sschwarzefunction which may have been set up with 17999647b63Sschwarze.Xr RSA_meth_set_init 3 18099647b63Sschwarzeand which is called just before returning from 18199647b63Sschwarze.Fn RSA_new_method . 18229ab75b0Sschwarze.Sh RETURN VALUES 18329ab75b0Sschwarze.Fn RSA_PKCS1_SSLeay , 1842b2bdfa4Sschwarze.Fn RSA_get_default_method , 18529ab75b0Sschwarzeand 18629ab75b0Sschwarze.Fn RSA_get_method 18729ab75b0Sschwarzereturn pointers to the respective 18829ab75b0Sschwarze.Vt RSA_METHOD . 18929ab75b0Sschwarze.Pp 19029ab75b0Sschwarze.Fn RSA_set_method 1912b2bdfa4Sschwarzereturns 1 on success or 0 on failure. 1922b2bdfa4SschwarzeCurrently, it cannot fail. 19329ab75b0Sschwarze.Pp 19429ab75b0Sschwarze.Fn RSA_new_method 19529ab75b0Sschwarzereturns 19629ab75b0Sschwarze.Dv NULL 19729ab75b0Sschwarzeand sets an error code that can be obtained by 19829ab75b0Sschwarze.Xr ERR_get_error 3 19929ab75b0Sschwarzeif the allocation fails. 20029ab75b0SschwarzeOtherwise it returns a pointer to the newly allocated structure. 20129ab75b0Sschwarze.Sh SEE ALSO 20280655ea9Sschwarze.Xr RSA_meth_new 3 , 20329ab75b0Sschwarze.Xr RSA_new 3 20429ab75b0Sschwarze.Sh HISTORY 20510e00d17Sschwarze.Fn RSA_set_default_method , 20610e00d17Sschwarze.Fn RSA_PKCS1_SSLeay , 20729ab75b0Sschwarzeand 20810e00d17Sschwarze.Fn RSA_new_method 20910e00d17Sschwarzefirst appeared in SSLeay 0.8.0. 2106b430279Sschwarze.Fn RSA_flags 2116b430279Sschwarzefirst appeared in SSLeay 0.9.0. 21247ef50e0SschwarzeThese functions have been available since 21347ef50e0Sschwarze.Ox 2.4 . 21447ef50e0Sschwarze.Pp 21529ab75b0Sschwarze.Fn RSA_get_default_method , 21629ab75b0Sschwarze.Fn RSA_set_method , 21729ab75b0Sschwarzeand 21829ab75b0Sschwarze.Fn RSA_get_method 21929ab75b0Sschwarzeas well as the 22029ab75b0Sschwarze.Fa rsa_sign 22129ab75b0Sschwarzeand 22229ab75b0Sschwarze.Fa rsa_verify 22329ab75b0Sschwarzecomponents of 22429ab75b0Sschwarze.Vt RSA_METHOD 2253fe1df4aSschwarzefirst appeared in OpenSSL 0.9.4 and have been available since 2263fe1df4aSschwarze.Ox 2.6 . 22729ab75b0Sschwarze.Sh BUGS 22829ab75b0SschwarzeThe behaviour of 22929ab75b0Sschwarze.Fn RSA_flags 230b5b3773bSjmcis a misfeature that is left as-is for now to avoid creating 23129ab75b0Sschwarzecompatibility problems. 23229ab75b0SschwarzeRSA functionality, such as the encryption functions, are controlled by 23329ab75b0Sschwarzethe 23429ab75b0Sschwarze.Fa flags 23529ab75b0Sschwarzevalue in the 23629ab75b0Sschwarze.Vt RSA 23729ab75b0Sschwarzekey itself, not by the 23829ab75b0Sschwarze.Fa flags 23929ab75b0Sschwarzevalue in the 24029ab75b0Sschwarze.Vt RSA_METHOD 24129ab75b0Sschwarzeattached to the RSA key (which is what this function returns). 24229ab75b0SschwarzeIf the flags element of an 24329ab75b0Sschwarze.Vt RSA 24429ab75b0Sschwarzekey is changed, the changes will be honoured by RSA functionality 24529ab75b0Sschwarzebut will not be reflected in the return value of the 24629ab75b0Sschwarze.Fn RSA_flags 24729ab75b0Sschwarzefunction - in effect 24829ab75b0Sschwarze.Fn RSA_flags 2492181f9ceStbbehaves more like an 2502181f9ceStb.Fn RSA_default_flags 2512181f9ceStbfunction, which does not 25229ab75b0Sschwarzecurrently exist. 253