1RSA_public_encrypt(3) OpenSSL RSA_public_encrypt(3)
2
3
4
6 RSA_public_encrypt, RSA_private_decrypt - RSA public key cryptography
7
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
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
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
61 SSL, PKCS #1 v2.0
62
64 ERR_get_error(3), rand(3), rsa(3), RSA_size(3)
65
67 The padding argument was added in SSLeay 0.8. RSA_NO_PADDING is
68 available since SSLeay 0.9.0, OAEP was added in OpenSSL 0.9.2b.
69
70
71
721.0.2k 2017-01-26 RSA_public_encrypt(3)