Commit Graph

81 Commits

Author SHA1 Message Date
Filippo Valsorda
ae74b61b59 cmd/age,internal/stream: improve error messages 2025-12-07 20:01:09 +01:00
Alexander Yastrebov
cda3988cc7 all: fix staticcheck warnings (#589)
Co-authored-by: Filippo Valsorda <github@bip.filippo.io>
2024-12-18 15:55:57 +01:00
Filippo Valsorda
6976c5fca5 plugin: expose package 2023-08-05 21:34:14 +02:00
Filippo Valsorda
7354aa0d08 internal/bech32: remove data length limit
Fixes #453
2022-12-23 12:28:06 +01:00
Filippo Valsorda
bf8d2a3911 age: move testkit to CCTV 2022-10-28 20:11:09 +02:00
Filippo Valsorda
891be91d42 armor: add FuzzMalleability test 2022-07-03 12:48:48 +02:00
Filippo Valsorda
799c2bf8e8 tests: add armor tests 2022-07-03 12:48:48 +02:00
Filippo Valsorda
e84d74239e age: wrap decryption errors through and add armor.Error 2022-07-03 12:48:48 +02:00
Filippo Valsorda
8023f06ce2 all: build tag tests that require Go 1.18 2022-06-20 22:33:31 +01:00
Filippo Valsorda
4f7bb44386 internal/format: add malleability fuzz test 2022-06-20 01:18:48 +01:00
Filippo Valsorda
3f56ac13fb internal/stream: reject trailing data (no EOF) after end of stream 2022-06-19 23:11:14 +02:00
Filippo Valsorda
2e090545df age: reject leading zeroes and sign in scrypt work factor 2022-06-19 17:52:30 +02:00
Filippo Valsorda
2088adf268 tests: add expected no match and minor additions 2022-06-19 00:11:23 +02:00
Filippo Valsorda
eaa4e03cfe tests: finish parsing and X25519 tests, distinguish HMAC errors
If the implementation re-encodes the header before checking the HMAC,
that would mask malleability issues: the HMAC check would fail because
the tests HMAC'd the original header, but an attacker could also produce
the right HMAC. Instead of duplicating every parsing tests (with the
original and re-encoded HMAC), we make the test framework distinguish
HMAC errors, which ensures bad encodings are recognized as such and not
bypassable HMAC errors.
2022-06-18 13:47:00 +02:00
Filippo Valsorda
f8a121dd87 tests: add more tests for hmac and X25519 encodings 2022-06-16 15:55:29 +02:00
Filippo Valsorda
92713afd1e tests: add scrypt tests and move Go files from testdata 2022-06-15 20:38:59 +02:00
Filippo Valsorda
787044bdb6 testdata: convert last chunk tests to testkit 2022-06-15 19:38:18 +02:00
Filippo Valsorda
a787511e01 testdata: add a few more testkit vectors 2022-06-15 18:54:09 +02:00
Filippo Valsorda
e49b1f9afe internal/testkit: new test framework 2022-06-15 18:53:07 +02:00
Filippo Valsorda
5824a13b57 cmd/age,internal/plugin: print a message if waiting on a plugin for too long 2022-05-24 15:57:42 +02:00
Filippo Valsorda
c0e80ef2c9 cmd/age: improve confirm dialog
Don't require enter after the selection number, print errors as
warnings, and retry if an unexpected selection is made.
2022-05-24 15:56:22 +02:00
Filippo Valsorda
eeb9a079da cmd/age: add -j option for data-less plugins
See str4d/rage#237 and str4d/rage#236
2022-05-24 15:56:22 +02:00
Filippo Valsorda
87a982b72e internal/plugin: refactor plugin handling code 2022-05-24 15:56:22 +02:00
Filippo Valsorda
5a0da177e9 internal/plugin,cmd/age: implement confirm protocol verb 2022-05-24 15:56:22 +02:00
Filippo Valsorda
349ed5ed3f cmd/age: clean up the terminal UI 2022-05-24 15:56:22 +02:00
Filippo Valsorda
384d0393e0 internal/plugin,cmd/age: add support for encrypting to plugin identities 2022-05-24 15:56:22 +02:00
Filippo Valsorda
7bad9c2ad8 internal/plugin: update to latest plugin spec
The main change is that phase 2 of the wrapping state machine is
interactive to accommodate symmetric plugins.
2022-05-24 15:56:22 +02:00
Filippo Valsorda
01b56b117c internal/plugin: complete experimental plugin support 2022-05-24 15:56:22 +02:00
Filippo Valsorda
f6a5b94705 internal/plugin,cmd/age: implement preliminary plugin client support 2022-05-24 15:56:22 +02:00
Filippo Valsorda
30d8e65e03 internal/stream: disallow empty final chunks
A non-empty payload of length a multiple of the chunk size can be
encrypted in two ways: with the last chunk full, or with an extra empty
last chunk. This is mostly an oversight in the original spec.

Both age and rage generate full last chunks, so we should be still in
time to pick one of the two, and avoid the underspecification. It's not
the one I would have picked originally, maybe, because disallowing full
last chunks would have avoided the trial decryption, but oh well.
2022-05-24 15:47:13 +02:00
Filippo Valsorda
765400f0c1 internal/format: factor out a StanzaReader for use in the plugin protocol 2022-05-22 11:54:38 +02:00
Richard Ulmer
f7fcbef542 internal/stream: remove unused variable from testRoundTrip (#396) 2022-04-27 07:31:48 -04:00
Helio Machado
d717942b93 internal/format: improve error message for old header format (#398) 2022-04-26 13:30:35 -04:00
Filippo Valsorda
dfa2052cb7 all: move copyright owners to AUTHORS file 2021-11-24 11:29:15 +01:00
Filippo Valsorda
6596145a2c armor: don't leave an empty line before the footer
Closes #264
Fixes #263
2021-05-26 13:35:30 +02:00
Filippo Valsorda
69e2222921 internal/format: drop go-fuzz test case
We were not running it in CI, so it had rotted or was going to rot.
We'll replace it with a native fuzz test once that's ready.
2021-03-10 05:38:47 -05:00
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