Encryption operation mode and the padding scheme should be chosen appropriately to guarantee data confidentiality, integrity and authenticity:
val c1 = Cipher.getInstance("AES") // Noncompliant: by default ECB mode is chosen
val c2 = Cipher.getInstance("AES/ECB/NoPadding") // Noncompliant: ECB doesn't provide serious message confidentiality
val c3 = Cipher.getInstance("RSA/None/NoPadding") // Noncompliant: RSA without OAEP padding scheme is not recommanded
// Recommended for block ciphers
val c1 = Cipher.getInstance("AES/GCM/NoPadding"); // Compliant
// Recommended for RSA
val c3 = Cipher.getInstance("RSA/None/OAEPWITHSHA-256ANDMGF1PADDING") // Compliant
// or the ECB mode can be used for RSA when "None" is not available with the security provider used - in that case, ECB will be treated as "None" for RSA.
val c3 = Cipher.getInstance("RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING"); // Compliant