Skip to content

Commit

Permalink
Java: add SHA224 and SHA384 to list of secure algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
Jami Cogswell authored and Jami Cogswell committed Nov 24, 2024
1 parent c6eaed3 commit 561321f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions java/ql/lib/semmle/code/java/security/Encryption.qll
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ string getInsecureAlgorithmRegex() {
string getASecureAlgorithmName() {
result =
[
"RSA", "SHA-?256", "SHA-?512", "CCM", "GCM", "AES(?![^a-zA-Z](ECB|CBC/PKCS[57]Padding))",
"Blowfish", "ECIES", "SHA3-(224|256|384|512)"
"RSA", "SHA-?(224|256|384|512)", "SHA3-(224|256|384|512)", "CCM", "GCM",
"AES(?![^a-zA-Z](ECB|CBC/PKCS[57]Padding))", "Blowfish", "ECIES"
]
}

Expand Down
4 changes: 4 additions & 0 deletions java/ql/src/change-notes/2024-11-24-sha2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Added SHA-224 and SHA-384 to the list of secure hashing algorithms. As a result the `java/potentially-weak-cryptographic-algorithm` query should no longer flag up uses of these algorithms.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void hashing() throws NoSuchAlgorithmException, IOException {

// BAD: Using a strong hashing algorithm but with a weak default
MessageDigest bad3 = MessageDigest.getInstance(props.getProperty("hashAlg2", "MD5"));

// GOOD: Using a strong hashing algorithm
MessageDigest ok = MessageDigest.getInstance(props.getProperty("hashAlg2"));

Expand All @@ -28,5 +28,8 @@ void hashing() throws NoSuchAlgorithmException, IOException {

// GOOD: Using a strong hashing algorithm
MessageDigest ok3 = MessageDigest.getInstance("SHA3-512");

// GOOD: Using a strong hashing algorithm
MessageDigest ok4 = MessageDigest.getInstance("SHA384");
}
}

0 comments on commit 561321f

Please sign in to comment.