×

Discussion Board

Results 1 to 11 of 11

Thread: AES encryption

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    279

    AES encryption

    Hello,
    How can I encrypt/decrypt data using AES ?

    I couldn't find anything in the wiki.

  2. #2
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: AES encryption

    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: AES encryption

    Hi,

    Here is one example of AES buffer encryption of files

    Also, there is this thread which has discussion on similar topic

  4. #4
    Registered User
    Join Date
    Jan 2006
    Posts
    279

    Re: AES encryption

    Thank you for your answers!
    I am new to QT and I guess I prefer to use the Symbian native code, but I am not sure how to set the Initiliazing Vector.
    Can you give me a hint on this?

    Thanks again!

  5. #5
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: AES encryption

    Check for QVector.
    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

  6. #6
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: AES encryption

    Hi,

    Did you already check the links shared before (the symbian ones). The code in the wiki reads from file and encrypts.

  7. #7
    Registered User
    Join Date
    Jan 2006
    Posts
    279

    Re: AES encryption

    Quote Originally Posted by kusumk View Post
    Hi,

    Did you already check the links shared before (the symbian ones). The code in the wiki reads from file and encrypts.
    Yes, but the example has only KAESKey, it does not have IV set.
    I have to set the key and the IV for the AES encoding

  8. #8
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: AES encryption

    Hi,

    Did you see this
    It would give you an idea of how it has to be defined, for processing you need to go by the algorithm/available implementations.

  9. #9
    Registered User
    Join Date
    Jan 2006
    Posts
    279

    Re: AES encryption

    What I did is use openssl library that were in the symbian qt sdk (I am new to QT and please correct me if I am using some of the built-in object in a wrong way)
    But now I am not able to compile on QT simulator, any ideas?
    Code:
    #ifdef Q_OS_SYMBIAN
    #include <stdapis/openssl/aes.h>
    #include <stdapis/openssl/evp.h>
    #endif
    
    #ifdef MEEGO_EDITION_HARMATTAN
    #include <openssl/aes.h>
    #include <openssl/evp.h>
    #endif
    
    
    QByteArray aes_encrypt( const QByteArray aTextToEncode )
    {
        EVP_CIPHER_CTX cipherContext;
        EVP_CIPHER_CTX_init( &cipherContext );
    
        const unsigned char* key = (const unsigned char*) "enter 32 bytes key";
        const unsigned char* iv =  (const unsigned char*) "enter 16 bytes vector";
    
        EVP_EncryptInit_ex( &cipherContext, EVP_aes_256_cbc(), NULL, key, iv);
    
        QByteArray encodedText;
        encodedText.resize( aTextToEncode.length() + AES_BLOCK_SIZE + 100 );
    
        int c_len = 0;
        EVP_EncryptUpdate( &cipherContext, ( unsigned char* ) encodedText.data(), &c_len, ( unsigned char* ) aTextToEncode.constData(), aTextToEncode.length() );
    
        qDebug("Encoded length: %d", c_len );
        /* update encodedText with the final remaining bytes */
        int f_len = 0;
        EVP_CipherFinal_ex( &cipherContext, ( unsigned char* ) encodedText.data() + c_len, &f_len );
        qDebug("Encoded final length: %d", f_len );
    
        EVP_CIPHER_CTX_cleanup( &cipherContext );
        encodedText.resize( c_len + f_len );
        return encodedText;
    }
    
    QString aesEncodeAndBase64( QString aTextToEncode )
    {
        QByteArray encodedText = aes_encrypt( aTextToEncode.toAscii() );
        QString res = encodedText.toBase64();
        qDebug("Encoded string %s", qPrintable( res ) );
        return res;
    }
    Last edited by microsoft2; 2012-04-19 at 16:14.

  10. #10
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: AES encryption

    Hi,

    Did you include the library details in the symbian section of your .pro file?

    Please check this section for more clarity on how to use symbian libs with QT.

  11. #11
    Registered User
    Join Date
    Jan 2006
    Posts
    279

    Re: AES encryption

    Yes, working ok on symbian and harmattan device
    In my .pro file I specified
    Code:
    symbian: LIBS += -llibcrypto
    contains(MEEGO_EDITION,harmattan): LIBS += -lcrypto
    The only problem is that the emulator does not have evp.h and I have to develop on device

Similar Threads

  1. AES 256 encryption
    By bejoy_ak in forum Mobile Java General
    Replies: 1
    Last Post: 2010-07-20, 18:07
  2. SMS Encryption
    By jayakrishnan.salim in forum Mobile Java General
    Replies: 16
    Last Post: 2009-07-13, 06:26
  3. A5/3 Encryption
    By daverunt in forum General Development Questions
    Replies: 1
    Last Post: 2009-01-16, 11:12
  4. Help with .png encryption
    By mugiwara in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2008-10-27, 08:12
  5. Encryption
    By kolkattakid in forum Symbian
    Replies: 0
    Last Post: 2004-05-31, 18:32

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×