uds icon indicating copy to clipboard operation
uds copied to clipboard

Encryption and chunk file read

Open salvatorenitopi opened this issue 6 years ago • 7 comments

Hi, i think that this is a very smart idea, I have some possible enhancements for you:

  1. reading and computing file in chunks
  2. adding AES encryption (in CBC mode)

To be more specific I would read the file in blocks long as the size of a page, then I would encrypt the block and upload it on Google documents (as a page)

A very simple example:

with open(path, 'rb') as f:
    for chunk in iter(lambda: f.read(4096), b''):
        enc = encrypt_fx (chunk)
        upload_page_fx (enc)

Let me know what you think.

salvatorenitopi avatar Jul 24 '18 16:07 salvatorenitopi

Sorry for bad indentation in my example code. And by the way I meant "encryption" in the title.

salvatorenitopi avatar Jul 24 '18 16:07 salvatorenitopi

@salvatorenitopi Good idea! I reckon it will allow us to process larger files without the enormous memory footprint needed currently :-)

stewartmcgown avatar Jul 24 '18 16:07 stewartmcgown

Multithreading added with 13079d5. Encryption will be next!

stewartmcgown avatar Jul 24 '18 22:07 stewartmcgown

Nice, I would use AES - CBC as encryption method (example: https://gist.github.com/forkd/168c9d74b988391e702aac5f4aa69e41 to edit according below)

I would encrypt a page in this way (CFB example):

Block0 -> random IV Block1 -> AES ( xor (x1, Block0) , key) Block2 -> AES ( xor (x2, Block1) , key) BlockN -> AES ( xor (xN, BlockN-1) , key)

(Where x is the plaintext)

Multithreading may not be possible using this method.

salvatorenitopi avatar Jul 25 '18 09:07 salvatorenitopi

Multithreading should be possible with this :-)

stewartmcgown avatar Jul 26 '18 08:07 stewartmcgown

Why not create a possibility for piping data into uds so that you could encrypt with any tool, which reads file in and prints encrypted output to stdout? In that way you would eliminate the need to have encryption built into the uds itself and everyone could use whatever encryption they like.

jarmo avatar May 17 '19 11:05 jarmo

Using uds as a backend for git-annex would be also a pretty easy way to achieve this. But it comes with all the complexity of that tool attached.

Fuco1 avatar May 19 '19 15:05 Fuco1