erfanonline
21st March 2009, 13:49
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:
QString eee("22640209");//exp: got from server
QString mmm("95033496681677513042303794296510796923484007896833 482880191206334940729008671");//mod:got from server
QCA::BigInteger exp11(eee);
QCA::BigInteger mod11(mmm);
public_key = new QCA::RSAPublicKey(mod11,exp11,"rsa");
QCA::SecureArray data = "27712887867";
QCA::SecureArray sarray = public_key->encrypt(data,QCA::EncryptionAlgorithm::EME_PKCS1v1 5);
QString sss(sarray.toByteArray());
QString rstr = QCA::arrayToHex(sarray.toByteArray());
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 "7fcbaf7722eed6bf8914a924ac03de7e825d492f10a1487c84 eb5d94989c5e91"
I am stuck and I have a deadline coming.
Any help is welcome.
Regards
Sarwar Erfan
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:
QString eee("22640209");//exp: got from server
QString mmm("95033496681677513042303794296510796923484007896833 482880191206334940729008671");//mod:got from server
QCA::BigInteger exp11(eee);
QCA::BigInteger mod11(mmm);
public_key = new QCA::RSAPublicKey(mod11,exp11,"rsa");
QCA::SecureArray data = "27712887867";
QCA::SecureArray sarray = public_key->encrypt(data,QCA::EncryptionAlgorithm::EME_PKCS1v1 5);
QString sss(sarray.toByteArray());
QString rstr = QCA::arrayToHex(sarray.toByteArray());
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 "7fcbaf7722eed6bf8914a924ac03de7e825d492f10a1487c84 eb5d94989c5e91"
I am stuck and I have a deadline coming.
Any help is welcome.
Regards
Sarwar Erfan