# Signature check during encryption / decryption

**URL:** <https://help.nextcloud.com/t/signature-check-during-encryption-decryption/34225>\
**Category:** ℹ️ Support\
**Tags:** external\_storage, encryption-server\
**Created:** [July 20, 2018, 12:39pm UTC](https://help.nextcloud.com/t/signature-check-during-encryption-decryption/34225 "2018-07-20T12:39:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tilo](https://help.nextcloud.com/letter_avatar/tilo/32/5_5575768a8748004e209b776fc1b2916d.png) [@Tilo](https://help.nextcloud.com/u/Tilo)\
**Post date:** [July 20, 2018, 12:39pm UTC](https://help.nextcloud.com/t/signature-check-during-encryption-decryption/34225/1 "2018-07-20T12:39:24Z")

</div>

Hey guys,

according to [Decrypt My Files](https://help.nextcloud.com/t/decrypt-my-files/30354) it seems to possible to **disable the signature check during encryption / decryption in case of missing, corrupt database.**

Disabling signature check does not work for me. A added “return true” as you mentioned. Than I get a “Missing signature” from hassignature-function. Therefore I added an “return false” and now decryption failed with “Encryption library: Decryption (symmetric) of content failed”.

Do you have any hints to decrypt files without (correct) signature from the database?

Anyhow it would be great to store the signature check not in database (maybe direct in filesystem?) or disabling the feature because its not that robust e.g. if you move files from an external storage not within nextcloud.

Thank you!

---

<div class="post-metadata">

**Author:** ![suntorytimed](https://help.nextcloud.com/user_avatar/help.nextcloud.com/suntorytimed/32/10517_2.png) [@suntorytimed](https://help.nextcloud.com/u/suntorytimed)\
**Post date:** [August 16, 2018, 8:26am UTC](https://help.nextcloud.com/t/signature-check-during-encryption-decryption/34225/2 "2018-08-16T08:26:12Z")

</div>

Having the same issue when disabling the signature check. @bjoern is there anything else we have to do?

---

<div class="post-metadata">

**Author:** ![suntorytimed](https://help.nextcloud.com/user_avatar/help.nextcloud.com/suntorytimed/32/10517_2.png) [@suntorytimed](https://help.nextcloud.com/u/suntorytimed)\
**Post date:** [August 21, 2018, 7:42am UTC](https://help.nextcloud.com/t/signature-check-during-encryption-decryption/34225/3 "2018-08-21T07:42:58Z")

</div>

@Tilo The reason why turning off the signature check doesn’t work, is that the server reports a different filesize to the client and breaks off the download too early. The client therefore thinks that the connection was lost and reports an error. But the files is already downloaded successfully (f.e. in Chrome you just have to remove .crdownload at the end of the downloaded file). I have written a small Python 3 script that can download the files via WebDav. It is a dirty hack, but at least I can recover my files.

You can find the script including an explanation in my gitea repository:  
[https://gitea.hibiki.eu/suntorytimed/nc-downloader](https://gitea.hibiki.eu/suntorytimed/nc-downloader)

---

<div class="post-metadata">

**Author:** ![suntorytimed](https://help.nextcloud.com/user_avatar/help.nextcloud.com/suntorytimed/32/10517_2.png) [@suntorytimed](https://help.nextcloud.com/u/suntorytimed)\
**Post date:** [August 21, 2018, 11:39am UTC](https://help.nextcloud.com/t/signature-check-during-encryption-decryption/34225/4 "2018-08-21T11:39:33Z")

</div>

(Sorry for repeating this post so often, but there are many forum entries and issues that people looking for a solution might find via Google 🙂)  
After checking the downloads I discovered that while the JPEGs open without any problem my RAW files didn’t. Looking closer at the JPEGs I could see that in the last pixel line there were some blocks missing. So the download wasn’t finished. Following up on the error message that gets displayed in Nextcloud in the `hasSignature()` call of `splitMetaData()` I discovered that the encrypted data field was empty and therefore there can’t be a signature in the file. To bypass this I have added following if clause into the function `symmetricDecryptFileContent()` in `apps/encryption/lib/Crypto/Crypt.php`:

```
            if ($keyFileContents == '') {
                    return '';
            }

```

I have put this code as the first command in the `symmetricDecryptFileContent()`. Together with disabling the signature check (putting `return true;` in the `checkSignature()` function in the same file):

```auto
    private function checkSignature($data, $passPhrase, $expectedSignature) {
            $signature = $this->createSignature($data, $passPhrase);
            if (!hash_equals($expectedSignature, $signature)) {
                    return true;
                    throw new GenericEncryptionException('Bad Signature', $this->l->t('Bad Signature'));
            }
    }

```

I can now see the previews in the web interface and download all files decrypted and even download the folders as zip-files. My script is not necessary anymore 🙂

---

<div class="post-metadata">

**Author:** ![yahesh](https://help.nextcloud.com/user_avatar/help.nextcloud.com/yahesh/32/48204_2.png) [@yahesh](https://help.nextcloud.com/u/yahesh)\
**Post date:** [August 7, 2019, 5:42am UTC](https://help.nextcloud.com/t/signature-check-during-encryption-decryption/34225/5 "2019-08-07T05:42:38Z")

</div>

Have you been able to decrypt your files? If not: We’ve written a tool that allows you to decrypt individual files if you still have your Nextcloud data directory and configuration file. It supports master key encrypted files, user key encrypted files (you additionally need the user passwords) and recovery key encrypted files (you additionally need the recovery password): [decrypt-file.php](https://github.com/syseleven/nextcloud-tools/blob/master/decrypt-file.php)

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 4, 2024, 7:24am UTC](https://help.nextcloud.com/t/signature-check-during-encryption-decryption/34225/6 "2024-12-04T07:24:50Z")

</div>



---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 9, 2024, 3:02pm UTC](https://help.nextcloud.com/t/signature-check-during-encryption-decryption/34225/7 "2024-12-09T15:02:11Z")

</div>


