1RSA_PADDING_ADD_PKCS1_TYPE_1(3)     OpenSSL    RSA_PADDING_ADD_PKCS1_TYPE_1(3)
2
3
4

NAME

6       RSA_padding_add_PKCS1_type_1, RSA_padding_check_PKCS1_type_1,
7       RSA_padding_add_PKCS1_type_2, RSA_padding_check_PKCS1_type_2,
8       RSA_padding_add_PKCS1_OAEP, RSA_padding_check_PKCS1_OAEP,
9       RSA_padding_add_PKCS1_OAEP_mgf1, RSA_padding_check_PKCS1_OAEP_mgf1,
10       RSA_padding_add_SSLv23, RSA_padding_check_SSLv23, RSA_padding_add_none,
11       RSA_padding_check_none - asymmetric encryption padding
12

SYNOPSIS

14        #include <openssl/rsa.h>
15
16        int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
17                                         const unsigned char *f, int fl);
18
19        int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
20                                           const unsigned char *f, int fl, int rsa_len);
21
22        int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
23                                         const unsigned char *f, int fl);
24
25        int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
26                                           const unsigned char *f, int fl, int rsa_len);
27
28        int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
29                                       const unsigned char *f, int fl,
30                                       const unsigned char *p, int pl);
31
32        int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
33                                         const unsigned char *f, int fl, int rsa_len,
34                                         const unsigned char *p, int pl);
35
36        int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
37                                            const unsigned char *f, int fl,
38                                            const unsigned char *p, int pl,
39                                            const EVP_MD *md, const EVP_MD *mgf1md);
40
41        int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
42                                              const unsigned char *f, int fl, int rsa_len,
43                                              const unsigned char *p, int pl,
44                                              const EVP_MD *md, const EVP_MD *mgf1md);
45
46        int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
47                                   const unsigned char *f, int fl);
48
49        int RSA_padding_check_SSLv23(unsigned char *to, int tlen,
50                                     const unsigned char *f, int fl, int rsa_len);
51
52        int RSA_padding_add_none(unsigned char *to, int tlen,
53                                 const unsigned char *f, int fl);
54
55        int RSA_padding_check_none(unsigned char *to, int tlen,
56                                   const unsigned char *f, int fl, int rsa_len);
57

DESCRIPTION

59       The RSA_padding_xxx_xxx() functions are called from the RSA encrypt,
60       decrypt, sign and verify functions. Normally they should not be called
61       from application programs.
62
63       However, they can also be called directly to implement padding for
64       other asymmetric ciphers. RSA_padding_add_PKCS1_OAEP() and
65       RSA_padding_check_PKCS1_OAEP() may be used in an application combined
66       with RSA_NO_PADDING in order to implement OAEP with an encoding
67       parameter.
68
69       RSA_padding_add_xxx() encodes fl bytes from f so as to fit into tlen
70       bytes and stores the result at to. An error occurs if fl does not meet
71       the size requirements of the encoding method.
72
73       The following encoding methods are implemented:
74
75       PKCS1_type_1
76           PKCS #1 v2.0 EMSA-PKCS1-v1_5 (PKCS #1 v1.5 block type 1); used for
77           signatures
78
79       PKCS1_type_2
80           PKCS #1 v2.0 EME-PKCS1-v1_5 (PKCS #1 v1.5 block type 2)
81
82       PKCS1_OAEP
83           PKCS #1 v2.0 EME-OAEP
84
85       SSLv23
86           PKCS #1 EME-PKCS1-v1_5 with SSL-specific modification
87
88       none
89           simply copy the data
90
91       The random number generator must be seeded prior to calling
92       RSA_padding_add_xxx().
93
94       RSA_padding_check_xxx() verifies that the fl bytes at f contain a valid
95       encoding for a rsa_len byte RSA key in the respective encoding method
96       and stores the recovered data of at most tlen bytes (for
97       RSA_NO_PADDING: of size tlen) at to.
98
99       For RSA_padding_xxx_OAEP(), p points to the encoding parameter of
100       length pl. p may be NULL if pl is 0.
101
102       For RSA_padding_xxx_OAEP_mgf1(), md points to the md hash, if md is
103       NULL that means md=sha1, and mgf1md points to the mgf1 hash, if mgf1md
104       is NULL that means mgf1md=md.
105

RETURN VALUES

107       The RSA_padding_add_xxx() functions return 1 on success, 0 on error.
108       The RSA_padding_check_xxx() functions return the length of the
109       recovered data, -1 on error. Error codes can be obtained by calling
110       ERR_get_error(3).
111

WARNING

113       The result of RSA_padding_check_PKCS1_type_2() is a very sensitive
114       information which can potentially be used to mount a Bleichenbacher
115       padding oracle attack. This is an inherent weakness in the PKCS #1 v1.5
116       padding design. Prefer PKCS1_OAEP padding. If that is not possible, the
117       result of RSA_padding_check_PKCS1_type_2() should be checked in
118       constant time if it matches the expected length of the plaintext and
119       additionally some application specific consistency checks on the
120       plaintext need to be performed in constant time.  If the plaintext is
121       rejected it must be kept secret which of the checks caused the
122       application to reject the message.  Do not remove the zero-padding from
123       the decrypted raw RSA data which was computed by RSA_private_decrypt()
124       with RSA_NO_PADDING, as this would create a small timing side channel
125       which could be used to mount a Bleichenbacher attack against any
126       padding mode including PKCS1_OAEP.
127

SEE ALSO

129       RSA_public_encrypt(3), RSA_private_decrypt(3), RSA_sign(3),
130       RSA_verify(3)
131
133       Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
134
135       Licensed under the OpenSSL license (the "License").  You may not use
136       this file except in compliance with the License.  You can obtain a copy
137       in the file LICENSE in the source distribution or at
138       <https://www.openssl.org/source/license.html>.
139
140
141
1421.1.1c                            2019-05-28   RSA_PADDING_ADD_PKCS1_TYPE_1(3)
Impressum