|
23 | 23 |
|
24 | 24 | encrypt_cipher = PKCS1_OAEP.new(public_key) |
25 | 25 |
|
26 | | -encrypted = encrypt_cipher.encrypt(secret_message) |
| 26 | +encrypted = encrypt_cipher.encrypt(secret_message) # $ CryptographicOperation CryptographicOperationInput=secret_message # MISSING: CryptographicOperationAlgorithm=RSA-OAEP? |
27 | 27 |
|
28 | 28 | print("encrypted={}".format(encrypted)) |
29 | 29 |
|
30 | 30 | print() |
31 | 31 |
|
32 | 32 | decrypt_cipher = PKCS1_OAEP.new(private_key) |
33 | 33 |
|
34 | | -decrypted = decrypt_cipher.decrypt( |
35 | | - encrypted, |
36 | | -) |
| 34 | +decrypted = decrypt_cipher.decrypt(encrypted) # $ CryptographicOperation CryptographicOperationInput=encrypted # MISSING: CryptographicOperationAlgorithm=RSA-OAEP? |
37 | 35 |
|
38 | 36 | print("decrypted={}".format(decrypted)) |
39 | 37 | assert decrypted == secret_message |
|
51 | 49 |
|
52 | 50 | signer = pss.new(private_key) |
53 | 51 |
|
54 | | -hasher = SHA256.new(message) |
55 | | -signature = signer.sign(hasher) |
| 52 | +hasher = SHA256.new(message) # $ CryptographicOperation CryptographicOperationAlgorithm=SHA256 CryptographicOperationInput=message |
| 53 | +signature = signer.sign(hasher) # $ CryptographicOperation CryptographicOperationInput=hasher # MISSING: CryptographicOperationAlgorithm=RSA-PSS? |
56 | 54 |
|
57 | 55 | print("signature={}".format(signature)) |
58 | 56 |
|
59 | 57 | print() |
60 | 58 |
|
61 | 59 | verifier = pss.new(public_key) |
62 | 60 |
|
63 | | -hasher = SHA256.new(message) |
64 | | -verifier.verify(hasher, signature) |
| 61 | +hasher = SHA256.new(message) # $ CryptographicOperation CryptographicOperationAlgorithm=SHA256 CryptographicOperationInput=message |
| 62 | +verifier.verify(hasher, signature) # $ CryptographicOperation CryptographicOperationInput=hasher CryptographicOperationInput=signature # MISSING: CryptographicOperationAlgorithm=RSA-PSS? |
65 | 63 | print("Signature verified (as expected)") |
66 | 64 |
|
67 | 65 | try: |
68 | 66 | verifier = pss.new(public_key) |
69 | | - hasher = SHA256.new(b"other message") |
70 | | - verifier.verify(hasher, signature) |
| 67 | + hasher = SHA256.new(b"other message") # $ CryptographicOperation CryptographicOperationAlgorithm=SHA256 CryptographicOperationInput=b"other message" |
| 68 | + verifier.verify(hasher, signature) # $ CryptographicOperation CryptographicOperationInput=hasher CryptographicOperationInput=signature # MISSING: CryptographicOperationAlgorithm=RSA-PSS? |
71 | 69 | raise Exception("Signature verified (unexpected)") |
72 | 70 | except ValueError: |
73 | 71 | print("Signature mismatch (as expected)") |
0 commit comments