1RSA_PADDING_ADD_PKCS1_TYPE_1(3ossl) OpenSSLRSA_PADDING_ADD_PKCS1_TYPE_1(3ossl)
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_none, RSA_padding_check_none - asymmetric encryption
11       padding
12

SYNOPSIS

14        #include <openssl/rsa.h>
15
16       The following functions have been deprecated since OpenSSL 3.0, and can
17       be hidden entirely by defining OPENSSL_API_COMPAT with a suitable
18       version value, see openssl_user_macros(7):
19
20        int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
21                                         const unsigned char *f, int fl);
22
23        int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
24                                           const unsigned char *f, int fl, int rsa_len);
25
26        int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
27                                         const unsigned char *f, int fl);
28
29        int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
30                                           const unsigned char *f, int fl, int rsa_len);
31
32        int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
33                                       const unsigned char *f, int fl,
34                                       const unsigned char *p, int pl);
35
36        int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
37                                         const unsigned char *f, int fl, int rsa_len,
38                                         const unsigned char *p, int pl);
39
40        int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
41                                            const unsigned char *f, int fl,
42                                            const unsigned char *p, int pl,
43                                            const EVP_MD *md, const EVP_MD *mgf1md);
44
45        int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
46                                              const unsigned char *f, int fl, int rsa_len,
47                                              const unsigned char *p, int pl,
48                                              const EVP_MD *md, const EVP_MD *mgf1md);
49
50        int RSA_padding_add_none(unsigned char *to, int tlen,
51                                 const unsigned char *f, int fl);
52
53        int RSA_padding_check_none(unsigned char *to, int tlen,
54                                   const unsigned char *f, int fl, int rsa_len);
55

DESCRIPTION

57       All of the functions described on this page are deprecated.
58       Applications should instead use the EVP PKEY APIs.
59
60       The RSA_padding_xxx_xxx() functions are called from the RSA encrypt,
61       decrypt, sign and verify functions. Normally they should not be called
62       from application programs.
63
64       However, they can also be called directly to implement padding for
65       other asymmetric ciphers. RSA_padding_add_PKCS1_OAEP() and
66       RSA_padding_check_PKCS1_OAEP() may be used in an application combined
67       with RSA_NO_PADDING in order to implement OAEP with an encoding
68       parameter.
69
70       RSA_padding_add_xxx() encodes fl bytes from f so as to fit into tlen
71       bytes and stores the result at to. An error occurs if fl does not meet
72       the size requirements of the encoding method.
73
74       The following encoding methods are implemented:
75
76       PKCS1_type_1
77           PKCS #1 v2.0 EMSA-PKCS1-v1_5 (PKCS #1 v1.5 block type 1); used for
78           signatures
79
80       PKCS1_type_2
81           PKCS #1 v2.0 EME-PKCS1-v1_5 (PKCS #1 v1.5 block type 2)
82
83       PKCS1_OAEP
84           PKCS #1 v2.0 EME-OAEP
85
86       none
87           simply copy the data
88
89       The random number generator must be seeded prior to calling
90       RSA_padding_add_xxx().  If the automatic seeding or reseeding of the
91       OpenSSL CSPRNG fails due to external circumstances (see RAND(7)), the
92       operation will fail.
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

WARNINGS

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

SEE ALSO

132       RSA_public_encrypt(3), RSA_private_decrypt(3), RSA_sign(3),
133       RSA_verify(3), RAND(7)
134

HISTORY

136       All of these functions were deprecated in OpenSSL 3.0.
137
139       Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
140
141       Licensed under the Apache License 2.0 (the "License").  You may not use
142       this file except in compliance with the License.  You can obtain a copy
143       in the file LICENSE in the source distribution or at
144       <https://www.openssl.org/source/license.html>.
145
146
147
1483.0.9                             2023-07-27RSA_PADDING_ADD_PKCS1_TYPE_1(3ossl)
Impressum