1*2175Sjp161948=pod 2*2175Sjp161948 3*2175Sjp161948=head1 NAME 4*2175Sjp161948 5*2175Sjp161948RSA_private_encrypt, RSA_public_decrypt - low level signature operations 6*2175Sjp161948 7*2175Sjp161948=head1 SYNOPSIS 8*2175Sjp161948 9*2175Sjp161948 #include <openssl/rsa.h> 10*2175Sjp161948 11*2175Sjp161948 int RSA_private_encrypt(int flen, unsigned char *from, 12*2175Sjp161948 unsigned char *to, RSA *rsa, int padding); 13*2175Sjp161948 14*2175Sjp161948 int RSA_public_decrypt(int flen, unsigned char *from, 15*2175Sjp161948 unsigned char *to, RSA *rsa, int padding); 16*2175Sjp161948 17*2175Sjp161948=head1 DESCRIPTION 18*2175Sjp161948 19*2175Sjp161948These functions handle RSA signatures at a low level. 20*2175Sjp161948 21*2175Sjp161948RSA_private_encrypt() signs the B<flen> bytes at B<from> (usually a 22*2175Sjp161948message digest with an algorithm identifier) using the private key 23*2175Sjp161948B<rsa> and stores the signature in B<to>. B<to> must point to 24*2175Sjp161948B<RSA_size(rsa)> bytes of memory. 25*2175Sjp161948 26*2175Sjp161948B<padding> denotes one of the following modes: 27*2175Sjp161948 28*2175Sjp161948=over 4 29*2175Sjp161948 30*2175Sjp161948=item RSA_PKCS1_PADDING 31*2175Sjp161948 32*2175Sjp161948PKCS #1 v1.5 padding. This function does not handle the 33*2175Sjp161948B<algorithmIdentifier> specified in PKCS #1. When generating or 34*2175Sjp161948verifying PKCS #1 signatures, L<RSA_sign(3)|RSA_sign(3)> and L<RSA_verify(3)|RSA_verify(3)> should be 35*2175Sjp161948used. 36*2175Sjp161948 37*2175Sjp161948=item RSA_NO_PADDING 38*2175Sjp161948 39*2175Sjp161948Raw RSA signature. This mode should I<only> be used to implement 40*2175Sjp161948cryptographically sound padding modes in the application code. 41*2175Sjp161948Signing user data directly with RSA is insecure. 42*2175Sjp161948 43*2175Sjp161948=back 44*2175Sjp161948 45*2175Sjp161948RSA_public_decrypt() recovers the message digest from the B<flen> 46*2175Sjp161948bytes long signature at B<from> using the signer's public key 47*2175Sjp161948B<rsa>. B<to> must point to a memory section large enough to hold the 48*2175Sjp161948message digest (which is smaller than B<RSA_size(rsa) - 49*2175Sjp16194811>). B<padding> is the padding mode that was used to sign the data. 50*2175Sjp161948 51*2175Sjp161948=head1 RETURN VALUES 52*2175Sjp161948 53*2175Sjp161948RSA_private_encrypt() returns the size of the signature (i.e., 54*2175Sjp161948RSA_size(rsa)). RSA_public_decrypt() returns the size of the 55*2175Sjp161948recovered message digest. 56*2175Sjp161948 57*2175Sjp161948On error, -1 is returned; the error codes can be 58*2175Sjp161948obtained by L<ERR_get_error(3)|ERR_get_error(3)>. 59*2175Sjp161948 60*2175Sjp161948=head1 SEE ALSO 61*2175Sjp161948 62*2175Sjp161948L<ERR_get_error(3)|ERR_get_error(3)>, L<rsa(3)|rsa(3)>, 63*2175Sjp161948L<RSA_sign(3)|RSA_sign(3)>, L<RSA_verify(3)|RSA_verify(3)> 64*2175Sjp161948 65*2175Sjp161948=head1 HISTORY 66*2175Sjp161948 67*2175Sjp161948The B<padding> argument was added in SSLeay 0.8. RSA_NO_PADDING is 68*2175Sjp161948available since SSLeay 0.9.0. 69*2175Sjp161948 70*2175Sjp161948=cut 71