×

Discussion Board

Results 1 to 7 of 7

Hybrid View

  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    19

    Question AES encryption problem

    Hello,

    I am facing a problem using the AES decryption that I got from link
    My function exits and doesn't continue the algorithm after the execution of the following line of code
    Code:
    bufDecryptor->ProcessFinalL(plainTextPtr,cipherTextPtr);
    I have surfed the web, and I've found several issues with same problem without any solution.
    So can anyone help me with this issue ?
    Kindly find below the function I am using for decryption.
    Code:
    QString MainWindow::decryptData(QString dataToDecrypt,QString keyOfDecryption)
    {
        TPtrC16 textPtr1(reinterpret_cast<const TUint16*>(keyOfDecryption.utf16()));
        HBufC8 *pHeap81 = HBufC8::NewMaxLC(textPtr1.Length());
        pHeap81->Des().Copy(textPtr1);
        TPtr8 aKey = pHeap81->Des();
        TPtr8 aIv = pHeap81->Des();
        QString enc(QByteArray::fromBase64(dataToDecrypt.toAscii()));
        RFs fsSession;
        User::LeaveIfError(fsSession.Connect());
        TPtrC16 textPtr(reinterpret_cast<const TUint16*>(enc.utf16()));
        HBufC8 *pHeap8 = HBufC8::NewMaxLC(textPtr.Length());
        pHeap8->Des().Copy(textPtr);
        TPtr8 plainTextPtr = pHeap8->Des();
        CAESDecryptor* method = CAESDecryptor::NewL(aKey);
        CModeCBCDecryptor* mode = CModeCBCDecryptor::NewL(method, aIv);
        CPadding* padding = CPaddingPKCS7::NewL(method->BlockSize());
        CBufferedDecryptor* bufDecryptor = CBufferedDecryptor::NewL(mode, padding);
        HBufC8* cipherText = HBufC8::NewL(bufDecryptor->MaxFinalOutputLength(plainTextPtr.Size()));
        TPtr8 cipherTextPtr = cipherText->Des();
        bufDecryptor->ProcessFinalL(plainTextPtr,cipherTextPtr);
        QString result3;
        result3=QString::fromAscii((const char *)cipherText->Ptr(), cipherText->Length());
        CleanupStack::PopAndDestroy();
        CleanupStack::PopAndDestroy();
        return result3;
    }
    Note that there is something so weird about it; Sometimes I am able to decrypt some encrypted data with the same algorithm,and sometimes it fails for another encrypted data.

    Best Regards,
    elippo

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: AES encryption problem

    Might help if you get the panic/leave code, it might give good ideas on what is going wrong in there.

  3. #3
    Registered User
    Join Date
    Apr 2013
    Posts
    19

    Re: AES encryption problem

    Quote Originally Posted by symbianyucca View Post
    Might help if you get the panic/leave code, it might give good ideas on what is going wrong in there.
    I got on my debug screen
    Active object (ptr=0x00903648, vptr=0x7d944a8c) leave: -6
    and using Y-task I got the following error ( JavaCommsClient-10000-0x13075fd0-621051169 Kill : 4320892 )

    Any idea ?

  4. #4
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: AES encryption problem

    -6 if that is really error code, would indicate bad request: http://www.developer.nokia.com/Commu...OS_Error_Codes , so you should check what kind of values you are supposed to give to the function

  5. #5
    Registered User
    Join Date
    Apr 2013
    Posts
    19

    Re: AES encryption problem

    Does anyone have an idea why the decryptData function works for some strings, and fails on others.

    Best Regards

  6. #6
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: AES encryption problem

    Not certain if it helps, but can you check whether it is related to the code string lenght ? or any other issue which would make the string different.

    The paddign there should take care of the right sizing, anyway, can you check that cipherText really is 16-bytes dividable, and not 8 bytes in all cases..

Similar Threads

  1. aes encryption problem
    By sh3at in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2011-07-06, 21:13
  2. encryption problem
    By sh3at in forum Symbian C++
    Replies: 3
    Last Post: 2011-07-02, 07:42
  3. Encryption problem
    By danhicksbyron in forum Symbian C++
    Replies: 3
    Last Post: 2010-06-01, 20:14
  4. encryption problem
    By sujoydas in forum Symbian C++
    Replies: 3
    Last Post: 2006-10-16, 08:24
  5. Encryption Problem
    By V R Krishna in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2004-05-27, 08:01

Posting Permissions

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