From 2f653c8be80e52bc8697462240c6a4ec2bf01c5e Mon Sep 17 00:00:00 2001 From: jld3103 Date: Fri, 14 Apr 2023 08:47:39 +0200 Subject: Cleanup signature checking logic in encryption Signed-off-by: jld3103 --- apps/encryption/lib/Crypto/Crypt.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'apps/encryption') diff --git a/apps/encryption/lib/Crypto/Crypt.php b/apps/encryption/lib/Crypto/Crypt.php index 22a697a1232..0cf6451d287 100644 --- a/apps/encryption/lib/Crypto/Crypt.php +++ b/apps/encryption/lib/Crypto/Crypt.php @@ -523,10 +523,12 @@ class Crypt { $signature = $this->createSignature($data, $passPhrase); $isCorrectHash = hash_equals($expectedSignature, $signature); - if (!$isCorrectHash && $enforceSignature) { - throw new GenericEncryptionException('Bad Signature', $this->l->t('Bad Signature')); - } elseif (!$isCorrectHash && !$enforceSignature) { - $this->logger->info("Signature check skipped", ['app' => 'encryption']); + if (!$isCorrectHash) { + if ($enforceSignature) { + throw new GenericEncryptionException('Bad Signature', $this->l->t('Bad Signature')); + } else { + $this->logger->info("Signature check skipped", ['app' => 'encryption']); + } } } -- cgit v1.2.3