Skip to content

Commit da13544

Browse files
committed
python: update tests for CryptographicOperation#getBlockMode
1 parent 9f2c59c commit da13544

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

python/ql/test/experimental/meta/ConceptsTest.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ class CryptographicOperationTest extends InlineExpectationsTest {
487487

488488
override string getARelevantTag() {
489489
result in [
490-
"CryptographicOperation", "CryptographicOperationInput", "CryptographicOperationAlgorithm"
490+
"CryptographicOperation", "CryptographicOperationInput", "CryptographicOperationAlgorithm",
491+
"CryptographicOperationBlockMode"
491492
]
492493
}
493494

@@ -507,6 +508,10 @@ class CryptographicOperationTest extends InlineExpectationsTest {
507508
element = cryptoOperation.toString() and
508509
value = cryptoOperation.getAlgorithm().getName() and
509510
tag = "CryptographicOperationAlgorithm"
511+
or
512+
element = cryptoOperation.toString() and
513+
value = cryptoOperation.getBlockMode() and
514+
tag = "CryptographicOperationBlockMode"
510515
)
511516
)
512517
}

python/ql/test/library-tests/frameworks/crypto/test_aes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
cipher = AES.new(key, AES.MODE_CBC, iv=iv)
2222
# using separate .encrypt calls on individual lines does not work
2323
whole_plantext = secret_message + padding
24-
encrypted = cipher.encrypt(whole_plantext) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=whole_plantext
24+
encrypted = cipher.encrypt(whole_plantext) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=whole_plantext CryptographicOperationBlockMode=CBC
2525

2626
print("encrypted={}".format(encrypted))
2727

2828
print()
2929

3030
cipher = AES.new(key, AES.MODE_CBC, iv=iv)
31-
decrypted = cipher.decrypt(encrypted) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=encrypted
31+
decrypted = cipher.decrypt(encrypted) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=encrypted CryptographicOperationBlockMode=CBC
3232

3333
decrypted = decrypted[:-padding_len]
3434

python/ql/test/library-tests/frameworks/cryptodome/test_aes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
cipher = AES.new(key, AES.MODE_CBC, iv=iv)
2222
# using separate .encrypt calls on individual lines does not work
2323
whole_plantext = secret_message + padding
24-
encrypted = cipher.encrypt(whole_plantext) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=whole_plantext
24+
encrypted = cipher.encrypt(whole_plantext) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=whole_plantext CryptographicOperationBlockMode=CBC
2525

2626
print("encrypted={}".format(encrypted))
2727

2828
print()
2929

3030
cipher = AES.new(key, AES.MODE_CBC, iv=iv)
31-
decrypted = cipher.decrypt(encrypted) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=encrypted
31+
decrypted = cipher.decrypt(encrypted) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=encrypted CryptographicOperationBlockMode=CBC
3232

3333
decrypted = decrypted[:-padding_len]
3434

python/ql/test/library-tests/frameworks/cryptography/test_aes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222

2323
encryptor = cipher.encryptor()
2424
print(padding_len)
25-
encrypted = encryptor.update(secret_message) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=secret_message
26-
encrypted += encryptor.update(padding) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=padding
25+
encrypted = encryptor.update(secret_message) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=secret_message CryptographicOperationBlockMode=CBC
26+
encrypted += encryptor.update(padding) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=padding CryptographicOperationBlockMode=CBC
2727
encrypted += encryptor.finalize()
2828

2929
print("encrypted={}".format(encrypted))
3030

3131
print()
3232

3333
decryptor = cipher.decryptor()
34-
decrypted = decryptor.update(encrypted) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=encrypted
34+
decrypted = decryptor.update(encrypted) # $ CryptographicOperation CryptographicOperationAlgorithm=AES CryptographicOperationInput=encrypted CryptographicOperationBlockMode=CBC
3535
decrypted += decryptor.finalize()
3636

3737
decrypted = decrypted[:-padding_len]

0 commit comments

Comments
 (0)