Results 1 to 7 of 7

Thread: AES-256 encryption along with ECB mode & PKCS7Padding

  1. #1
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default AES-256 encryption along with ECB mode & PKCS7Padding

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: AES-256 encryption along with ECB mode & PKCS7Padding

    OpenSSL can handle that. However using AES with ECB is not that safe, you know.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: AES-256 encryption along with ECB mode & PKCS7Padding

    Quote Originally Posted by wysota View Post
    OpenSSL can handle that.
    Thanks, but we would like to know if any Qt abstractions (like QCA) are available for the mentioned package.



    Quote Originally Posted by wysota View Post
    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: AES-256 encryption along with ECB mode & PKCS7Padding

    Quote Originally Posted by sattu View Post
    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
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: AES-256 encryption along with ECB mode & PKCS7Padding

    Quote Originally Posted by wysota View Post
    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.


    Quote Originally Posted by wysota View Post
    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: AES-256 encryption along with ECB mode & PKCS7Padding

    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:

    Qt Code:
    1. QwwCipher cipher;
    2. cipher.setCipher("aes-256-ecb");
    3. cipher.setKey("0123456789ABCDEF");
    4. cipher.setIv(QByteArray(16,0));
    5. cipher.setInput(...);
    6. cipher.setOutput(...);
    7. cipher.encrypt();
    To copy to clipboard, switch view to plain text mode 

    or just simply:

    Qt Code:
    1. QByteArray out = qEncrypt("aes-256-ecb", indata, inkey, QByteArray());
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 12th October 2012 at 12:34.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    sattu (12th October 2012)

  8. #7
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: AES-256 encryption along with ECB mode & PKCS7Padding

    That's great. Will google out all of them as soon as i am free. Thanks a lot Wysota.

Similar Threads

  1. Replies: 2
    Last Post: 4th June 2012, 12:56
  2. Replies: 1
    Last Post: 7th March 2012, 21:34
  3. Replies: 1
    Last Post: 2nd November 2009, 12:02
  4. Replies: 9
    Last Post: 15th April 2009, 06:23
  5. Replies: 8
    Last Post: 10th October 2007, 18:20

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.