Skip to content

Instantly share code, notes, and snippets.

@yarjor
Created September 29, 2018 17:45
Show Gist options
  • Save yarjor/82d98ba5588dd9031f64a5f9a582bc6e to your computer and use it in GitHub Desktop.
Save yarjor/82d98ba5588dd9031f64a5f9a582bc6e to your computer and use it in GitHub Desktop.
[Detect cipher block size] #blockcipher #crypto #oracle #detection
def detect_block_size(cipher_box):
last_size = len(cipher_box('A'))
counter = 0
while True:
counter += 1
new_size = len(cipher_box('A' * counter))
if new_size > last_size:
return new_size - last_size
last_size = new_size
# cipher_box is a function that accepts plain-text and returns cipher-text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment