Results 1 to 4 of 4

Thread: Problem in crypto :: RSA

  1. #1
    Join Date
    Mar 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Problem in crypto :: RSA

    I am writing a client software in QT 4.5 Commercial edition that need to send rsa encrypted data to server.
    Steps are these:
    1. get public key from server. The server gives (mod,exp) pair and nothing else
    2. I need to encrypt data using "basic rsa" using the (mod,exp) and send to the server.

    I am doing this to encrypt:

    Qt Code:
    1. QString eee("22640209");//exp: got from server
    2.  
    3. QString mmm("95033496681677513042303794296510796923484007896833482880191206334940729008671");//mod:got from server
    4.  
    5. QCA::BigInteger exp11(eee);
    6. QCA::BigInteger mod11(mmm);
    7.  
    8. public_key = new QCA::RSAPublicKey(mod11,exp11,"rsa");
    9.  
    10. QCA::SecureArray data = "27712887867";
    11. QCA::SecureArray sarray = public_key->encrypt(data,QCA::EncryptionAlgorithm::EME_PKCS1v15);
    12.  
    13. QString sss(sarray.toByteArray());
    14. QString rstr = QCA::arrayToHex(sarray.toByteArray());
    To copy to clipboard, switch view to plain text mode 
    But, the problem is, the result never matches with the expected result (from a working java applicaton for same purpose which uses Bouncy Castle)

    The correct output for the message "22640209" should be "7fcbaf7722eed6bf8914a924ac03de7e825d492f10a1487c8 4eb5d94989c5e91"

    I am stuck and I have a deadline coming.

    Any help is welcome.

    Regards
    Sarwar Erfan

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

    Default Re: Problem in crypto :: RSA

    What encryption mode are you using? Maybe the two applications use different modes?
    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
    Mar 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem in crypto :: RSA

    Thanks for your reply.
    How do I change encryption mode in qt crypto?

  4. #4
    Join Date
    Nov 2008
    Posts
    142
    Thanks
    3
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem in crypto :: RSA

    I don't know much about QCA, but according to the documentation QCA::Cipher provides a Mode enum, so you can probably use this class to create a cipher with the mode your server is expecting.

    If you are not sure what that mode would be, have a look at the Java code. If it is some non-standard mode, it should be set somewhere in the code. Otherwise, it would be the default that BouncyCastle uses, so you should look at it's documentation to find out what that default is.

Similar Threads

  1. Replies: 5
    Last Post: 19th November 2008, 17:54
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.