Archived Forum Post

Index of archived forum posts


RSA chilkat and openssl

Jul 19 '15 at 22:57

Hello, i have troubles with chilkat rsa.

i'm trying:

QString akey = "<rsakeyvalue><modulus>" + mod + "</modulus><exponent>" + exp + "</exponent></rsakeyvalue>";
QString password = rsa->encryptStringENC("abcd", false);

All ok, but Steam can't recognize this. Alternative code with openssl work good!

publickey = RSA_new();
        BIGNUM *publickey_mod = BN_new();
        BIGNUM *publickey_exp = BN_new();

//QString -> String -> Char* -> BIGNUM
        BN_hex2bn(&publickey_mod, modulus.toStdString().c_str());
        BN_hex2bn(&publickey_exp, exponent.toStdString().c_str());

//Adds data to RSA publickey
        publickey->n = publickey_mod;
        publickey->e = publickey_exp;
    encrypted = new unsigned char[RSA_size(publickey)];

if (RSA_public_encrypt(input.length(), reinterpret_cast<const unsigned="" char="" *="">(input.toStdString().c_str()), encrypted, &(*publickey), RSA_PKCS1_PADDING) == -1)
            delete[] encrypted;
            encrypted = NULL;


On JavaScript Steam have code:

var pubKey = RSA.getPublicKey( results.publickey_mod, results.publickey_exp );
var encryptedPassword = RSA.encrypt( password, pubKey );