PDA

View Full Version : AES-256 encryption along with ECB mode & PKCS7Padding



sattu
12th October 2012, 07:39
Hi Everyone,

I had downloaded QCA package from the following link:-
http://delta.affinix.com/qca/

One of our basic requirement was that data should be encrypted using AES-256 symmetric algorithm (AES/ECB/PKCS7Padding). But in the downloaded package AES-256 encryption along with ECB mode & PKCS7Padding is not supported.

So can anyone guide us regarding any solution to the above mentioned problem?

wysota
12th October 2012, 09:09
OpenSSL can handle that. However using AES with ECB is not that safe, you know.

sattu
12th October 2012, 09:46
OpenSSL can handle that.
Thanks, but we would like to know if any Qt abstractions (like QCA) are available for the mentioned package.




However using AES with ECB is not that safe, you know.
Yes, that's correct. CBS mode is much better. But then that's the exact requirement AES-256 with ECB.

wysota
12th October 2012, 09:59
Thanks, but we would like to know if any Qt abstractions (like QCA) are available for the mentioned package.
QCA can use OpenSSL as its backend so I don't see why this set would not be possible to use. However encrypting using OpenSSL is so easy, you don't really need any abstractions.


Yes, that's correct. CBS mode is much better. But then that's the exact requirement AES-256 with ECB.
Well... suit yourself. If you encrypt less than 256 bits of data then ECB is as safe as any other mode ;)

sattu
12th October 2012, 12:22
QCA can use OpenSSL as its backend so I don't see why this set would not be possible to use.
I also was wondering that. The same combination if I try for CBS mode it works fine, but when it comes to ECB mode, QCA doesn't support it.



QCA can use OpenSSL as its backend so I don't see why this set would not be possible to use. However encrypting using OpenSSL is so easy, you don't really need any abstractions.
Well, hope it actually is easy. :) All I know is that If I ask you for some direct examples or links you won't give. So better let me google out for some openSSL examples. :rolleyes:

wysota
12th October 2012, 12:29
Have a look at EVP_get_cipherbyname, EVP_EncryptInit_ex, EVP_EncryptUpdate, EVP_EncryptFinal_ex, etc.

I have a very simple wrapper around those calls so in my case what you want would be achieved by:


QwwCipher cipher;
cipher.setCipher("aes-256-ecb");
cipher.setKey("0123456789ABCDEF");
cipher.setIv(QByteArray(16,0));
cipher.setInput(...);
cipher.setOutput(...);
cipher.encrypt();

or just simply:


QByteArray out = qEncrypt("aes-256-ecb", indata, inkey, QByteArray());

sattu
12th October 2012, 13:43
That's great. Will google out all of them as soon as i am free. Thanks a lot Wysota.