Is it possible to do AES ECB encryption using the python classes in slowaes?
The AESModeOfOperation
supports OFB, CFB & CBC modes. Is there a way to emulate ECB using one of these modes?
It is possible to use CBC with an IV value of all zero's (16 bytes valued '00' in hexadecimals).
Only encrypt a single block. If you get more than 16 bytes output then the plain text was padded before encryption; only use the first 16 bytes of output.
Now you've got a single block encrypt. ECB mode is simply a concatenation of single block encrypts. So you take 16 bytes of plain text, encrypt with the above, and let the result be the next 16 bytes of ciphertext.
Of course you may have to pad your message yourself, but that should not be too difficult.
you don't need to do anything special for ecb. just divide your message into blocks and encrypt each block using the "raw" aes (ie AES.encrypt()
in Python). similarly, to decrypt, call AES.decrypt()
for each block.
the other modes are more complicated, which is why the code in AESModeOfOperation
is needed for those.
as others have said, this is not secure. see the discussion at wikipedia (in particular, look at the penguin images).