From b0129e91256b66372c07ba956e7c41d5bee6848f Mon Sep 17 00:00:00 2001 From: Ha Phan Date: Tue, 6 Jan 2015 15:27:30 +0700 Subject: [PATCH] Compare numeric part of OpenSSL version --- phpseclib/Crypt/RSA.php | 13 ++++++++++--- phpseclib/Math/BigInteger.php | 9 ++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 793eecc7..53f94354 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -515,9 +515,16 @@ class Crypt_RSA $versions = array(); if (!empty($matches[1])) { - for ($i = 0; $i < count($matches[1]); $i++) { - $versions[$matches[1][$i]] = trim(str_replace('=>', '', strip_tags($matches[2][$i]))); - } + for ($i = 0; $i < count($matches[1]); $i++) { + $fullVersion = trim(str_replace('=>', '', strip_tags($matches[2][$i]))); + + // Remove letter part in OpenSSL version + if (!preg_match('/(\d+\.\d+\.\d+)/i', $fullVersion, $m)) { + $versions[$matches[1][$i]] = $fullVersion; + } else { + $versions[$matches[1][$i]] = $m[0]; + } + } } // it doesn't appear that OpenSSL versions were reported upon until PHP 5.3+ diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 5753584c..8e54f741 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -278,7 +278,14 @@ class Math_BigInteger $versions = array(); if (!empty($matches[1])) { for ($i = 0; $i < count($matches[1]); $i++) { - $versions[$matches[1][$i]] = trim(str_replace('=>', '', strip_tags($matches[2][$i]))); + $fullVersion = trim(str_replace('=>', '', strip_tags($matches[2][$i]))); + + // Remove letter part in OpenSSL version + if (!preg_match('/(\d+\.\d+\.\d+)/i', $fullVersion, $m)) { + $versions[$matches[1][$i]] = $fullVersion; + } else { + $versions[$matches[1][$i]] = $m[0]; + } } }