diff options
Diffstat (limited to 'apps/files_external/lib/Lib/Auth/PublicKey/RSA.php')
-rw-r--r-- | apps/files_external/lib/Lib/Auth/PublicKey/RSA.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php index cb387b22012..8dedf8c5196 100644 --- a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php +++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php @@ -35,8 +35,6 @@ use \phpseclib\Crypt\RSA as RSACrypt; */ class RSA extends AuthMechanism { - const CREATE_KEY_BITS = 1024; - /** @var IConfig */ private $config; @@ -69,14 +67,19 @@ class RSA extends AuthMechanism { /** * Generate a keypair * + * @param int $keyLenth * @return array ['privatekey' => $privateKey, 'publickey' => $publicKey] */ - public function createKey() { + public function createKey($keyLength) { $rsa = new RSACrypt(); $rsa->setPublicKeyFormat(RSACrypt::PUBLIC_FORMAT_OPENSSH); $rsa->setPassword($this->config->getSystemValue('secret', '')); - return $rsa->createKey(self::CREATE_KEY_BITS); + if ($keyLength !== 1024 && $keyLength !== 2048 && $keyLength !== 4096) { + $keyLength = 1024; + } + + return $rsa->createKey($keyLength); } } |