mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Update the server to expect a base64 encoded string as the encrypted string (for JSON transport).
This commit is contained in:
@@ -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) ); }
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user