31 Commits

Author SHA1 Message Date
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
891be91d42 armor: add FuzzMalleability test 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
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
765400f0c1 internal/format: factor out a StanzaReader for use in the plugin protocol 2022-05-22 11:54:38 +02: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
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
9b83d948f5 internal/age: surface format.Recipient as type Stanza 2020-06-27 19:44:26 -04:00
Filippo Valsorda
085466567a internal/format: fix a nasty bufio.Reader nesting bug 2020-05-18 02:28:31 -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
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
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
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
11fc3e293a internal/format: wrap body at 56 columns 2019-10-13 17:24:21 -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