Commit Graph

45 Commits

Author SHA1 Message Date
Filippo Valsorda
15df6e2cf7 internal/format: require the last line of stanzas to be short
We are going to reuse the stanza format for IPC in the plugin protocol,
but in that context we need stanzas to be self-closing. Currently they
almost are, but if the body is 0 modulo 48, there is no way to know if
the stanza is over after the last line.

Now, all stanzas have to end with a short line, even if empty.

No ciphertexts generated by age in the past are affected, but 3% of the
ciphertexts generated by rage will now stop working. They are still
supported by rage going forward. If it turns out to be a common issue,
we can add an exception.
2021-02-08 19:55:28 +01:00
Matthias Schneider
a02075a0cc internal/stream: fix readChunk documentation (#163)
r.c was renamed to r.src.
2021-01-03 15:26:48 +01: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
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
e609359651 age,agessh,armor: unleash public API 💥🦑 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
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
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
Filippo Valsorda
9fdb125641 go.mod: switch to upstream golang.org/x/crypto
Fixes #99
2020-02-04 14:14: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
Filippo Valsorda
3807646596 internal/age: don't log binary data in tests
Fixes #32
2019-12-30 01:43:42 +01:00
Filippo Valsorda
63301d18b4 internal/age: add a comment about the fixed AEAD nonce 2019-12-28 02:43:51 +01:00
Filippo Valsorda
bbab440e19 internal/age: add a label to the scrypt salt
This way every recipient is labeled with the version.

-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNjcnlwdCBSbmw2ellyQ1VFK25rVkwx
TkF0SklnIDE4CjlZL2RKb2FOcjFrM0MwSVZqS1BzMUFLeVF5Y1RaMEwvQlRLMWwv
Q0xJbEEKLS0tIEJ1STZCbFh5Vjdsam5nSEFGTVZUY1BxcVVIek04ZUVrOGR4L3ph
NkYzS28KucY25ejFefMDMtKvsAEofDQLsYF41NPrSPITpoxuVWMMZ1ldm+lDh09q
RzCIZAhLN8jaqdeVdCEutqiniJ/9qv4=
-----END AGE ENCRYPTED FILE-----

Password: lies
2019-12-27 17:13:20 +01:00
Filippo Valsorda
158b2ce899 all: switch labels and intro to age-encryption.org/v1 2019-12-27 17:13:20 +01:00
Filippo Valsorda
c434eee6e8 internal/format: switch armor to PEM
It's with a heavy heart that I admit using the ASCII header as part of
the armor was clever, and you know what we think about being clever
around here.

Still, PEM is so lax, we target a subset without headers, and without
garbage before and after the markers.

-----BEGIN AGE ENCRYPTED FILE-----
VGhpcyBpcyBhIGZpbGUgZW5jcnlwdGVkIHdpdGggYWdlLXRvb2wuY29tLCB2ZXJz
aW9uIDEKLT4gWDI1NTE5IGozWWtNTWtaVGNDc0tKVGtMN29aam9NT2FUaGpBTVdU
Y1k5ZHVNdWJhUlkKb0F5d2N4ZW1lSTM1SkZiWHIxcHRFWW0rMjNzK3RuOTg1OHpN
L0ZkVzNCTQotLS0gQWZqdXFFaXNhbmYxbGpPRVZsSS9QM0wyM0RrTHRWWElsQnFu
ejFmRW4zdwq1FMc+yjVJBDuBUZSPMi0nCAtELIObQOHHQlQnvhk6BCITceOD5DbN
S7b6oumB8i/hEJvTtsOLgTBofzqzB90iAQ==
-----END AGE ENCRYPTED FILE-----

AGE-SECRET-KEY-1Y77J4M9R7GEKMZHR6YFDLDWV74VK2YQV4C7SR2H7SSVVJ05HQS4Q7NNMS3
2019-12-27 17:13:20 +01:00
Filippo Valsorda
b142e0fd01 internal/format: switch to 64 columns of standard Base64
Now that we don't use Base64 in keys, let's just go back to the standard
alphabet. Still in the spirit of reducing weirdness, use the PEM column
count, so we can also reuse the lineWriter for the PEM armor.

See https://groups.google.com/d/msg/age-dev/UAjkvLoCr9I/l4Q1h3OPAgAJ.
2019-12-27 17:13:20 +01:00
Filippo Valsorda
9a84e437b1 all: switch key format to Bech32
Use the BIP173 format, which is whole-word selectable, markup safe, and
case insensitive.

AGE-SECRET-KEY-1FPSHVEFQXYSX5MMFDE6ZCGRTV4JHQGRFWSS8WETVDSSX76TVV4JQU272CR

See https://groups.google.com/d/msg/age-dev/UAjkvLoCr9I/l4Q1h3OPAgAJ.

All bech32 Go packages have funky APIs, internal types, or case
handling, so include a heavily refactored version of the reference
implementation, and the tests from github.com/btcsuite/btcutil/bech32.
2019-12-27 17:13:20 +01:00
Filippo Valsorda
93ea79628d all: change module name to filippo.io/age
No need to tie ourselves to GitHub.

The redirect is not set up yet, but as long as there is a replace in the
go.mod the tool can't be installed with "go get" anyway.

Not using age-tool.com because A) I don't actually like the domain and
B) it should be about the spec not the specific implementation.
2019-12-07 00:59:41 -05:00
Filippo Valsorda
03f7237541 internal/age: refactor to use the new golang.org/x/crypto/curve25519 API 2019-11-27 22:49:40 -04:00
Filippo Valsorda
9821fcefc9 internal/stream: fix TestRoundTrip 2019-11-27 22:00:48 -04:00
Filippo Valsorda
884b6f365d internal/age: support parsing armored files 2019-11-24 22:28:57 -05:00
Filippo Valsorda
4c4e446f72 internal/age,internal/format: implement armored file generation 2019-11-24 21:10:57 -05:00
Filippo Valsorda
c624abc0ad cmd/age: add support for encrypted SSH key files 2019-11-24 19:15:53 -05:00
Filippo Valsorda
a5bf40786d cmd/age: add -i and -o flags 2019-10-14 21:09:11 -04:00
Filippo Valsorda
2a0aef5803 internal/age: use a prototype of X25519 from golang/go#32670 2019-10-13 18:14:54 -04:00
Filippo Valsorda
11fc3e293a internal/format: wrap body at 56 columns 2019-10-13 17:24:21 -04:00
Dimitris Apostolou
fe362d8f0a internal/age: fix typo in an ed25519PublicKeyToCurve25519 comment (#13) 2019-10-09 17:57:02 -04:00
Filippo Valsorda
a99e57c53c internal/age: make the scrypt recipient work parameter log2(N)
Fixes #10
2019-10-08 23:24:13 -04:00
Matt Layher
dd0939ffaa cmd/age: initial support for SSH identities and recipients
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2019-10-07 22:14:24 -04:00
Filippo Valsorda
022002171c internal/age: add ssh-ed25519 recipients 2019-10-07 00:45:59 -04:00
Filippo Valsorda
0940f184fb cmd/age: add a prototype of the command line tool 2019-10-06 23:16:20 -04:00
Filippo Valsorda
37d95cc84a all: remove AEAD marker
As Thomas convinced me, we can always add it back by bumping the
version, but the fewest knobs and joints we start with, the better.
2019-10-06 21:57:26 -04:00
Filippo Valsorda
e9c118cea0 internal: implement STREAM, key exchange, encryption and decryption
Developed live over 6 hours of streaming on Twitch.

https://twitter.com/FiloSottile/status/1180875486911766528
2019-10-06 21:19:04 -04:00
Filippo Valsorda
52dbe9eecf internal/format: implement outer layer parsing and marshaling 2019-10-05 22:45:51 -04:00