aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-07-05 11:37:14 +0200
committerCarl Schwan <carl@carlschwan.eu>2022-07-05 11:37:14 +0200
commit1c23c029af1ef83935badb8b63cb4dffac59b1e4 (patch)
tree647370899a380f3e77906875428c289f7b4c936e /lib
parentcdf3b60555eb559ea5f9b141903054afbc273062 (diff)
downloadnextcloud-server-1c23c029af1ef83935badb8b63cb4dffac59b1e4.tar.gz
nextcloud-server-1c23c029af1ef83935badb8b63cb4dffac59b1e4.zip
Handler large passwords
For passwords bigger than 250 characters, use a bigger key since the performance impact is minor (around one second to encrypt the password). For passwords bigger than 470 characters, give up earlier and throw exeception recommanding admin to either enable the previously enabled configuration or use smaller passwords. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Authentication/Token/PublicKeyTokenProvider.php5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
index 16425a2e1c3..96bf9a86087 100644
--- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php
+++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
@@ -346,7 +346,7 @@ class PublicKeyTokenProvider implements IProvider {
$config = array_merge([
'digest_alg' => 'sha512',
- 'private_key_bits' => 2048,
+ 'private_key_bits' => $password !== null && strlen($password) > 250 ? 4096 : 2048,
], $this->config->getSystemValue('openssl', []));
// Generate new key
@@ -369,6 +369,9 @@ class PublicKeyTokenProvider implements IProvider {
$dbToken->setPrivateKey($this->encrypt($privateKey, $token));
if (!is_null($password) && $this->config->getSystemValueBool('auth.storeCryptedPassword', true)) {
+ if (strlen($password) > 469) {
+ throw new \RuntimeException('Trying to save a password with more than 469 characters is not supported. If you want to use big passwords, disable the auth.storeCryptedPassword option in config.php');
+ }
$dbToken->setPassword($this->encryptPassword($password, $publicKey));
}