mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
add shared key sizes
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
private import semmle.code.java.security.Encryption
|
||||
private import semmle.code.java.dataflow.DataFlow
|
||||
private import semmle.code.java.security.EncryptionKeySizes
|
||||
|
||||
/** A source for an insufficient key size. */
|
||||
abstract class InsufficientKeySizeSource extends DataFlow::Node {
|
||||
@@ -42,7 +43,7 @@ private module Asymmetric {
|
||||
}
|
||||
|
||||
/** Returns the minimum recommended key size for RSA, DSA, and DH algorithms. */
|
||||
private int getMinKeySize() { result = 2048 }
|
||||
private int getMinKeySize() { result = minSecureKeySizeAsymmetricNonEc() }
|
||||
|
||||
/** An instance of an RSA, DSA, or DH algorithm specification. */
|
||||
private class Spec extends ClassInstanceExpr {
|
||||
@@ -87,7 +88,7 @@ private module Asymmetric {
|
||||
}
|
||||
|
||||
/** Returns the minimum recommended key size for elliptic curve (EC) algorithms. */
|
||||
private int getMinKeySize() { result = 256 }
|
||||
private int getMinKeySize() { result = minSecureKeySizeAsymmetricEc() }
|
||||
|
||||
/** Returns the key size from an EC algorithm's curve name string */
|
||||
bindingset[algorithm]
|
||||
@@ -168,7 +169,7 @@ private module Symmetric {
|
||||
}
|
||||
|
||||
/** Returns the minimum recommended key size for AES algorithms. */
|
||||
private int getMinKeySize() { result = 128 }
|
||||
private int getMinKeySize() { result = minSecureKeySizeSymmetric() }
|
||||
|
||||
/** A call to the `init` method declared in `javax.crypto.KeyGenerator`. */
|
||||
private class KeyGenInit extends MethodAccess {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*
|
||||
* Provides predicates for recommended encryption key sizes.
|
||||
* Such that we can share this logic across our CodeQL analysis of different languages.
|
||||
*/
|
||||
|
||||
/** Returns the minimum recommended key size for asymmetric algorithms (RSA, DSA, and DH). */
|
||||
int minSecureKeySizeAsymmetricNonEc() { result = 2048 }
|
||||
|
||||
/** Returns the minimum recommended key size for elliptic curve (EC) algorithms. */
|
||||
int minSecureKeySizeAsymmetricEc() { result = 256 }
|
||||
|
||||
/** Returns the minimum recommended key size for symmetric algorithmms (AES). */
|
||||
int minSecureKeySizeSymmetric() { result = 128 }
|
||||
Reference in New Issue
Block a user