Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jvdsn
GitHub Repository: jvdsn/crypto-attacks
Path: blob/master/attacks/cbc_and_cbc_mac/eam_key_reuse.py
2589 views
1
def attack(decrypt_oracle, iv, c, t):
2
"""
3
Uses a chosen-ciphertext attack to decrypt the ciphertext.
4
:param decrypt_oracle: the decryption oracle
5
:param iv: the initialization vector
6
:param c: the ciphertext
7
:param t: the tag corresponding to the ciphertext
8
:return: the plaintext
9
"""
10
c_ = iv + c
11
p_ = decrypt_oracle(bytes(16), c_, c[-16:])
12
return p_[16:]
13
14