1RSA_PUBLIC_ENCRYPT(3)               OpenSSL              RSA_PUBLIC_ENCRYPT(3)
2
3
4

NAME

6       RSA_public_encrypt, RSA_private_decrypt - RSA public key cryptography
7

SYNOPSIS

9        #include <openssl/rsa.h>
10
11        int RSA_public_encrypt(int flen, unsigned char *from,
12                               unsigned char *to, RSA *rsa, int padding);
13
14        int RSA_private_decrypt(int flen, unsigned char *from,
15                                unsigned char *to, RSA *rsa, int padding);
16

DESCRIPTION

18       RSA_public_encrypt() encrypts the flen bytes at from (usually a session
19       key) using the public key rsa and stores the ciphertext in to. to must
20       point to RSA_size(rsa) bytes of memory.
21
22       padding denotes one of the following modes:
23
24       RSA_PKCS1_PADDING
25           PKCS #1 v1.5 padding. This currently is the most widely used mode.
26
27       RSA_PKCS1_OAEP_PADDING
28           EME-OAEP as defined in PKCS #1 v2.0 with SHA-1, MGF1 and an empty
29           encoding parameter. This mode is recommended for all new
30           applications.
31
32       RSA_SSLV23_PADDING
33           PKCS #1 v1.5 padding with an SSL-specific modification that denotes
34           that the server is SSL3 capable.
35
36       RSA_NO_PADDING
37           Raw RSA encryption. This mode should only be used to implement
38           cryptographically sound padding modes in the application code.
39           Encrypting user data directly with RSA is insecure.
40
41       flen must be less than RSA_size(rsa) - 11 for the PKCS #1 v1.5 based
42       padding modes, less than RSA_size(rsa) - 41 for RSA_PKCS1_OAEP_PADDING
43       and exactly RSA_size(rsa) for RSA_NO_PADDING.  The random number
44       generator must be seeded prior to calling RSA_public_encrypt().
45
46       RSA_private_decrypt() decrypts the flen bytes at from using the private
47       key rsa and stores the plaintext in to. to must point to a memory
48       section large enough to hold the decrypted data (which is smaller than
49       RSA_size(rsa)). padding is the padding mode that was used to encrypt
50       the data.
51

RETURN VALUES

53       RSA_public_encrypt() returns the size of the encrypted data (i.e.,
54       RSA_size(rsa)). RSA_private_decrypt() returns the size of the recovered
55       plaintext.
56
57       On error, -1 is returned; the error codes can be obtained by
58       ERR_get_error(3).
59

WARNING

61       Decryption failures in the RSA_PKCS1_PADDING mode leak information
62       which can potentially be used to mount a Bleichenbacher padding oracle
63       attack. This is an inherent weakness in the PKCS #1 v1.5 padding
64       design. Prefer RSA_PKCS1_OAEP_PADDING.
65

CONFORMING TO

67       SSL, PKCS #1 v2.0
68

SEE ALSO

70       ERR_get_error(3), RAND_bytes(3), RSA_size(3)
71
73       Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
74
75       Licensed under the OpenSSL license (the "License").  You may not use
76       this file except in compliance with the License.  You can obtain a copy
77       in the file LICENSE in the source distribution or at
78       <https://www.openssl.org/source/license.html>.
79
80
81
821.1.1                             2018-09-11             RSA_PUBLIC_ENCRYPT(3)
Impressum