From 6686e203e7da58056a46f26890025aa2a20e58d7 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 18 Sep 2012 05:17:14 -0500 Subject: [PATCH] Reformat keys even if private key format is the same OpenSSL uses As is private keys weren't being encrypted when a private key was being set and OpenSSL was being used. Thanks TeigneuX! --- phpseclib/Crypt/RSA.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 71955082..f38a0294 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -510,10 +510,8 @@ class Crypt_RSA { $publickey = openssl_pkey_get_details($rsa); $publickey = $publickey['key']; - if ($this->privateKeyFormat != CRYPT_RSA_PRIVATE_FORMAT_PKCS1) { - $privatekey = call_user_func_array(array($this, '_convertPrivateKey'), array_values($this->_parseKey($privatekey, CRYPT_RSA_PRIVATE_FORMAT_PKCS1))); - $publickey = call_user_func_array(array($this, '_convertPublicKey'), array_values($this->_parseKey($publickey, CRYPT_RSA_PUBLIC_FORMAT_PKCS1))); - } + $privatekey = call_user_func_array(array($this, '_convertPrivateKey'), array_values($this->_parseKey($privatekey, CRYPT_RSA_PRIVATE_FORMAT_PKCS1))); + $publickey = call_user_func_array(array($this, '_convertPublicKey'), array_values($this->_parseKey($publickey, CRYPT_RSA_PUBLIC_FORMAT_PKCS1))); // clear the buffer of error strings stemming from a minimalistic openssl.cnf while (openssl_error_string() !== false);