Merge pull request #37724 from nextcloud/fix/encryption-signature-check-logic

Cleanup signature checking logic in encryption
This commit is contained in:
Christoph Wurst 2023-04-17 17:39:34 +02:00 committed by GitHub
commit b952066140
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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']);
}
}
}