Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symmetric Encryption #13

Open
Shadow53 opened this issue Jun 2, 2021 · 3 comments
Open

Symmetric Encryption #13

Shadow53 opened this issue Jun 2, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Shadow53
Copy link
Owner

Shadow53 commented Jun 2, 2021

There is a little bit of configuration support for this already, but no actual support.

Essentially, backed up files will get encrypted using a given password, and restored files will be decrypted by the same.

There will be two sources of password: a raw password password = "" and a password command to retrieve it from somewhere else.

I'll need to do research into the best encryption to use for both speed and security. AES, probably.

@Shadow53 Shadow53 added the enhancement New feature or request label Jun 2, 2021
@Shadow53 Shadow53 self-assigned this Jun 2, 2021
@Shadow53 Shadow53 added this to the 0.3.0 milestone Jun 5, 2021
@Shadow53
Copy link
Owner Author

Shadow53 commented Jun 5, 2021

I've been doing some research into algorithms that could be used, and here's the gist of what I've found:

  • The two most common encryption methods are AES-GCM and ChaCha20/Poly1305
  • AES is probably the most performant on modern x86 hardware because of AES-NI processor instructions
  • When using software implementations, ChaCha20 is generally much faster and more likely to be secure from timing attacks
  • Google is using ChaCha for TLS 1.3 stuff because it is better for mobile devices, which generally do not have hardware-accelerated AES
  • XChaCha20/Poly1305 is a newer variant on ChaCha20/Poly1305 that has better security for reasons that made sense when I read them and have since disappeared from my brain.
  • AES-SIV-GCM is a variant on AES-GCM that is a bit slower but is more resistant to nonce reuse.

So, without being an expert in cryptography, the best options appear to come down to:

  • XChaCha20/Poly1305
  • AES-SIV-GCM

... probably in that order, though that depends on what libraries are available for Rust, whether they've been verified, and so on.

@Shadow53
Copy link
Owner Author

Shadow53 commented Jun 5, 2021

Looks like RustCrypto has implementations of both with some amount of auditing for both -- the ChaCha crate was directly audited and the AES-SIV-GCM one was not, though its dependency crate for AES-GCM was.

@Shadow53 Shadow53 modified the milestones: 0.3.0, 0.4.0 Sep 11, 2021
@Shadow53
Copy link
Owner Author

Okay, so I've done a lot of research and I have determined what seems to be at least an okay route to go, if not good. This is regardless of which algorithm is used.

  1. Whatever algorithm is used will need nonces. When it comes to hoard, the best options are going to be randomly generated or using a hash of the plaintext,
    • The latter would make the Operations check easier to do, but leaks data about the plaintext.
    • Nonces do not need to be secret, so storing them on disk is fine.
  2. Using a random salt for each operation is a good idea, to help prevent (key, nonce) reuse. Using a cryptographically secure PRNG is important for this.
  3. Looks like PBKDF2 is the standard for deriving a key from a password, so we should use that.
  4. Can still perform the various checks, just with more effort.
    • The log files will store the encrypted path, with salt/nonce
    • To perform the checks, decrypt the paths, encrypt files on disk if needed, then do whatever comparisons
      • This will lead to encrypting files multiple times with different salts. Not sure there is a way around this without sacrificing security.
    • If decryption fails at any point, log a warning/error and abort

@Shadow53 Shadow53 removed this from the 0.5.0 milestone Apr 5, 2022
@Shadow53 Shadow53 added this to the 0.6.0 milestone Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant