def aes_cbc_dec(rawCipher, rawKey, rawIV): cipherBlocks = chunks(rawCipher, 16) plain = b"" for block in cipherBlocks: ecbOut = aes_ecb_dec(block, rawKey) cbcOut = hexToRaw(hex_xor(rawToHex(ecbOut), rawToHex(rawIV))) rawIV = block plain += cbcOut return plain
def aes_cbc_dec(rawCipher, rawKey, rawIV): cipherBlocks = chunks(rawCipher, 16) plain = b'' for block in cipherBlocks: ecbOut = aes_ecb_dec(block, rawKey) cbcOut = hexToRaw(hex_xor(rawToHex(ecbOut), rawToHex(rawIV))) rawIV = block plain += cbcOut return plain
def aes_cbc_dec(rawCipher, rawKey, rawIV): cipherBlocks = chunks(rawCipher, 16); plain = b''; for block in cipherBlocks: ecbOut = aes_ecb_dec(block, rawKey); cbcOut = hexToRaw(hex_xor(rawToHex(ecbOut), rawToHex(rawIV))); rawIV = block; plain += cbcOut; return plain;
def decryptAndParseProfile(encProfile): decProfile = aes_ecb_dec(encProfile, aesKey) decProfile = removePKCS7Padding(decProfile) profile = parseKeyValue(decProfile.decode('UTF-8')) return profile
def decryptAndParseProfile(encProfile): decProfile = aes_ecb_dec(encProfile, aesKey); decProfile = removePKCS7Padding(decProfile); profile = parseKeyValue(decProfile.decode('UTF-8')); return profile;