-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Getting rid of openssl_seal and rc4 in server side encryption #37243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| $this->addRecoveryKeys($filePath . '/'); | ||
| } else { | ||
| $fileKey = $this->keyManager->getFileKey($filePath, $this->user->getUID()); | ||
| $fileKey = $this->keyManager->getFileKey($filePath, $this->user->getUID(), null); |
Check notice
Code scanning / Psalm
PossiblyNullReference
| $chunk = substr($data, 0, $this->getUnencryptedBlockSize(true)); | ||
|
|
||
| $encrypted .= $this->crypt->symmetricEncryptFileContent($chunk, $this->fileKey, $this->version + 1, $position); | ||
| $encrypted .= $this->crypt->symmetricEncryptFileContent($chunk, $this->fileKey, $this->version + 1, (string)$position); |
Check notice
Code scanning / Psalm
PossiblyFalseOperand
Signed-off-by: Côme Chilliet <[email protected]>
fileKey gets deleted upon save as it’s stored in shareKeys instead now. We use presence of a fileKey to detect if a file is using the legacy system or the new one, because we do not always have access to header data. Signed-off-by: Côme Chilliet <[email protected]>
Signed-off-by: Côme Chilliet <[email protected]>
Signed-off-by: Côme Chilliet <[email protected]>
Signed-off-by: Côme Chilliet <[email protected]>
c512e86 to
24e762c
Compare
|
@come-nc Had a first look at the code. Switching to OAEP is nice to see, as well as RC-4 being gone. If I could wish for another improvement, it would be that the file version should be written into the file header as well (and not just to the database). Considerations:
|
I need to look into that, because for the RC4 drop I added a useLegacyFileKey in the header, and in the end I can only use it when decoding, there are some code path where we do not read the header, like when resharing or adding recovery keys.
So the version in the header would only be written by the normal process, and would be read only for recovery scenarios? But in any case I think this would need to go in a follow-up PR as it is not tied to this one. |
Yes, exactly. I remember that someone wrote a fix-file-version-in-database command which tests through a bunch of version numbers to find the correct one. I wrote one such script myself in the past as well. Having the version number within the file header would obsolete that brute-force approach. And as the file header is rewritten with every re-encryption anyway...
Fine for me. |
Signed-off-by: Côme Chilliet <[email protected]>
|
Follow-up task: write an occ command to migrate all files to the new key format, when master key is used. (it only needs to open/write/close all encrypted files.) |
|
@come-nc Hi and thanks for this work, could the follow-up task be tracked by an issue or draft PR ? |
|
Hi, Does it break recover-tool? New files added with Nextcloud 27 have no fileKey and the script does not work anymore |
|
Also, the documentation needs to be updated: https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/encryption_configuration.html |
This should be fixed. |
I read this page and I am not sure which part you are referring to which should be updated? |
|
I don't remember, someone may have removed the part I mentioned. I should have link to a specific Nextcloud version |
|
@joshtrichards Can you explain why you added the pending documentation label back? |
No answer, removing. |
|
Oops missed this first time around. Not sure now. I seem to remember fixing the encryption tools link, but that was a different issue. Fine by me. |
Summary
Get rid of the intermediate fileKey and the obsolete RC4 encryption used on it.
Also used the opportunity to change the padding used to OAEP.
Files encrypted with previous version can still be read but upon write they will get migrated to the new encryption.
Checklist