Created
June 30, 2015 14:28
-
-
Save dmb2/172602d372050ea8d9fd to your computer and use it in GitHub Desktop.
This file contains 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
# Cipher text is a bytestring | |
# bi is the block index, or which block to edit. Flipping a bit in this block will result in a one bit edit in the bi+1 plaintext block | |
# i is the targeted bit's index | |
# z is the array of decoded bytes. | |
# The idea here is to target bit i, but also flip the bits of previously discovered bytes. | |
def flip_bit(cipher_text,bi,i,z) | |
bsize=16 | |
i.times do |j| | |
tb=(z[j-1]==nil) ? 0 : z[j-1] | |
cb=cipher_text.bytes()[bi*bsize-j-1] | |
cipher_text[bi*bsize-j-1]=(cb^tb^i).chr | |
end | |
return cipher_text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment