mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Python/JS: Recognize SHA-3 hash functions
Official names are SHA3-224, SHA3-256, SHA3-384, SHA3-512 as per https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
This commit is contained in:
@@ -28,7 +28,11 @@ private module AlgorithmNames {
|
||||
name = "SHA256" or
|
||||
name = "SHA384" or
|
||||
name = "SHA512" or
|
||||
name = "SHA3"
|
||||
name = "SHA3" or
|
||||
name = "SHA3224" or
|
||||
name = "SHA3256" or
|
||||
name = "SHA3384" or
|
||||
name = "SHA3512"
|
||||
}
|
||||
|
||||
predicate isWeakHashingAlgorithm(string name) {
|
||||
|
||||
10
python/ql/test/library-tests/frameworks/crypto/test_sha3.py
Normal file
10
python/ql/test/library-tests/frameworks/crypto/test_sha3.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from Crypto.Hash import SHA3_224
|
||||
|
||||
hasher = SHA3_224.new(b"secret message") # $ CryptographicOperation CryptographicOperationInput=b"secret message" CryptographicOperationAlgorithm=SHA3224
|
||||
print(hasher.hexdigest())
|
||||
|
||||
|
||||
hasher = SHA3_224.new() # $ CryptographicOperation CryptographicOperationAlgorithm=SHA3224
|
||||
hasher.update(b"secret") # $ CryptographicOperation CryptographicOperationInput=b"secret" CryptographicOperationAlgorithm=SHA3224
|
||||
hasher.update(b" message") # $ CryptographicOperation CryptographicOperationInput=b" message" CryptographicOperationAlgorithm=SHA3224
|
||||
print(hasher.hexdigest())
|
||||
@@ -0,0 +1,10 @@
|
||||
from Cryptodome.Hash import SHA3_224
|
||||
|
||||
hasher = SHA3_224.new(b"secret message") # $ CryptographicOperation CryptographicOperationInput=b"secret message" CryptographicOperationAlgorithm=SHA3224
|
||||
print(hasher.hexdigest())
|
||||
|
||||
|
||||
hasher = SHA3_224.new() # $ CryptographicOperation CryptographicOperationAlgorithm=SHA3224
|
||||
hasher.update(b"secret") # $ CryptographicOperation CryptographicOperationInput=b"secret" CryptographicOperationAlgorithm=SHA3224
|
||||
hasher.update(b" message") # $ CryptographicOperation CryptographicOperationInput=b" message" CryptographicOperationAlgorithm=SHA3224
|
||||
print(hasher.hexdigest())
|
||||
Reference in New Issue
Block a user