Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jvdsn
GitHub Repository: jvdsn/crypto-attacks
Path: blob/master/attacks/cbc/iv_recovery.py
2589 views
1
from Crypto.Util.strxor import strxor
2
3
4
def attack(decrypt_oracle):
5
"""
6
Recovers the initialization vector using a chosen-ciphertext attack.
7
:param decrypt_oracle: the decryption oracle to decrypt ciphertexts
8
:return: the initialization vector
9
"""
10
p = decrypt_oracle(bytes(32))
11
return strxor(p[:16], p[16:])
12
13