@@ -18,6 +18,12 @@ import (
1818
1919// PKCS1v15DecryptOptions is for passing options to PKCS #1 v1.5 decryption using
2020// the [crypto.Decrypter] interface.
21+ //
22+ // Deprecated: PKCS #1 v1.5 encryption is dangerous and should not be used.
23+ // See [draft-irtf-cfrg-rsa-guidance-05] for more information. Use
24+ // [EncryptOAEP] and [DecryptOAEP] instead.
25+ //
26+ // [draft-irtf-cfrg-rsa-guidance-05]: https://www.ietf.org/archive/id/draft-irtf-cfrg-rsa-guidance-05.html#name-rationale
2127type PKCS1v15DecryptOptions struct {
2228 // SessionKeyLen is the length of the session key that is being
2329 // decrypted. If not zero, then a padding error during decryption will
@@ -37,8 +43,11 @@ type PKCS1v15DecryptOptions struct {
3743// deterministically on the bytes read from random, and may change
3844// between calls and/or between versions.
3945//
40- // WARNING: use of this function to encrypt plaintexts other than
41- // session keys is dangerous. Use RSA OAEP in new protocols.
46+ // Deprecated: PKCS #1 v1.5 encryption is dangerous and should not be used.
47+ // See [draft-irtf-cfrg-rsa-guidance-05] for more information. Use
48+ // [EncryptOAEP] and [DecryptOAEP] instead.
49+ //
50+ // [draft-irtf-cfrg-rsa-guidance-05]: https://www.ietf.org/archive/id/draft-irtf-cfrg-rsa-guidance-05.html#name-rationale
4251func EncryptPKCS1v15 (random io.Reader , pub * PublicKey , msg []byte ) ([]byte , error ) {
4352 if fips140only .Enabled {
4453 return nil , errors .New ("crypto/rsa: use of PKCS#1 v1.5 encryption is not allowed in FIPS 140-only mode" )
@@ -91,14 +100,17 @@ func EncryptPKCS1v15(random io.Reader, pub *PublicKey, msg []byte) ([]byte, erro
91100 return rsa .Encrypt (fk , em )
92101}
93102
94- // DecryptPKCS1v15 decrypts a plaintext using RSA and the padding scheme from PKCS #1 v1.5.
95- // The random parameter is legacy and ignored, and it can be nil.
103+ // DecryptPKCS1v15 decrypts a plaintext using RSA and the padding scheme from
104+ // PKCS #1 v1.5. The random parameter is legacy and ignored, and it can be nil.
96105//
97- // Note that whether this function returns an error or not discloses secret
98- // information. If an attacker can cause this function to run repeatedly and
99- // learn whether each instance returned an error then they can decrypt and
100- // forge signatures as if they had the private key. See
101- // DecryptPKCS1v15SessionKey for a way of solving this problem.
106+ // Deprecated: PKCS #1 v1.5 encryption is dangerous and should not be used.
107+ // Whether this function returns an error or not discloses secret information.
108+ // If an attacker can cause this function to run repeatedly and learn whether
109+ // each instance returned an error then they can decrypt and forge signatures as
110+ // if they had the private key. See [draft-irtf-cfrg-rsa-guidance-05] for more
111+ // information. Use [EncryptOAEP] and [DecryptOAEP] instead.
112+ //
113+ // [draft-irtf-cfrg-rsa-guidance-05]: https://www.ietf.org/archive/id/draft-irtf-cfrg-rsa-guidance-05.html#name-rationale
102114func DecryptPKCS1v15 (random io.Reader , priv * PrivateKey , ciphertext []byte ) ([]byte , error ) {
103115 if err := checkPublicKeySize (& priv .PublicKey ); err != nil {
104116 return nil , err
@@ -160,6 +172,13 @@ func DecryptPKCS1v15(random io.Reader, priv *PrivateKey, ciphertext []byte) ([]b
160172// Standard PKCS #1”, Daniel Bleichenbacher, Advances in Cryptology (Crypto '98)
161173// - [1] RFC 3218, Preventing the Million Message Attack on CMS,
162174// https://www.rfc-editor.org/rfc/rfc3218.html
175+ //
176+ // Deprecated: PKCS #1 v1.5 encryption is dangerous and should not be used. The
177+ // protections implemented by this function are limited and fragile, as
178+ // explained above. See [draft-irtf-cfrg-rsa-guidance-05] for more information.
179+ // Use [EncryptOAEP] and [DecryptOAEP] instead.
180+ //
181+ // [draft-irtf-cfrg-rsa-guidance-05]: https://www.ietf.org/archive/id/draft-irtf-cfrg-rsa-guidance-05.html#name-rationale
163182func DecryptPKCS1v15SessionKey (random io.Reader , priv * PrivateKey , ciphertext []byte , key []byte ) error {
164183 if err := checkPublicKeySize (& priv .PublicKey ); err != nil {
165184 return err
0 commit comments