If Mallory wants to trick Bob the Investigator into thinking that he is sending plain text, then he can covert the cipher text into a plain text format. In the following Mallory converts the cipher text using RFC 1751, and which converts 11 bits values to a word (where there are 2^11 words):
Cipher text converted to plain text |
Code
The following is an outline of the code:
import sys import os import binascii from Crypto.Util import RFC1751 from Crypto.Cipher import AES import hashlib import sys import binascii import Padding plaintext='hello' password='hello' if (len(sys.argv)>1): plaintext=str(sys.argv[1]) plaintext=plaintext.replace("#"," ") def encrypt(plaintext,key, mode): encobj = AES.new(key,mode) return(encobj.encrypt(plaintext)) def decrypt(ciphertext,key, mode): encobj = AES.new(key,mode) return(encobj.decrypt(ciphertext)) key = hashlib.sha256(password.encode()).digest() plaintext = Padding.appendPadding(plaintext,blocksize=Padding.AES_blocksize,mode=0) print("Input data (CMS): ",binascii.hexlify(plaintext.encode())) print() ciphertext = encrypt(plaintext.encode(),key,AES.MODE_ECB) print("Cipher (ECB): ",binascii.hexlify(bytearray(ciphertext))) print() y = RFC1751.key_to_english(ciphertext) print("Cipher to plain:\t",y) ciphertext = RFC1751.english_to_key(y) print("\n\nReverse:\t",binascii.hexlify(key)) print() plaintext = decrypt(ciphertext,key,AES.MODE_ECB) print(" decrypt: ",plaintext) plaintext = Padding.removePadding(plaintext.decode(),mode=0) print(" decrypt: ",plaintext)