by jph · 9y ago · 0 comments
gpg --symmetric \
--cipher-algo aes256 \
--digest-algo sha256 \
--cert-digest-algo sha256 \
--compress-algo none -z 0 \
--quiet --no-greeting \
--no-use-agent "$@"
I keep this command here: https://github.com/SixArm/gpg-encrypt
The options are chosen to balance tradeoffs of convenience, strength, and portability. --s2k-mode 3
--s2k-digest-algo sha512
--s2k-count 1000000
Default is to use salt + one round of SHA1, which is relatively weak.(I'm asking seriously; I don't have a strong opinion about GPG command line arguments)
GPG 2 has better defaults, but it grew to include the kitchen sink and have a lot of moving parts, and I'd still prefer to have a good smaller program that does only a few things but do them good. My ideal would be a small executable with as little dependencies as possible.
https://gnupg.org/documentation/manuals/gnupg/gpgv.html#gpgv
https://gnupg.org/documentation/manuals/gnupg/symcryptrun.ht...
It can be requested directly via '--force-mdc', but, as long as you're tweaking the configuration, you might as well boost everything up to the full "Grovergeddon" settings.
It's a wrapper for gpg to edit encrypted files.
personal-cipher-preferences AES256 AES
personal-digest-preferences SHA256 SHA512
personal-compress-preferences Uncompressed
default-preference-list SHA256 SHA512 AES256 AES Uncompressed
cert-digest-algo SHA256
s2k-cipher-algo AES256
s2k-digest-algo SHA256
s2k-mode 3
s2k-count 65011712
disable-cipher-algo 3DES
weak-digest SHA1
force-mdc
Note that these options impact compatibility with other GPG/PGP clients.These suggestions strike a different balance between protection and speed.
--no-use-agent
This is dummy option. gpg always requires the agent. gpg: WARNING: "--no-use-agent" is an obsolete option - it has no effect set -euf
onecmd --args "$@"
The set -u is unneeded, as there are no code variables involved.The set -e is not needed, as there is only one command, and the script will return the exit status of such command. Always. And will exit after that command. Always.
The set -f, will disable globbing, which I'm not sure it's what you want, when using a simple wrapper passing "$@" as filenames to gpg...
This is the classic braceless if-guard mistake; leave it out today because you don't need it, forget, add something tomorrow and it breaks.
#!/usr/bin/env bash
set -e
fail() { false ; echo hello; }
if ! fail; then :; fi
That outputs "hello" and exits with 0. $ file /tmp/something.gpg
/tmp/something.gpg: GPG symmetrically encrypted data (AES cipher)
It has to, otherwise you'd have to know and use exactly the same options when decrypting. You could always strip it manually if you don't want this...