HEX
Server: nginx/1.28.3
System: Linux ip-172-31-12-242 6.17.0-1007-aws #7~24.04.1-Ubuntu SMP Thu Jan 22 21:04:49 UTC 2026 x86_64
User: root (0)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: //usr/local/openssl/man/man3/RSA_private_decrypt.3
.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "RSA_public_encrypt 3"
.TH RSA_public_encrypt 3 2019-12-20 1.0.2u OpenSSL
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
RSA_public_encrypt, RSA_private_decrypt \- RSA public key cryptography
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 1
\& #include <openssl/rsa.h>
\&
\& int RSA_public_encrypt(int flen, const unsigned char *from,
\&    unsigned char *to, RSA *rsa, int padding);
\&
\& int RSA_private_decrypt(int flen, const unsigned char *from,
\&     unsigned char *to, RSA *rsa, int padding);
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
\&\fBRSA_public_encrypt()\fR encrypts the \fBflen\fR bytes at \fBfrom\fR (usually a
session key) using the public key \fBrsa\fR and stores the ciphertext in
\&\fBto\fR. \fBto\fR must point to RSA_size(\fBrsa\fR) bytes of memory.
.PP
\&\fBpadding\fR denotes one of the following modes:
.IP RSA_PKCS1_PADDING 4
.IX Item "RSA_PKCS1_PADDING"
PKCS #1 v1.5 padding. This currently is the most widely used mode.
.IP RSA_PKCS1_OAEP_PADDING 4
.IX Item "RSA_PKCS1_OAEP_PADDING"
EME-OAEP as defined in PKCS #1 v2.0 with SHA\-1, MGF1 and an empty
encoding parameter. This mode is recommended for all new applications.
.IP RSA_SSLV23_PADDING 4
.IX Item "RSA_SSLV23_PADDING"
PKCS #1 v1.5 padding with an SSL-specific modification that denotes
that the server is SSL3 capable.
.IP RSA_NO_PADDING 4
.IX Item "RSA_NO_PADDING"
Raw RSA encryption. This mode should \fIonly\fR be used to implement
cryptographically sound padding modes in the application code.
Encrypting user data directly with RSA is insecure.
.PP
\&\fBflen\fR must be less than RSA_size(\fBrsa\fR) \- 11 for the PKCS #1 v1.5
based padding modes, less than RSA_size(\fBrsa\fR) \- 41 for
RSA_PKCS1_OAEP_PADDING and exactly RSA_size(\fBrsa\fR) for RSA_NO_PADDING.
The random number generator must be seeded prior to calling
\&\fBRSA_public_encrypt()\fR.
.PP
\&\fBRSA_private_decrypt()\fR decrypts the \fBflen\fR bytes at \fBfrom\fR using the
private key \fBrsa\fR and stores the plaintext in \fBto\fR. \fBto\fR must point
to a memory section large enough to hold the decrypted data (which is
smaller than RSA_size(\fBrsa\fR)). \fBpadding\fR is the padding mode that
was used to encrypt the data.
.SH "RETURN VALUES"
.IX Header "RETURN VALUES"
\&\fBRSA_public_encrypt()\fR returns the size of the encrypted data (i.e.,
RSA_size(\fBrsa\fR)). \fBRSA_private_decrypt()\fR returns the size of the
recovered plaintext.
.PP
On error, \-1 is returned; the error codes can be
obtained by \fBERR_get_error\fR\|(3).
.SH WARNING
.IX Header "WARNING"
Decryption failures in the RSA_PKCS1_PADDING mode leak information
which can potentially be used to mount a Bleichenbacher padding oracle
attack. This is an inherent weakness in the PKCS #1 v1.5 padding
design. Prefer RSA_PKCS1_OAEP_PADDING.
.SH "CONFORMING TO"
.IX Header "CONFORMING TO"
SSL, PKCS #1 v2.0
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBERR_get_error\fR\|(3), \fBrand\fR\|(3), \fBrsa\fR\|(3),
\&\fBRSA_size\fR\|(3)
.SH HISTORY
.IX Header "HISTORY"
The \fBpadding\fR argument was added in SSLeay 0.8. RSA_NO_PADDING is
available since SSLeay 0.9.0, OAEP was added in OpenSSL 0.9.2b.