"Piggy Bank" style encrypted volume

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

"Piggy Bank" style encrypted volume

Postby darkspork » Mon Jan 02, 2012 3:10 am UTC

Partially due to Bitcoin, I've been looking into methods of storing encrypted data, and one particularly amusing one came to mind:

Is there a simple way to encrypt a directory in such a way that its contents are encrypted (both data and metadata, including file/directory structure), but files can be written without a key? I know about asymmetric cryptography, so it's certainly possible - a single file can be encrypted this way using a public key, so it would be trivial to encrypt individual files with the key and plop them in a directory, but what if you wanted to encrypt file names and directory structure in this manner as well? Furthermore, what if you wanted to append encrypted data to the end of an encrypted file without decrypting the file? What if you wanted to delete a specific file from an encrypted volume without decrypting any of it first, perhaps denying it even existed before you tried to delete it?

I'm wondering if an implementation of (most of) this already exists (maybe some flags I missed in the encryptfs man pages). I know it's possible at least in theory - perhaps by creating an asymetrically encrypted log of all requested activity on the encrypted volume, which would be postponed until it was decrypted with the private key. If not, it might make for an interesting shell script.
Shameless Website Promotion: Gamma Energy
My new esoteric programming language: GLOBOL
An experiment to mess with Google Search results: HARDCORE PORNOGRAPHY HARDCORE PORNOGRAPHY
User avatar
darkspork
 
Posts: 531
Joined: Tue Sep 23, 2008 12:43 am UTC
Location: Land of Trains and Suburbs

Re: "Piggy Bank" style encrypted volume

Postby undecim » Mon Jan 02, 2012 8:58 pm UTC

darkspork wrote:Partially due to Bitcoin, I've been looking into methods of storing encrypted data, and one particularly amusing one came to mind:

Is there a simple way to encrypt a directory in such a way that its contents are encrypted (both data and metadata, including file/directory structure), but files can be written without a key? I know about asymmetric cryptography, so it's certainly possible - a single file can be encrypted this way using a public key, so it would be trivial to encrypt individual files with the key and plop them in a directory, but what if you wanted to encrypt file names and directory structure in this manner as well? Furthermore, what if you wanted to append encrypted data to the end of an encrypted file without decrypting the file? What if you wanted to delete a specific file from an encrypted volume without decrypting any of it first, perhaps denying it even existed before you tried to delete it?

I'm wondering if an implementation of (most of) this already exists (maybe some flags I missed in the encryptfs man pages). I know it's possible at least in theory - perhaps by creating an asymetrically encrypted log of all requested activity on the encrypted volume, which would be postponed until it was decrypted with the private key. If not, it might make for an interesting shell script.


A tar file with public key encryption should do what you want. IIRC, tar files are just concatenations of files in 512-bit blocks, with a 1-block header before each file. So to add a file, you would just put together the file and header, encrypt it, and append it to the tar file. Then you could read the file with the private key.

However, a writer could sabotage your tar file by writing a header that says the file is several terabytes large, and not adding any data. (as well as many other trickses with the header)
Blue, blue, blue
User avatar
undecim
 
Posts: 286
Joined: Tue Jan 19, 2010 7:09 pm UTC

Re: "Piggy Bank" style encrypted volume

Postby Yakk » Tue Jan 03, 2012 4:51 pm UTC

What do you mean by "deleted"? Because it is difficult to prevent later reconstruction of the data without destroying it. And a destructive delete operation that does no harm if the file isn't there seems tricky.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
User avatar
Yakk
 
Posts: 10038
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: "Piggy Bank" style encrypted volume

Postby darkspork » Wed Jan 04, 2012 3:14 pm UTC

undecim wrote:A tar file with public key encryption should do what you want. IIRC, tar files are just concatenations of files in 512-bit blocks, with a 1-block header before each file. So to add a file, you would just put together the file and header, encrypt it, and append it to the tar file. Then you could read the file with the private key.

However, a writer could sabotage your tar file by writing a header that says the file is several terabytes large, and not adding any data. (as well as many other trickses with the header)

The one problem I see: will tar allow you to append to existing files or delete (unlink, not overwrite) them? I don't think that's entirely possible.

Yakk wrote:What do you mean by "deleted"? Because it is difficult to prevent later reconstruction of the data without destroying it. And a destructive delete operation that does no harm if the file isn't there seems tricky.

That was a theoretical "cool feature" that I really don't see mathematical sense in. I really can't make heads or tails of it either.
Shameless Website Promotion: Gamma Energy
My new esoteric programming language: GLOBOL
An experiment to mess with Google Search results: HARDCORE PORNOGRAPHY HARDCORE PORNOGRAPHY
User avatar
darkspork
 
Posts: 531
Joined: Tue Sep 23, 2008 12:43 am UTC
Location: Land of Trains and Suburbs

Re: "Piggy Bank" style encrypted volume

Postby userxp » Tue Jan 10, 2012 11:18 am UTC

darkspork wrote:Is there a simple way to encrypt a directory in such a way that its contents are encrypted (both data and metadata, including file/directory structure), but files can be written without a key? I know about asymmetric cryptography, so it's certainly possible - a single file can be encrypted this way using a public key, so it would be trivial to encrypt individual files with the key and plop them in a directory, but what if you wanted to encrypt file names and directory structure in this manner as well?

Encrypting file names is just a matter of applying the same cryptographic protocol to them (nowadays you can implement a filesystem in pretty much any language thanks to FUSE). The hard problem is maintaining the file structure in a secure way. Either:
a) The files are stored in a secure place (such as a server), that the attacker cannot reach, in which case you don't even need encryption (except for extra security).
b) The files are stored in an insecure place (such as a hard drive), in which case the attacker can always just overwrite everything with zeros.

These two are out of the question. The only remaining possibility I can think of is to have the files stored in a distributed network which allows appending but not deleting (unless you control a big part of the network, that is). In that case you probably can't "delete" anything, but since you can't tell encrypted data from random data without knowing the key, you could always claim that that file is just random garbage (and make it more plausible by uploading random garbage all the time).

darkspork wrote:Furthermore, what if you wanted to append encrypted data to the end of an encrypted file without decrypting the file?

I don't know if there is any easier way, but you could always add a new file and then automatically append it to the previous one when decrypting.

Also, Gamma Energy is an awesome game.
userxp
 
Posts: 436
Joined: Thu Jul 09, 2009 12:40 pm UTC

Re: "Piggy Bank" style encrypted volume

Postby Zamfir » Fri Jan 13, 2012 12:32 pm UTC

I guess deletes are possible for the party who inserted that specific file. They could just remember which bytes "belong" to them and replace them by an equally-sized other file, filled with random junk or something innocuous.
User avatar
Zamfir
 
Posts: 5740
Joined: Wed Aug 27, 2008 2:43 pm UTC
Location: Nederland


Return to Coding

Who is online

Users browsing this forum: No registered users and 9 guests