by matt_wulfeck · 9y ago · 0 comments
Ask your third-party to supply a gpg public key over a secure channel, then it's very to encrypt files for them (and only them) to read.
I'm personally curious about the best solution...
@Canada, if the "malicious"(untrusted?) server modifies the backup how could you decrypt anyway?
The solution is to generate a hash or a MAC after encrypting. A plain hash would have to be kept locally because the malicious server could modify it if stored there. A MAC could be stored on the server, but then it would be necessary to derive another key for that and store it locally. (Or store the input for deriving the encryption key and MAC key... in any case, annoying)
GPG takes care of all this for you. Bottom line: Avoid OpenSSL command line for this kind of thing.
Even if you wanted to use a more secure cipher according to [this](https://security.stackexchange.com/questions/128883/basic-qu...) `openssl enc` does not support the more secure ciphers that openssl tls does.
Is this the reason to avoid openssl for file encryption?
AES-CBC is just a block cipher mode of operation. TLS is a protocol that takes care of negotiating algorithms for key exchange, bulk encryption (which may be a block cipher using some mode), authentication, etc. All of these things combined is the "suite" of ciphers. Implementations provide decent tooling for managing keys and preferences.
Like TLS, GPG uses a suite of ciphers to do its job and provides tools to manage it without getting caught up in extremely low level details. Like TLS, the default suite of algorithms it prefers change with the times, but from a user perspective it stays the same.
I also see clearly how hashing the encrypted data before "storing it at this 3rd party" would allow you to verify CBC block modifications.
I guess I don't understand GPG well enough to see how it solves this problem better than AES CBC 256. Could you perchance provide a link? Or explain how GPG would take care of this?