Files
codeql/java/ql/test/query-tests/security/CWE-780/RsaWithoutOaepTest.java
2025-06-24 16:42:28 +02:00

18 lines
495 B
Java

import javax.crypto.Cipher;
class RsaWithoutOaep {
public void test() throws Exception {
Cipher rsaBad = Cipher.getInstance("RSA/ECB/NoPadding"); // $ Alert
Cipher rsaGood = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding");
}
public Cipher getCipher(String spec) throws Exception {
return Cipher.getInstance(spec); // $ Sink
}
public void test2() throws Exception {
Cipher rsa = getCipher("RSA/ECB/NoPadding"); // $ Alert
}
}