From 25e08bc8a0037a3332d016f0491fff4da7b04b2c Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 5 Jun 2017 15:42:25 +0200 Subject: Allow 2048 and 4096 bit SFTP keys Signed-off-by: Roeland Jago Douma --- apps/files_external/lib/Lib/Auth/PublicKey/RSA.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'apps/files_external/lib/Lib/Auth/PublicKey') diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php index cb387b22012..6e7ab0e6fde 100644 --- a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php +++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php @@ -69,14 +69,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); } } -- cgit v1.2.3