Update the server to expect a base64 encoded string as the encrypted string (for JSON transport).

This commit is contained in:
Ken Moore
2016-02-19 16:07:39 -05:00
parent 2bd77b9882
commit 9bb9add1db

View File

@@ -330,7 +330,10 @@ void AuthorizationManager::ClearHostFail(QString host){
}
QString AuthorizationManager::DecryptSSLString(QString encstring, QString pubkey){
qDebug() << "Decrypt String:" << "Length:" << encstring.length() << encstring;
//Convert from the base64 string back to a byte array
QByteArray enc = QByteArray::fromBase64(encstring.toLatin1());
qDebug() << "Decrypt String:" << "Length:" << enc.length() << enc;
qDebug() << " - Base64:" << encstring;
unsigned char decode[4098] = {};
RSA *rsa= NULL;
BIO *keybio = NULL;
@@ -340,10 +343,10 @@ QString AuthorizationManager::DecryptSSLString(QString encstring, QString pubkey
qDebug() << " - Read pubkey";
rsa = PEM_read_bio_RSA_PUBKEY(keybio, &rsa,NULL, NULL);
qDebug() << " - Decrypt string";
bool ok = (-1 != RSA_public_decrypt(encstring.length(), (unsigned char*)(encstring.toLatin1().data()), decode, rsa, RSA_PKCS1_PADDING) );
bool ok = (-1 != RSA_public_decrypt(enc.length(), (unsigned char*)(enc.data()), decode, rsa, RSA_PKCS1_PADDING) );
qDebug() <<" - Success:" << ok;
if(!ok){ return ""; }
else{ return QString::fromLatin1( (char *)(decode) ).simplified(); }
else{ return QString::fromLatin1( (char*)(decode) ); }
}
/*