Results 1 to 5 of 5

Thread: QCA TripleDes

  1. #1
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default QCA TripleDes

    Sorry if this doesn't belong in this one. Wasn't sure where do forgive me.

    I'm trying to use QCA with 3DES. It works fine when using it for HMac(Sha1) but when I use it for 3DES. I get a segmentation fault. I have support for it. I've tried every combination. I've looked in the doc. But no luck. Unless I remove the des3key and iv from it. But I need that to be in it.

    Qt Code:
    1. MSNCrypto::mbiEncrypt ( QString& ssoKey, QString& nonce )
    2. {
    3. QString magic1 = "WS-SecureConversationSESSION KEY HASH";
    4. QString magic2 = "WS-SecureConversationSESSION KEY ENCRYPTION";
    5. // three keys needed for the encryption process.
    6. QString key1, key2, key3;
    7. // hash object.
    8. QByteArray hash;
    9. const char* hmacsha1 = "hmac(sha1)";
    10. const char* tripledes = "tripledes-cbc";
    11. // create the base64 decoder.
    12. QCA::Base64 decoder(QCA::Decode);
    13.  
    14. // decode the sso key.
    15. key1 = decoder.decodeString(ssoKey);
    16. // debugging purposes.
    17. qDebug() << "key1: " << key1;
    18. // get the derive key and encrypt it with the magic string.
    19. key2 = deriveKey(key1, magic1);
    20. // debugging purposes.
    21. qDebug() << "key2: " << key2;
    22. // get the derive key and encrypt it with the second magic string.
    23. key3 = deriveKey(key1, magic2);
    24. // debugging purposes.
    25. qDebug() << "key3: " << key3;
    26.  
    27. if(!QCA::isSupported(hmacsha1) && !QCA::isSupported(tripledes)) {
    28. qFatal("[ERROR] Does not support HMAC SHA1 or TRIPLE DES CBC");
    29. } else {
    30. // create the hmac object.
    31. QCA::MessageAuthenticationCode hmac(hmacsha1, QCA::SecureArray());
    32. // create the key.
    33. QCA::SymmetricKey key(key1.toLatin1());
    34. // create the triple des key.
    35. QCA::SymmetricKey des3key(key3.toLatin1());
    36. // setup the key to be used.
    37. hmac.setup(key);
    38. // create the secure array.
    39. QCA::SecureArray data(nonce.toUtf8());
    40. // update the data.
    41. hmac.update(data);
    42. // no more updates after calling final.
    43. hash = hmac.final().toByteArray();
    44. // debugging purposes.
    45. qDebug() << "mbiHash: " << hash;
    46.  
    47. // create the initalization vector with 8 random bytes.
    48. QCA::InitializationVector iv(8);
    49.  
    50. // create the triple des cipher object.
    51. QCA::Cipher cipher(QString("tripledes"), QCA::Cipher::CBC, QCA::Cipher::DefaultPadding, QCA::Encode, des3key, iv);
    52. //cipher.setup(QCA::Decode, des3key, iv);
    53. }
    54. return "";
    55. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QCA TripleDes

    Could you provide a simple compilable example which produces the crash so we don't have to write a test application around provided code to test it...? Also, which version of QCA did you try with?
    J-P Nurmi

  3. #3
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QCA TripleDes

    I'm using the latest version in gentoo portage

    qca-2.0.0-r2
    qca-cyrus-sasl 2.0.0-beta3
    qca-gnupg 2.0.0-beta2
    qca-logger 2.0.0-beta2
    qca-ossl 2.0.0-beta3
    qca-pkcs11 2.0.0-beta2
    qca-tls 1.0-r4
    Attached Files Attached Files

  4. #4

    Default Re: QCA TripleDes

    // the Initializer object sets things up, and
    // also does cleanup when it goes out of scope
    QCA::Initializer init;

  5. #5
    Join Date
    Dec 2013
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QCA TripleDes

    set padding as QCA::Cipher::NoPadding instead of default( means PKCS7) padding .

    QCA::Cipher cipher(QString("tripledes"), QCA::Cipher::CBC, QCA::Cipher::NoPadding, QCA::Encode, des3key, iv);

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.