Created
September 29, 2018 17:48
-
-
Save yarjor/5b9e08be4643c7bbf64e09ff6a67329b to your computer and use it in GitHub Desktop.
[Differentiate ECB/CBC] #oracle #detection #crypto #blockcipher #cbc #ecb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def detect_cipher(cipher_box): | |
chosen_plaintext = 'a' * 16 * 6 | |
cipher_text = cipher_box(chosen_plaintext) | |
cipher_blocks = divide_blocks(cipher_text, 16) | |
if len(cipher_blocks) != len(set(cipher_blocks)): | |
return 'ECB' | |
else: | |
return 'CBC' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment