236 points · by maxt · 9y ago · 99 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.
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...Not having a browser add-on to retrieve passwords was feeling like a step back in terms of convenience though. That's why I built & open sourced browserpass [1], a browser extension for Pass.
It uses Native Host Messaging to securely retrieve passwords, so no crazy port listening as some other open-sourced add-ons do (which is a terribly bad idea).
Features: http://keepass.info/features.html
I switched to pass / qtpass (cross-platform Qt frond-end for pass) after seeing it on hacker news (or somewhere else like Twitter) because it uses GnuPG + git (simple and I am capable of both in CLI). Last but not least, pass provides migration scripts from keepass/keepassx (and a lot more... - feel like I had to migrate ;-)
https://play.google.com/store/apps/details?id=com.zeapo.pwds...
$ xz -k elrond_minutes.txt
$ scrypt enc elrond_minutes.txt.xz elrond_minutes.txt.xz.enc
$ signify -S \
-s vilya.key \
-m elrond_minutes.txt.xz.enc \
-x elrond_minutes.txt.xz.enc.sig
$ rm elrond_minutes.txt{,.xz}
Signing the final output is probably extraneous; I think scrypt uses a HMAC. This involves invoking multiple tools, but since each tool only does one thing it's much easier to reason about, and I prefer this over using an omnibus tool like gpg. xz < file | scrypt enc - > file.xz.enc
And I agree: scrypt (the program) is much better for password encrypting documents. It is only a few thousand lines of readable code; it uses modern algorithm choices (scrypt, AES256-CTR, HMAC-SHA256), with no alternatives; there isn't any configuration involved; and it's written by a respected author.>You need to be able to recall the passphrase that was used to encrypt the file.
Why bother writing security guidelines which are impossible for a human to follow?
edit: Try recalling any passphrases generated by the command below, and that's before the random sprinkling of punctuation.
grep -E "^[a-z]{5,10}$" /usr/share/dict/words | shuf -n5 | tr '\n' ' 'Imagine this, you take four word types/groups, say, substantive, verb, adverb, preposition/place.
You list 128 of each - all with identified uniqly by the first two letters. You let a machine pick a word from each column at random. The phrase is your mnemonic key, the password (to type in) is the first two letters of each word, concatenated.
If you want to appease password strength checks, capitalise the first letter, and end the input with a period.
So: "girl runs happily up", becomes "giruhaup" (or, with equivalent entropy, but satisfying "at least three symbol groups": "Giruhaup.").
Now, that's then 4 picks out of 128 words, or an encoding of 4 times 7 bits (2^7=128) - 28 bits. You'd need three such passwords concatenated to break past 64 bits of entropy. And you'd have to type in 24 letters. That's pretty hard to type in blind without a typo.
You might be able to use lists of 256 words - but it'd make it a bit more difficult to make the wordlists (because words should be identified by the first two characters) - and you'd still need two "phrases" and type in 16 characters.
Adding random numbers, symbols or capitalization is probably not worth the challenge they add in remembering where they go, for the single/few bits of entropy they add.
And I'm still not convinced 16 characters is short enough to be usable for "most people".
For the long tail of passwords that you shouldn't be memorizing in the first place, a password manager with a good configurable password generator is invaluable. I use Lastpass (I like the breadth of it's platform support: all major consumer OSes, all major mobile OSes, extensions for all major browsers). Alternatively, lot of people recommend 1password.
Diceware has better guarantees, but the password managers are usually much more convenient[1]. I weigh these costs and benefits when choosing which way to go for a particular use case.
[1] With the significant exception of passwords that will regularly have to be typed out on mobile, since diceware passwords are much more virtual keyboard friendly than random character generated passwords. This is partly because you can typically keep the entire thing in your head, not having to reference your password manager multiple times, and partly because they don't rely on special characters for their entropy, so can be typed out on the primary keyboard without switching to numeral or special character keyboards.
My main takeaway looking at the problem, is that 64 bits is a lot to encode in ~26 letters and maybe 10 digits - in a way that is easy to remember, easy to type, easy to read (if eg: given a printed initial password, read/hear (sharing over the phone/double as a way to read out a hash/shared key etc).
My main issue with diceware is the large number of words; almost touching on typical active vocabulary of even native speakers - never mind if your users speak little or no English. One benefit of the system above is that as long as you can come up with four/five sets of 128 words that don't collide among themselves in the groups of 128 - you can adapt the system to any alphabet and preserve any guarantees of entropy. Making a diceware wordlists is a huge undertaking by comparison. (But the benefit is that people have already done this for many languages).
And while it might feel good to pretend full words add entropy, if you assume the attacker knows your system - it really doesn't (hence "guaranteed" entropy).
As for diceware, I don't find those passwords easy to remember - especially past 60 bits of entropy. But use what works for you.
"Shiny C0rrect H0rse Battery Staple!"
In my experience, overly restrictive password policies force users to choose passwords that are less secure and easier to remember.
thanks for the link
This hunt for dates in titles on HN is bad and it's awitch hunt these days.
Disclaimer: I'm not an author nor submitter.
Asymmetric encryption solves the problem of transmitting the password safely ("solve" is a rather optimistic word, maybe "delegates" is more appropriate); if you can safely transfer passwords from point to point, then using symmetric encryption is far easier.
Which is just a different problem, not necessarily an easier one, like you say.
That's a very nice way to put it, I'm going to reuse that !
====
Use GPG with the cipher AES256, without the --armour option, and with compression to encrypt your files during inter-host transfers. GPG
Encryption helps protect your files during inter-host file transfers (for example, when using the scp, bbftp, or ftp commands). We recommend GPG (Gnu Privacy Guard), an Open Source OpenPGP-compatible encryption system.
===
scp shouldn't be in that list.
But for bulk data encrypting good symmetric (AES, CAST5, etc.) is both more secure and significantly faster.
This is how the same document can be encrypted for multiple recipients efficiently, without duplication all the data. First the document is encrypted with a symmetric key, which is then encrypted with the public key of each recipient. This information will be prepended to the actual encrypted document.
For details see: https://tools.ietf.org/html/rfc4880#section-2.1