MIHCrypto
MIHCrypto copied to clipboard
Supporting ECB mode for AES Encryption
Hi @hohl ,
I know CBC mode for AES encryption is much secure than ECB mode, but as the server I'm connecting to has ECB mode of encryption/decryption I'm forced to use the same on the iOS client. Can you give me some pointers on implementing ECB mode in the MIHCrypto ?
Hey, @indiandragon
It shouldn't be too hard to extend MIHAESKey
to support ECB. Right now it is hardcoded to use the CBC chiper in lines 126 to 136 and lines 176 to 184. You could try to replace this hardcoded lines by adding for ex. a chiper
property to the MIHAESKey
class and then add a switch
construct in those lines.
The EVP_aes_256_cbc()
function used in the above linked lines constructs the chiper (256 bit CBC chiper for AES) which is then used in the lines below for the encryption process. There must be some similar chiper function for ECB
too in the OpenSSL documentation.
Hey @hohl , thanks for the information. I'll update when I implement the same.