def test_encr_decr_round(): padded = pad(text, 16) ciphert = cbc_encrypt(iv, key, padded) #print("ciphertext:", ciphert) plaint = cbc_decrypt(iv, key, ciphert) #print("plaintext:", plaint) plaint = unpad(plaint) assert_equals(plaint, text, "encrypt/decrypt round test")
def decrypt(binInput): global key enc = binInput[16:] iv = binInput[:16] padded = cbc_decrypt(iv, key, enc) plain = unpad(padded) #print(plain) return plain
def test_encr_decr_round_rnd_iv(): iv2 = bytearray(16) iv2[0] = 1 padded = pad(text, 16) ciphert = cbc_encrypt(iv2, key, padded) #print("ciphertext:", ciphert) plaint = cbc_decrypt(iv2, key, ciphert) #print("plaintext:", plaint) plaint = unpad(plaint) assert_equals(plaint, text, "encrypt/decrypt round test - second IV")
def cbcDecryptIv(key, cipherInput): iv = cipherInput[:16] cipher = cipherInput[16:] plain = cbc_decrypt(iv, key ,cipher) checkPadding(plain) #print("DDD", plain) #print("DDD length", len(plain)) return unpad(plain)
def findAll(oracle): res = b'' while True: char = find_next_char(oracle, 16, res) if char == None: break print(char) res += bytes([char]) res = unpad(res) return res
def test_challenge10(): res = cbc_decrypt(iv, key, bin_input) res = unpad(res) print(res.decode()) print("challenge 10 passed")
def checkProfile(prof): global key plain = unpad(ecb_decrypt(key, prof)) return plain