unbekanntes-pferd / dracoon-python-api

A Python3 based package to connect with DRACOON API (async) - more infos on DRACOON here: https://dracoon.com
Apache License 2.0
12 stars 4 forks source link

New idea: encrypt_file function #107

Open stsch9 opened 1 year ago

stsch9 commented 1 year ago

In the example it is described how a user has to encrypt a file client-side.

  1. generate plain file key
  2. encrypt bytes/file (AES 256 GCM)
  3. encrypt file key (with public key of keypair)

I don't think a user should worry about how to encrypt a file client-side. I think it is safer to replace these three functions by one function (see e.g. box function of nacl/libsodium or Hybrid encryption of tink)

encrypt_file(file, plublic key):
   return enc_file, enc_file_key, (file_key)

Probably the function must also return the plaintext file_key to be able to distribute it to the other users.

unbekanntes-pferd commented 1 year ago

The reason the example is present is due to the fact that I did not sort out crypto operations as an own package (yet), but the overall handling should be documented.

A user of the dracoon package usually does not have to use any of it because using

await dracoon.upload(...) 
# or download 
await dracoon.download(...)

abstracts everything regarding crypto away. I'll leave this open and will refactor the function when I move out crypto as an own PyPi package.

Again, thanks for the feedback!