Merge pull request #18024 from owncloud/phpseclib-2.0
Update phpseclib to 2.0 for increased PHP7 compatibility
This commit is contained in:
commit
728780aee8
6 changed files with 29 additions and 26 deletions
2
3rdparty
2
3rdparty
|
@ -1 +1 @@
|
|||
Subproject commit c45d817921543d2f0562ac4f3be61404b1d4a35e
|
||||
Subproject commit 0590498b38aa0c760e2ad7af4fbd19787d62ed4e
|
|
@ -25,6 +25,7 @@ namespace OCA\Files_External\Controller;
|
|||
use OCP\AppFramework\Controller;
|
||||
use OCP\IRequest;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use phpseclib\Crypt\RSA;
|
||||
|
||||
class AjaxController extends Controller {
|
||||
public function __construct($appName, IRequest $request) {
|
||||
|
@ -32,8 +33,8 @@ class AjaxController extends Controller {
|
|||
}
|
||||
|
||||
private function generateSshKeys() {
|
||||
$rsa = new \Crypt_RSA();
|
||||
$rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_OPENSSH);
|
||||
$rsa = new RSA();
|
||||
$rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_OPENSSH);
|
||||
$rsa->setPassword(\OC::$server->getConfig()->getSystemValue('secret', ''));
|
||||
|
||||
$key = $rsa->createKey();
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use phpseclib\Crypt\AES;
|
||||
|
||||
/**
|
||||
* Class to configure mount.json globally and for users
|
||||
*/
|
||||
|
@ -895,10 +897,7 @@ class OC_Mount_Config {
|
|||
* Returns the encryption cipher
|
||||
*/
|
||||
private static function getCipher() {
|
||||
if (!class_exists('Crypt_AES', false)) {
|
||||
include('Crypt/AES.php');
|
||||
}
|
||||
$cipher = new Crypt_AES(CRYPT_AES_MODE_CBC);
|
||||
$cipher = new AES(AES::MODE_CBC);
|
||||
$cipher->setKey(\OC::$server->getConfig()->getSystemValue('passwordsalt', null));
|
||||
return $cipher;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,12 @@
|
|||
*/
|
||||
namespace OC\Files\Storage;
|
||||
|
||||
use phpseclib\Net\RSA;
|
||||
use phpseclib\Net\SFTP;
|
||||
use phpseclib\Net\SFTP\Stream;
|
||||
|
||||
/**
|
||||
* Uses phpseclib's Net_SFTP class and the Net_SFTP_Stream stream wrapper to
|
||||
* Uses phpseclib's Net\SFTP class and the Net\SFTP\Stream stream wrapper to
|
||||
* provide access to SFTP servers.
|
||||
*/
|
||||
class SFTP extends \OC\Files\Storage\Common {
|
||||
|
@ -42,7 +46,7 @@ class SFTP extends \OC\Files\Storage\Common {
|
|||
private $port = 22;
|
||||
|
||||
/**
|
||||
* @var \Net_SFTP
|
||||
* @var SFTP
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
|
@ -51,10 +55,10 @@ class SFTP extends \OC\Files\Storage\Common {
|
|||
*/
|
||||
public function __construct($params) {
|
||||
// Register sftp://
|
||||
\Net_SFTP_Stream::register();
|
||||
Stream::register();
|
||||
|
||||
$this->host = $params['host'];
|
||||
|
||||
|
||||
//deals with sftp://server example
|
||||
$proto = strpos($this->host, '://');
|
||||
if ($proto != false) {
|
||||
|
@ -87,7 +91,7 @@ class SFTP extends \OC\Files\Storage\Common {
|
|||
/**
|
||||
* Returns the connection.
|
||||
*
|
||||
* @return \Net_SFTP connected client instance
|
||||
* @return SFTP connected client instance
|
||||
* @throws \Exception when the connection failed
|
||||
*/
|
||||
public function getConnection() {
|
||||
|
@ -96,7 +100,7 @@ class SFTP extends \OC\Files\Storage\Common {
|
|||
}
|
||||
|
||||
$hostKeys = $this->readHostKeys();
|
||||
$this->client = new \Net_SFTP($this->host, $this->port);
|
||||
$this->client = new SFTP($this->host, $this->port);
|
||||
|
||||
// The SSH Host Key MUST be verified before login().
|
||||
$currentHostKey = $this->client->getServerPublicHostKey();
|
||||
|
|
|
@ -22,10 +22,9 @@
|
|||
*/
|
||||
namespace OC\Files\Storage;
|
||||
|
||||
/**
|
||||
* Uses phpseclib's Net_SFTP class and the Net_SFTP_Stream stream wrapper to
|
||||
* provide access to SFTP servers.
|
||||
*/
|
||||
use phpseclib\Crypt\RSA;
|
||||
use phpseclib\Net\SFTP;
|
||||
|
||||
class SFTP_Key extends \OC\Files\Storage\SFTP {
|
||||
private $publicKey;
|
||||
private $privateKey;
|
||||
|
@ -39,7 +38,7 @@ class SFTP_Key extends \OC\Files\Storage\SFTP {
|
|||
/**
|
||||
* Returns the connection.
|
||||
*
|
||||
* @return \Net_SFTP connected client instance
|
||||
* @return SFTP connected client instance
|
||||
* @throws \Exception when the connection failed
|
||||
*/
|
||||
public function getConnection() {
|
||||
|
@ -48,7 +47,7 @@ class SFTP_Key extends \OC\Files\Storage\SFTP {
|
|||
}
|
||||
|
||||
$hostKeys = $this->readHostKeys();
|
||||
$this->client = new \Net_SFTP($this->getHost());
|
||||
$this->client = new SFTP($this->getHost());
|
||||
|
||||
// The SSH Host Key MUST be verified before login().
|
||||
$currentHostKey = $this->client->getServerPublicHostKey();
|
||||
|
@ -74,10 +73,10 @@ class SFTP_Key extends \OC\Files\Storage\SFTP {
|
|||
/**
|
||||
* Returns the private key to be used for authentication to the remote server.
|
||||
*
|
||||
* @return \Crypt_RSA instance or null in case of a failure to load the key.
|
||||
* @return RSA instance or null in case of a failure to load the key.
|
||||
*/
|
||||
private function getPrivateKey() {
|
||||
$key = new \Crypt_RSA();
|
||||
$key = new RSA();
|
||||
$key->setPassword(\OC::$server->getConfig()->getSystemValue('secret', ''));
|
||||
if (!$key->loadKey($this->privateKey)) {
|
||||
// Should this exception rather than return null?
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
|
||||
namespace OC\Security;
|
||||
|
||||
use Crypt_AES;
|
||||
use Crypt_Hash;
|
||||
use phpseclib\Crypt\AES;
|
||||
use phpseclib\Crypt\Hash;
|
||||
use OCP\Security\ICrypto;
|
||||
use OCP\Security\ISecureRandom;
|
||||
use OCP\Security\StringUtils;
|
||||
|
@ -41,7 +41,7 @@ use OCP\IConfig;
|
|||
* @package OC\Security
|
||||
*/
|
||||
class Crypto implements ICrypto {
|
||||
/** @var Crypt_AES $cipher */
|
||||
/** @var AES $cipher */
|
||||
private $cipher;
|
||||
/** @var int */
|
||||
private $ivLength = 16;
|
||||
|
@ -51,7 +51,7 @@ class Crypto implements ICrypto {
|
|||
private $random;
|
||||
|
||||
function __construct(IConfig $config, ISecureRandom $random) {
|
||||
$this->cipher = new Crypt_AES();
|
||||
$this->cipher = new AES();
|
||||
$this->config = $config;
|
||||
$this->random = $random;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class Crypto implements ICrypto {
|
|||
// Append an "a" behind the password and hash it to prevent reusing the same password as for encryption
|
||||
$password = hash('sha512', $password . 'a');
|
||||
|
||||
$hash = new Crypt_Hash('sha512');
|
||||
$hash = new Hash('sha512');
|
||||
$hash->setKey($password);
|
||||
return $hash->hash($message);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue