File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
python/ql/test/library-tests/frameworks/stdlib Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ import hmac
2+ import hashlib
3+
4+ key = b"<secret key>"
5+
6+ hmac_obj = hmac .new (key , b"secret message" , "sha256" ) # $ MISSING: CryptographicOperation CryptographicOperationInput=b"secret message" CryptographicOperationAlgorithm=SHA256
7+ print (hmac_obj .digest ())
8+ print (hmac_obj .hexdigest ())
9+
10+ hmac_obj = hmac .new (key , msg = b"secret message" , digestmod = "sha256" ) # $ MISSING: CryptographicOperation CryptographicOperationInput=b"secret message" CryptographicOperationAlgorithm=SHA256
11+ print (hmac_obj .hexdigest ())
12+
13+
14+ hmac_obj = hmac .new (key , digestmod = "sha256" )
15+ hmac_obj .update (b"secret" ) # $ MISSING: CryptographicOperation CryptographicOperationInput=b"secret" CryptographicOperationAlgorithm=SHA256
16+ hmac_obj .update (msg = b" message" ) # $ MISSING: CryptographicOperation CryptographicOperationInput=b" message" CryptographicOperationAlgorithm=SHA256
17+ print (hmac_obj .hexdigest ())
18+
19+
20+ hmac_obj = hmac .new (key , b"secret message" , hashlib .sha256 ) # $ MISSING: CryptographicOperation CryptographicOperationInput=b"secret message" CryptographicOperationAlgorithm=SHA256
21+ print (hmac_obj .hexdigest ())
22+
23+
24+ # like hmac.new
25+ hmac_obj = hmac .HMAC (key , digestmod = "sha256" )
26+ hmac_obj .update (b"secret message" ) # $ MISSING: CryptographicOperation CryptographicOperationInput=b"secret message" CryptographicOperationAlgorithm=SHA256
27+ print (hmac_obj .hexdigest ())
28+
29+
30+ dig = hmac .digest (key , b"secret message" , "sha256" ) # $ MISSING: CryptographicOperation CryptographicOperationInput=b"secret message" CryptographicOperationAlgorithm=SHA256
31+ print (dig )
32+ dig = hmac .digest (key , msg = b"secret message" , digest = "sha256" ) # $ MISSING: CryptographicOperation CryptographicOperationInput=b"secret message" CryptographicOperationAlgorithm=SHA256
33+ print (dig )
You can’t perform that action at this time.
0 commit comments