Timeline for PHP: decrypting a file directly to a stream using the defuse/PHP_encryption library
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 6, 2020 at 16:51 | comment | added | Ben Johnson |
I have precisely this need, but I do need to support excessive file sizes, so reading the entire file into memory is not an option. It seems like the implementation would need to read a chunk into a file pointer, decrypt it, and write the plaintext chunk to a separate stream, which is sent to the client via fpassthru($stream) or similar (rinse and repeat). If this is even feasible and sane, I'm struggling to conceptualize how this could possibly work without modifying the Defuse library code. Any guidance would be fantastic.
|
|
Dec 21, 2016 at 16:19 | comment | added | Martin | Thanks for the info, @symcbean , and the answer by Kyrth is useful too. I did construct a solution to this but it's been a couple of months since I've looked into this topic so I'm wary of saying much without checking what I actually did (my memory is not great). I think I created a wrapper. | |
Dec 21, 2016 at 1:25 | comment | added | symcbean | Uploading leaves an unencrypted footprint (albeit as a deleted file if you are doing your job properly). I assume you have some magic mojo for accessing the key without storing it on the filesystem. I suggest you implement as a streamwrapper - php.net/manual/en/class.streamwrapper.php - or invoke an external command to decrypt to stdout and read from there (again the read might be implemented as a streamwrapper). Remember to make the seek method fail. | |
Dec 20, 2016 at 16:18 | answer | added | Kyrth | timeline score: 1 | |
Jul 22, 2016 at 19:06 | comment | added | symcbean | With a log structured filesystem, even shredding the file may leave traces of the plaintext on the server. If you need tin foil hat security, encrypt and decrypt on the client. | |
Jul 22, 2016 at 16:11 | history | edited | Martin | CC BY-SA 3.0 |
edited title
|
Jul 22, 2016 at 15:44 | history | asked | Martin | CC BY-SA 3.0 |