3

first of all, sorry if my question is not clear, because English is not my first language. Anyway, let-me explain the concept I'm struggling to solve as the best solution. I have some guys, and they want privacy for their cloud (hosting their files). Ok, cryptography is the way to go I believe. So I did some quick research and found that I can crypt their files with PHP and store them crypted in the cloud's server. But this way, to decrypt their files and give them a download of the original file, I'll need to get their crypt key (supposed to be secret and kept only in client side) and use it in PHP mcrypt, to decrypt the file. This way, I create a possibility to 'hook' their crypt keys, and decrypt their files even without the permission. Ok, I don't pretend to do that, but I want to "wash my hands" (maybe this expression doesn't work well in English, but try to understand) about what they are hosting there. If anytime, for legal purposes I get obligated to get the key of some user and decrypt the files, I just don't want to have any ways to do that. Is there any way to do this with the PHP mcrypt library? Maybe doing some hashing function with their crypt key (just supposing) or maybe processing the downloaded file in the client side via javascript (is that even possible?)

  • Do you want to be able to decrypt their data or not be able to decrypt their data? – RoraΖ Feb 2 '15 at 18:34
  • I need to deliver their data decrypted. Otherwise I'll need to create some kind of application, this way they decrypt the data on the app, but I'm looking for a "stand alone" solution, without external apps. Everything done online, on browser, as a normal file cloud service. – user3810691 Feb 2 '15 at 18:47
3

I have some guys, and they want privacy for their cloud (hosting their files).

Sounds like a common goal these days.

Ok, cryptography is the way to go I believe.

Right.

So I did some quick research and found that I can crypt their files with PHP and store them crypted in the cloud's server. But this way, to decrypt their files and give them a download of the original file, I'll need to get their crypt key (supposed to be secret and kept only in client side) and use it in PHP mcrypt, to decrypt the file.

If you're typing the word MCRYPT into your PHP code, you're doing it wrong.

This way, I create a possibility to 'hook' their crypt keys, and decrypt their files even without the permission. Ok, I don't pretend to do that, but I want to "wash my hands" (maybe this expression doesn't work well in English, but try to understand) about what they are hosting there. If anytime, for legal purposes I get obligated to get the key of some user and decrypt the files, I just don't want to have any ways to do that. Is

So basically, you're realizing the limitations of symmetric cryptography: If you have a copy of the key, you can decrypt it.

Is there any way to do this with the PHP mcrypt library? Maybe doing some hashing function with their crypt key (just supposing) or maybe processing the downloaded file in the client side via javascript (is that even possible?)

No, you cannot do this with mcrypt. You can do it in general, however.

A Better Solution than Mcrypt

Just use libsodium. Specifically, you can use libsodium.js in a web browser, Chrome extension, or Electron desktop application. Encrypt files with crypto_box_seal(), decrypt them on the user's machine with crypto_box_seal_open().

If you need to store anything in the server (i.e. for cross-device encryption), only store the salt (for crypto_pwhash() and crypto_box_seed_keypair()) and require your users to remember a password.

This allows you to design your application with respect to the principle of least privilege and never see their ciphertext. Your users don't need to trust your server operator for anything except availability. Even if you receive a subpoena, you can't decrypt their files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.