Skip to content

Commit 651031b

Browse files
authored
python crypto update hmac module library (#69)
1 parent d548e47 commit 651031b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

python/ql/lib/experimental/cryptography/modules/stdlib/HmacModule.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ private import experimental.cryptography.CryptoAlgorithmNames
66
private import experimental.cryptography.modules.stdlib.HashlibModule as HashlibModule
77

88
/**
9-
* `hmac` is a ptyhon standard library module for key-based hashing algorithms.
9+
* `hmac` is a python standard library module for key-based hashing algorithms.
1010
* https://docs.python.org/3/library/hmac.html
1111
*/
1212
// -----------------------------------------------
@@ -23,25 +23,27 @@ module Hashes {
2323

2424
DataFlow::Node getDigestModParamSrc(GenericHmacHashCall call) {
2525
result = Utils::getUltimateSrcFromApiNode(call.(API::CallNode).getParameter(2, "digestmod"))
26+
or
27+
result = Utils::getUltimateSrcFromApiNode(call.(API::CallNode).getParameter(2, "digest"))
2628
}
2729

2830
/**
2931
* This class captures the common behavior for all HMAC operations:
3032
* hmac.HMAC https://docs.python.org/3/library/hmac.html#hmac.HMAC
3133
* hmac.new https://docs.python.org/3/library/hmac.html#hmac.new
3234
* hmac.digest https://docs.python.org/3/library/hmac.html#hmac.digest
33-
* These operations commonly set the algorithm as a string in the third argument (`digestmod`)
35+
* These operations commonly set the algorithm as a string in the third argument (`digest` or `digestmod`)
3436
* of the operation itself.
3537
*
36-
* NOTE: `digestmod` is the digest name, digest constructor or module for the HMAC object to use, however
38+
* NOTE: `digest` or `digestmod` is the digest name, digest constructor or module for the HMAC object to use, however
3739
* this class only identifies string names. The other forms are found by CryptopgraphicArtifacts,
3840
* modeled in `HmacHMACConsArtifact` and `Hashlib.qll`, specifically through hashlib.new and
3941
* direct member accesses (e.g., hashlib.md5).
4042
*
41-
* Where no `digestmod` exists, the algorithm is assumed to be `md5` per the docs found here:
43+
* Where no `digest` or `digestmod` exists, the algorithm is assumed to be `md5` per the docs found here:
4244
* https://docs.python.org/3/library/hmac.html#hmac.new
4345
*
44-
* Where `digestmod` exists but is not a string and not a hashlib algorithm, it is assumed
46+
* Where `digest` or `digestmod` exists but is not a string and not a hashlib algorithm, it is assumed
4547
* to be `UNKNOWN`. Note this includes cases wheere the digest is provided as a `A module supporting PEP 247.`
4648
* Such modules are currently not modeled.
4749
*/

0 commit comments

Comments
 (0)