xref: /netbsd-src/crypto/external/bsd/openssl/dist/doc/man3/RSA_private_encrypt.pod (revision b0d1725196a7921d003d2c66a14f186abda4176b)
113d40330Schristos=pod
213d40330Schristos
313d40330Schristos=head1 NAME
413d40330Schristos
5f30e0929SchristosRSA_private_encrypt, RSA_public_decrypt - low-level signature operations
613d40330Schristos
713d40330Schristos=head1 SYNOPSIS
813d40330Schristos
913d40330Schristos #include <openssl/rsa.h>
1013d40330Schristos
11*b0d17251SchristosThe following functions have been deprecated since OpenSSL 3.0, and can be
12*b0d17251Schristoshidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
13*b0d17251Schristossee L<openssl_user_macros(7)>:
14*b0d17251Schristos
1513d40330Schristos int RSA_private_encrypt(int flen, unsigned char *from,
1613d40330Schristos                         unsigned char *to, RSA *rsa, int padding);
1713d40330Schristos
1813d40330Schristos int RSA_public_decrypt(int flen, unsigned char *from,
1913d40330Schristos                        unsigned char *to, RSA *rsa, int padding);
2013d40330Schristos
2113d40330Schristos=head1 DESCRIPTION
2213d40330Schristos
23*b0d17251SchristosBoth of the functions described on this page are deprecated.
24*b0d17251SchristosApplications should instead use L<EVP_PKEY_sign_init_ex(3)>,
25*b0d17251SchristosL<EVP_PKEY_sign(3)>, L<EVP_PKEY_verify_recover_init(3)>, and
26*b0d17251SchristosL<EVP_PKEY_verify_recover(3)>.
27*b0d17251Schristos
28f30e0929SchristosThese functions handle RSA signatures at a low-level.
2913d40330Schristos
3013d40330SchristosRSA_private_encrypt() signs the B<flen> bytes at B<from> (usually a
3113d40330Schristosmessage digest with an algorithm identifier) using the private key
3213d40330SchristosB<rsa> and stores the signature in B<to>. B<to> must point to
3313d40330SchristosB<RSA_size(rsa)> bytes of memory.
3413d40330Schristos
3513d40330SchristosB<padding> denotes one of the following modes:
3613d40330Schristos
3713d40330Schristos=over 4
3813d40330Schristos
3913d40330Schristos=item RSA_PKCS1_PADDING
4013d40330Schristos
4113d40330SchristosPKCS #1 v1.5 padding. This function does not handle the
4213d40330SchristosB<algorithmIdentifier> specified in PKCS #1. When generating or
4313d40330Schristosverifying PKCS #1 signatures, L<RSA_sign(3)> and L<RSA_verify(3)> should be
4413d40330Schristosused.
4513d40330Schristos
4613d40330Schristos=item RSA_NO_PADDING
4713d40330Schristos
4813d40330SchristosRaw RSA signature. This mode should I<only> be used to implement
4913d40330Schristoscryptographically sound padding modes in the application code.
5013d40330SchristosSigning user data directly with RSA is insecure.
5113d40330Schristos
5213d40330Schristos=back
5313d40330Schristos
5413d40330SchristosRSA_public_decrypt() recovers the message digest from the B<flen>
5513d40330Schristosbytes long signature at B<from> using the signer's public key
5613d40330SchristosB<rsa>. B<to> must point to a memory section large enough to hold the
5713d40330Schristosmessage digest (which is smaller than B<RSA_size(rsa) -
5813d40330Schristos11>). B<padding> is the padding mode that was used to sign the data.
5913d40330Schristos
6013d40330Schristos=head1 RETURN VALUES
6113d40330Schristos
6213d40330SchristosRSA_private_encrypt() returns the size of the signature (i.e.,
6313d40330SchristosRSA_size(rsa)). RSA_public_decrypt() returns the size of the
6413d40330Schristosrecovered message digest.
6513d40330Schristos
6613d40330SchristosOn error, -1 is returned; the error codes can be
6713d40330Schristosobtained by L<ERR_get_error(3)>.
6813d40330Schristos
6913d40330Schristos=head1 SEE ALSO
7013d40330Schristos
7113d40330SchristosL<ERR_get_error(3)>,
72*b0d17251SchristosL<RSA_sign(3)>, L<RSA_verify(3)>,
73*b0d17251SchristosL<EVP_PKEY_sign(3)>, L<EVP_PKEY_verify_recover(3)>
74*b0d17251Schristos
75*b0d17251Schristos=head1 HISTORY
76*b0d17251Schristos
77*b0d17251SchristosBoth of these functions were deprecated in OpenSSL 3.0.
7813d40330Schristos
7913d40330Schristos=head1 COPYRIGHT
8013d40330Schristos
81*b0d17251SchristosCopyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
8213d40330Schristos
83*b0d17251SchristosLicensed under the Apache License 2.0 (the "License").  You may not use
8413d40330Schristosthis file except in compliance with the License.  You can obtain a copy
8513d40330Schristosin the file LICENSE in the source distribution or at
8613d40330SchristosL<https://www.openssl.org/source/license.html>.
8713d40330Schristos
8813d40330Schristos=cut
89