-
Notifications
You must be signed in to change notification settings - Fork 522
Expand file tree
/
Copy pathcbc-padding-oracle.java
More file actions
38 lines (32 loc) · 1.41 KB
/
cbc-padding-oracle.java
File metadata and controls
38 lines (32 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package servlets;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class Cls extends HttpServlet
{
private static org.apache.log4j.Logger log = Logger.getLogger(Register.class);
// cf. https://find-sec-bugs.github.io/bugs.htm#TDES_USAGE
protected void danger(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// ruleid:cbc-padding-oracle
Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
c.init(Cipher.ENCRYPT_MODE, k, iv);
byte[] cipherText = c.doFinal(plainText);
}
protected void danger_lowercase(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// ruleid:cbc-padding-oracle
Cipher c = Cipher.getInstance("aes/cbc/pkcs5padding");
c.init(Cipher.ENCRYPT_MODE, k, iv);
byte[] cipherText = c.doFinal(plainText);
}
protected void ok(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// ok:cbc-padding-oracle
Cipher c = Cipher.getInstance("AES/GCM/NoPadding");
c.init(Cipher.ENCRYPT_MODE, k, iv);
byte[] cipherText = c.doFinal(plainText);
}
}