Commit Graph

103 Commits

Author SHA1 Message Date
Daan Sprenkels
dc8716d8fc cmd/age: support "-i -" if stdin is not in use
Fixes #143
Closes #145

Co-authored-by: Filippo Valsorda <hi@filippo.io>
2021-01-03 09:10:21 -05:00
Filippo Valsorda
3f2deb5a3b cmd/age: be less clever in the lazyOpener implementation
I am a fan of closures and DoerFunc interface adapters, but the boring
thing is more readable. Sigh.
2021-01-03 09:10:21 -05:00
Filippo Valsorda
97b6569a66 cmd/age: lazily open output file at first write
This avoids leaving behind an empty file when an error occurs before we
write the header (for example, because the passphrase is invalid). Do a
best-effort check before taking user input for whether the file exists
so we don't waste user effort. An error might still happen after user
input if other kind of open errors happen (for example, a permission
issue, or disk full).

Fixes #159
Fixes #57
Closes #169
2021-01-03 09:10:21 -05:00
Filippo Valsorda
02ee8b969a internal/format: buffer newlineWriter writes
Most writes in the cmd/age Writer stack are chunk-sized, so
approximately 64KiB. However, the newlineWriter, which splits lines at
64 columns, was doing a Write on the underlying Writer for each line,
making chunks effectively 48 bytes (before base64). There is no
buffering underneath it, so it was resulting in a lot of write syscalls.

Add a reusable bytes.Buffer to buffer the output of each
(*newlineWriter).Write call, and Write it all at once on the
destination.

This makes --armor just 50% slower than plain, instead of 10x.

Fixes #167
2021-01-03 09:10:21 -05:00
Filippo Valsorda
cb4d1de4b7 cmd/age: show usage if no arguments and flags are specified
Fixes #74
2021-01-03 09:10:21 -05:00
Filippo Valsorda
e665eeafb0 cmd/age-keygen: make world-readable warning less obscure
Fixes #149
Fixes #75
2021-01-03 09:10:21 -05:00
Filippo Valsorda
4dee0155ee cmd/age,cmd/age-keygen: improve help text
Closes #168
2021-01-03 09:10:21 -05:00
Filippo Valsorda
0522803919 cmd/age,cmd/age-keygen: add -version flag
Fixes #157
Fixes #101
Closes #97
2021-01-03 09:10:21 -05:00
Filippo Valsorda
f8507c1cac age,cmd/age: add ParseRecipients and -R for recipient files
Fixes #84
Fixes #66
Closes #165
Closes #158
Closes #115
Closes #64
Closes #43
Closes #20
2021-01-03 09:10:21 -05:00
Filippo Valsorda
7ab2008136 .github/workflows: extend testing matrix 2021-01-03 00:28:03 +01:00
Luca Corbo
f5a47fcc9a age: fix typo in ParseX25519Identity docs (#134) 2021-01-03 00:13:41 +01:00
Filippo Valsorda
6f51e96429 .github/workflows: add build.yml
Fixes #164
Fixes #148
Fixes #133
Closes #25
2021-01-02 23:41:45 +01:00
Filippo Valsorda
53ccaf8b71 agessh: use filippo.io/edwards25519 for Ed25519 to Curve25519 conversion 2020-12-04 18:45:52 +01:00
Filippo Valsorda
6593c56e33 .github/workflows: switch from Travis CI to GitHub Actions
So long, and thanks for all the builds!
2020-11-21 01:50:09 +01:00
Filippo Valsorda
31500bfa2f age: clean up examples of hardcoded data v1.0.0-beta5 2020-09-20 12:57:16 +02:00
Filippo Valsorda
22e598d458 age: replace ParseX25519Identities with ParseIdentities
The latter returns a []Identity that can be used with Decrypt directly.
2020-09-20 12:54:15 +02:00
Filippo Valsorda
65f171a239 age: add ParseX25519Identities and key management docs 2020-09-20 12:17:15 +02:00
Filippo Valsorda
2194f6962c age: mitigate multi-key attacks on ChaCha20Poly1305
It's possible to craft ChaCha20Poly1305 ciphertexts that decrypt under
multiple keys. (I know, it's wild.)

The impact is different for different recipients, but in general only
applies to Chosen Ciphertext Attacks against online decryption oracles:

* With the scrypt recipient, it lets the attacker make a recipient
  stanza that decrypts with multiple passwords, speeding up a bruteforce
  in terms of oracle queries (but not scrypt work, which can be
  precomputed) to logN by binary search.

  Limiting the ciphertext size limits the keys to two, which makes this
  acceptable: it's a loss of only one bit of security in a scenario
  (online decryption oracles) that is not recommended.

* With the X25519 recipient, it lets the attacker search for accepted
  public keys without using multiple recipient stanzas in the message.
  That lets the attacker bypass the 20 recipients limit (which was not
  actually intended to defend against deanonymization attacks).

  This is not really in the threat model for age: we make no attempt to
  provide anonymity in an online CCA scenario.

  Anyway, limiting the keys to two by enforcing short ciphertexts
  mitigates the attack: it only lets the attacker test 40 keys per
  message instead of 20.

* With the ssh-ed25519 recipient, the attack should be irrelevant, since
  the recipient stanza includes a 32-bit hash of the public key, making
  it decidedly not anonymous.

  Also to avoid breaking the abstraction in the agessh package, we don't
  mitigate the attack for this recipient, but we document the lack of
  anonymity.

This was reported by Paul Grubbs in the context of the upcoming paper
"Partitioning Oracle Attacks", USENIX Security 2021 (to appear), by
Julia Len, Paul Grubbs, and Thomas Ristenpart.
2020-09-19 18:52:59 +02:00
Shimmy Xu
07c72f3b69 internal/bech32: fix vet error by making rune conversion explicit (#141)
Fixes #138
2020-09-07 16:07:10 +02:00
Filippo Valsorda
21a7203f6a README: add link to Go documentation 2020-07-20 19:34:08 -04:00
Filippo Valsorda
0c650f815d age: fix filippo.io/age/agessh name in package docs
Thanks to @Mohammed90 for pointing this out.
2020-06-27 23:47:17 -04:00
Filippo Valsorda
189041b668 age: move package from filippo.io/age/age to filippo.io/age 🤦‍♂️ v1.0.0-beta4 2020-06-27 22:06:32 -04:00
Filippo Valsorda
e609359651 age,agessh,armor: unleash public API 💥🦑 v1.0.0-beta3 2020-06-27 21:08:42 -04:00
Filippo Valsorda
33355dcc1c internal/age: unexport NewX25519Recipient and NewX25519Identity 2020-06-27 21:03:35 -04:00
Filippo Valsorda
9a08b7e66f internal/age,internal/armor: add examples 2020-06-27 21:03:09 -04:00
Filippo Valsorda
9b83d948f5 internal/age: surface format.Recipient as type Stanza 2020-06-27 19:44:26 -04:00
Filippo Valsorda
c9a35c0727 internal/agessh: move EncryptedSSHIdentity out of cmd/age 2020-05-19 02:07:27 -04:00
Filippo Valsorda
7d608d1219 .github/workflows: add rage interop tests trigger (#125) 2020-05-18 20:44:50 -04:00
Filippo Valsorda
6782356e45 internal/age: add some docs and polish API 2020-05-18 02:53:37 -04:00
Filippo Valsorda
085466567a internal/format: fix a nasty bufio.Reader nesting bug 2020-05-18 02:28:31 -04:00
Filippo Valsorda
292c3aaeea internal/agessh: new package
Move the SSH recipient types out of the main package to declutter the
godoc. This also allows us to drop the x/crypto/ssh build dependency
entirely from the age package import tree.
2020-05-18 01:20:08 -04:00
Filippo Valsorda
b32ea4c1f6 cmd/age: add a TODO about not dumping decrypted binary to the terminal 2020-05-18 00:21:41 -04:00
Filippo Valsorda
c7c7f1870f internal/armor: new package 2020-05-18 00:12:36 -04:00
Filippo Valsorda
a7c4274d23 internal/age: remove EncryptWithArmor and armor support in Decrypt
The caller can take care of the armor. For consistency move the
responsibility to close the armor to the caller, and make the stream
Writer not propagate Close.

This also will also allow us to spin the armor implementation out into
its won package that imports format, without getting an import loop from
format.Parse magically invoking armor decoding.

Less magic in the API, more magic in the CLI.
2020-05-18 00:11:21 -04:00
Filippo Valsorda
7088a73234 internal/age: unexport SSHFingerprint 2020-05-18 00:05:25 -04:00
Filippo Valsorda
f0f8092d60 internal/format: update fuzzing target
Fixes #96
2020-03-25 02:23:37 -04:00
Filippo Valsorda
f28f85d87b internal/format: require recipients and arguments not to be empty
Also updated the spec to clarify that arbitrary strings can't be empty.
2020-03-25 02:22:58 -04:00
Filippo Valsorda
f54bb8daab internal/format: don't generate and reject empty lines in recipient bodies
Detected by https://github.com/str4d/rage/runs/532262359 and by go-fuzz.
2020-03-25 02:22:58 -04:00
Ross Kinsey
35e582514d go.mod: update x/crypto for aes256-cbc support (#111, golang/go#37939) 2020-03-24 01:57:18 -04:00
Filippo Valsorda
111d0fe1f4 go.mod: update x/crypto to bring in fix for golang/go#36609
Updates #78
2020-02-20 11:13:44 -05:00
Filippo Valsorda
9fdb125641 go.mod: switch to upstream golang.org/x/crypto
Fixes #99
2020-02-04 14:14:08 -05:00
Mike Sampson
a798d4ef31 README: add Arch Linux AUR instructions (#76)
Co-authored-by: Filippo Valsorda <1225294+FiloSottile@users.noreply.github.com>
2020-01-10 16:27:00 -05:00
Li-Wen Hsu
68da6c5f50 README: add FreeBSD installation instruction (#79)
Co-authored-by: Filippo Valsorda <1225294+FiloSottile@users.noreply.github.com>
2020-01-10 16:21:19 -05:00
Anand Sharma
2419b5da58 README: fix a typo in the SSH Keys section (#85)
Co-authored-by: Filippo Valsorda <1225294+FiloSottile@users.noreply.github.com>
2020-01-10 16:19:42 -05:00
Filippo Valsorda
4e84199130 .github: update spec-feedback.md 2020-01-08 14:24:02 -05:00
Filippo Valsorda
f9f6d7ca50 .github: add specification feedback issue template 2020-01-08 14:22:08 -05:00
Filippo Valsorda
e43cf8b4a2 cmd/age: improve incorrect passphrase error message
Fixes #41
2019-12-31 14:20:39 +01:00
Filippo Valsorda
7935150f35 internal/age: improve empty passphrase error message
Fixes #62
2019-12-31 14:20:39 +01:00
Ed Maste
1110c3b6e1 .cirrus.yml: enable Cirrus CI for FreeBSD CI (#58) 2019-12-31 00:23:34 +01:00
Joe Shaw
1223fbe6da HomebrewFormula: update to beta2 (#60) 2019-12-31 00:14:01 +01:00