diff --git a/cli/Commands/OAuth2/Keys.php b/cli/Commands/OAuth2/Keys.php index c9c073836fca83ef4b3609a78655001b77bbe6f5..8274dbc7b4831f1953ef2fae86224bc72e55f530 100644 --- a/cli/Commands/OAuth2/Keys.php +++ b/cli/Commands/OAuth2/Keys.php @@ -2,7 +2,7 @@ namespace Studip\Cli\Commands\OAuth2; -use phpseclib\Crypt\RSA; +use phpseclib3\Crypt\RSA; use Studip\OAuth2\Container; use Studip\OAuth2\KeyInformation; use Studip\OAuth2\SetupInformation; @@ -46,7 +46,7 @@ class Keys extends Command $this->storeKeyContentsToFile($encryptionKey, $this->generateEncryptionKey()); - $keys = (new RSA())->createKey(4096); + $keys = RSA::createKey(4096); $this->storeKeyContentsToFile($publicKey, $keys['publickey']); $this->storeKeyContentsToFile($privateKey, $keys['privatekey']); diff --git a/composer.json b/composer.json index 4257135f2054d6c44992fe0216fdb91904b31080..bcd3ee055eb1247b2ad66925b33456971d4508a6 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "phpxmlrpc/extras": "^0.6.2", "algo26-matthias/idna-convert": "^3.0", "caxy/php-htmldiff": "^0.1.9", - "phpseclib/phpseclib": "^2.0", + "phpseclib/phpseclib": "^3", "ext-gd": "*", "ext-gettext": "*", "ext-pdo_mysql": "*", diff --git a/composer.lock b/composer.lock index 0e9eea0a7b96fd9b4c79415da90ff94c8b4a2e38..be96584ff1acb411d7cb08a9f69d07171905a681 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e5a2c38d2da4fc895b77b9575107b066", + "content-hash": "b7e85080cec3bd84bb509a9b89bdc107", "packages": [ { "name": "algo26-matthias/idna-convert", @@ -2013,32 +2013,32 @@ }, { "name": "phpseclib/phpseclib", - "version": "2.0.38", + "version": "3.0.19", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "b03536539f43a4f9aa33c4f0b2f3a1c752088fcd" + "reference": "cc181005cf548bfd8a4896383bb825d859259f95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/b03536539f43a4f9aa33c4f0b2f3a1c752088fcd", - "reference": "b03536539f43a4f9aa33c4f0b2f3a1c752088fcd", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/cc181005cf548bfd8a4896383bb825d859259f95", + "reference": "cc181005cf548bfd8a4896383bb825d859259f95", "shasum": "" }, "require": { - "php": ">=5.3.3" + "paragonie/constant_time_encoding": "^1|^2", + "paragonie/random_compat": "^1.4|^2.0|^9.99.99", + "php": ">=5.6.1" }, "require-dev": { - "phing/phing": "~2.7", - "phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "*" }, "suggest": { + "ext-dom": "Install the DOM extension to load XML formatted public keys.", "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", - "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations.", - "ext-xml": "Install the XML extension to load XML formatted public keys." + "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." }, "type": "library", "autoload": { @@ -2046,7 +2046,7 @@ "phpseclib/bootstrap.php" ], "psr-4": { - "phpseclib\\": "phpseclib/" + "phpseclib3\\": "phpseclib/" } }, "notification-url": "https://packagist.org/downloads/", @@ -2103,7 +2103,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/2.0.38" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.19" }, "funding": [ { @@ -2119,7 +2119,7 @@ "type": "tidelift" } ], - "time": "2022-09-02T17:04:26+00:00" + "time": "2023-03-05T17:13:09+00:00" }, { "name": "phpxmlrpc/extras", diff --git a/lib/models/OERIdentity.php b/lib/models/OERIdentity.php index 71322e8101a2c362c9c292ee36defd3869b75aeb..8c627284c7ffb75e89864fb0ac1b809441e364f2 100644 --- a/lib/models/OERIdentity.php +++ b/lib/models/OERIdentity.php @@ -1,5 +1,7 @@ <?php +use phpseclib3\Crypt\RSA; + abstract class OERIdentity extends SimpleORMap { /** @@ -14,16 +16,12 @@ abstract class OERIdentity extends SimpleORMap public function createSignature($text) { - $rsa = new \phpseclib\Crypt\RSA(); - $rsa->loadKey($this['private_key']); - return $rsa->sign($text); + return RSA::loadPrivateKey($this['private_key'])->sign($text); } public function verifySignature($text, $signature) { - $rsa = new \phpseclib\Crypt\RSA(); - $rsa->loadKey($this['public_key']); - return $rsa->verify($text, $signature); + return RSA::loadPublicKey($this['public_key'])->verify($text, $signature); } public function cbCreateKeysIfNecessary() @@ -33,9 +31,9 @@ abstract class OERIdentity extends SimpleORMap } } - protected function createKeys() { - $rsa = new \phpseclib\Crypt\RSA(); - $keypair = $rsa->createKey(4096); + protected function createKeys() + { + $keypair = RSA::createKey(4096); $this['private_key'] = preg_replace("/\r/", "", $keypair['privatekey']); $this['public_key'] = preg_replace("/\r/", "", $keypair['publickey']); }