xref: /freebsd/crypto/openssl/doc/man3/RSA_private_encrypt.pod (revision 58f351825a371d1a3dd693d6f64a1245ea851a51)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5*58f35182SJung-uk KimRSA_private_encrypt, RSA_public_decrypt - low-level signature operations
6e71b7053SJung-uk Kim
7e71b7053SJung-uk Kim=head1 SYNOPSIS
8e71b7053SJung-uk Kim
9e71b7053SJung-uk Kim #include <openssl/rsa.h>
10e71b7053SJung-uk Kim
11e71b7053SJung-uk Kim int RSA_private_encrypt(int flen, unsigned char *from,
12e71b7053SJung-uk Kim                         unsigned char *to, RSA *rsa, int padding);
13e71b7053SJung-uk Kim
14e71b7053SJung-uk Kim int RSA_public_decrypt(int flen, unsigned char *from,
15e71b7053SJung-uk Kim                        unsigned char *to, RSA *rsa, int padding);
16e71b7053SJung-uk Kim
17e71b7053SJung-uk Kim=head1 DESCRIPTION
18e71b7053SJung-uk Kim
19*58f35182SJung-uk KimThese functions handle RSA signatures at a low-level.
20e71b7053SJung-uk Kim
21e71b7053SJung-uk KimRSA_private_encrypt() signs the B<flen> bytes at B<from> (usually a
22e71b7053SJung-uk Kimmessage digest with an algorithm identifier) using the private key
23e71b7053SJung-uk KimB<rsa> and stores the signature in B<to>. B<to> must point to
24e71b7053SJung-uk KimB<RSA_size(rsa)> bytes of memory.
25e71b7053SJung-uk Kim
26e71b7053SJung-uk KimB<padding> denotes one of the following modes:
27e71b7053SJung-uk Kim
28e71b7053SJung-uk Kim=over 4
29e71b7053SJung-uk Kim
30e71b7053SJung-uk Kim=item RSA_PKCS1_PADDING
31e71b7053SJung-uk Kim
32e71b7053SJung-uk KimPKCS #1 v1.5 padding. This function does not handle the
33e71b7053SJung-uk KimB<algorithmIdentifier> specified in PKCS #1. When generating or
34e71b7053SJung-uk Kimverifying PKCS #1 signatures, L<RSA_sign(3)> and L<RSA_verify(3)> should be
35e71b7053SJung-uk Kimused.
36e71b7053SJung-uk Kim
37e71b7053SJung-uk Kim=item RSA_NO_PADDING
38e71b7053SJung-uk Kim
39e71b7053SJung-uk KimRaw RSA signature. This mode should I<only> be used to implement
40e71b7053SJung-uk Kimcryptographically sound padding modes in the application code.
41e71b7053SJung-uk KimSigning user data directly with RSA is insecure.
42e71b7053SJung-uk Kim
43e71b7053SJung-uk Kim=back
44e71b7053SJung-uk Kim
45e71b7053SJung-uk KimRSA_public_decrypt() recovers the message digest from the B<flen>
46e71b7053SJung-uk Kimbytes long signature at B<from> using the signer's public key
47e71b7053SJung-uk KimB<rsa>. B<to> must point to a memory section large enough to hold the
48e71b7053SJung-uk Kimmessage digest (which is smaller than B<RSA_size(rsa) -
49e71b7053SJung-uk Kim11>). B<padding> is the padding mode that was used to sign the data.
50e71b7053SJung-uk Kim
51e71b7053SJung-uk Kim=head1 RETURN VALUES
52e71b7053SJung-uk Kim
53e71b7053SJung-uk KimRSA_private_encrypt() returns the size of the signature (i.e.,
54e71b7053SJung-uk KimRSA_size(rsa)). RSA_public_decrypt() returns the size of the
55e71b7053SJung-uk Kimrecovered message digest.
56e71b7053SJung-uk Kim
57e71b7053SJung-uk KimOn error, -1 is returned; the error codes can be
58e71b7053SJung-uk Kimobtained by L<ERR_get_error(3)>.
59e71b7053SJung-uk Kim
60e71b7053SJung-uk Kim=head1 SEE ALSO
61e71b7053SJung-uk Kim
62e71b7053SJung-uk KimL<ERR_get_error(3)>,
63e71b7053SJung-uk KimL<RSA_sign(3)>, L<RSA_verify(3)>
64e71b7053SJung-uk Kim
65e71b7053SJung-uk Kim=head1 COPYRIGHT
66e71b7053SJung-uk Kim
67*58f35182SJung-uk KimCopyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
68e71b7053SJung-uk Kim
69e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License").  You may not use
70e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
71e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
72e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
73e71b7053SJung-uk Kim
74e71b7053SJung-uk Kim=cut
75