Optimal Asymmetric Encryption Padding adds an element of randomness to RSA encryption, and helps prevent partial decryption. Using RSA encryption with some other padding, or without padding yields an encrypted value that is easier for an attacker to decode.


== Noncompliant Code Example

----
Cipher cipher = Cipher.getInstance("RSA/None/NOPADDING");  // Noncompliant
----


== Compliant Solution

----
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING");
----


== See

* https://owasp.org/Top10/A02_2021-Cryptographic_Failures/[OWASP Top 10 2021 Category A2] - Cryptographic Failures
* https://cwe.mitre.org/data/definitions/780.html[MITRE, CWE-780] - Use of RSA Algorithm without OAEP
* https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration[OWASP Top Ten 2013 Category A5] - Security Misconfiguration

