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().  If the automatic seeding or reseeding of the
93       OpenSSL CSPRNG fails due to external circumstances (see RAND(7)), the
94       operation will fail.
95
96       RSA_padding_check_xxx() verifies that the fl bytes at f contain a valid
97       encoding for a rsa_len byte RSA key in the respective encoding method
98       and stores the recovered data of at most tlen bytes (for
99       RSA_NO_PADDING: of size tlen) at to.
100
101       For RSA_padding_xxx_OAEP(), p points to the encoding parameter of
102       length pl. p may be NULL if pl is 0.
103
104       For RSA_padding_xxx_OAEP_mgf1(), md points to the md hash, if md is
105       NULL that means md=sha1, and mgf1md points to the mgf1 hash, if mgf1md
106       is NULL that means mgf1md=md.
107

RETURN VALUES

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

WARNINGS

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

SEE ALSO

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