D
D
dvachek2015-08-15 21:03:57
RSA
dvachek, 2015-08-15 21:03:57

I use php to authorize steam through the site, does RSA behave strangely?

I'm trying to write a script for authorization on the site steamcommunity.com in php. On the site itself, the password is encrypted with a public key before being sent. And so on php I had a very strange crap, the string is encrypted for some reason 1 time out of 10! 9 times it gives false instead of a cipher, as well as 1 warning and 1 notice, and on the 10th time it gives out an encrypted string, and apparently incorrect.
Encrypted messages:

Warning: openssl_public_encrypt(): key parameter is not a valid public key in /Steam/phpseclib/Math/BigInteger.php on line 1703
Notice: Integer too large in /Steam/phpseclib/Crypt/RSA.php on line 2133

For the 10th time these messages do not issue! Gives the encrypted string!
Encryption code:
$rsa = new \Crypt_RSA(); 
        $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
        $public_key = [
             "modulus" => new \Math_BigInteger($result->publickey_mod, 16),
             "publicExponent" => new \Math_BigInteger($result->publickey_exp, 16),
        ];
        $rsa->loadKey($public_key, CRYPT_RSA_PUBLIC_FORMAT_RAW);
        $encrypted_password = base64_encode($rsa->encrypt($pass));

The BigInteger and RSA classes are here: phpseclib.sourceforge.net
What's the problem here?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question