age decrypt refuses a text-form file with a blank line before its first line; age reads it #77

Open
opened 2026-10-13 00:50:53 +02:00 by clawbot · 0 comments
Collaborator

age decrypt recognises the text form (--armor output) only when the file begins exactly with -----BEGIN AGE ENCRYPTED FILE-----. A text-form file with a blank line or spaces in front, as pasted from mail or a terminal, is taken for the binary form and refused with decrypting: failed to read header: parsing age header: unexpected intro: "\n". The reference age tool (v1.3.2, cmd/age/age.go, decrypt) trims up to 1024 bytes of leading whitespace before looking for that line and decrypts the same file.

Where: internal/agekey/agekey.go:194-203 (unarmored).

How to see:

export KEYFUNC_MNEMONIC='abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
echo hi | ./keyfunc age encrypt --armor -o a.age
sed '1s/^/\n/' a.age | ./keyfunc age decrypt
./keyfunc age priv | tee id | sed d
sed '1s/^/\n/' a.age | age -d -i id

The third line is refused; the fifth prints hi.

Definition of done: a text-form file preceded by blank lines or spaces decrypts, as with age. A test in internal/agekey/agekey_test.go or internal/cli/age_test.go puts a newline and two spaces in front of an armored file and expects the plaintext.

Severity: minor. The file is intact and the reference tool reads it; the message does not say what to fix.

Model: fable-5-1

`age decrypt` recognises the text form (`--armor` output) only when the file begins exactly with `-----BEGIN AGE ENCRYPTED FILE-----`. A text-form file with a blank line or spaces in front, as pasted from mail or a terminal, is taken for the binary form and refused with `decrypting: failed to read header: parsing age header: unexpected intro: "\n"`. The reference `age` tool (v1.3.2, `cmd/age/age.go`, `decrypt`) trims up to 1024 bytes of leading whitespace before looking for that line and decrypts the same file. Where: `internal/agekey/agekey.go:194-203` (`unarmored`). How to see: export KEYFUNC_MNEMONIC='abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about' echo hi | ./keyfunc age encrypt --armor -o a.age sed '1s/^/\n/' a.age | ./keyfunc age decrypt ./keyfunc age priv | tee id | sed d sed '1s/^/\n/' a.age | age -d -i id The third line is refused; the fifth prints `hi`. **Definition of done**: a text-form file preceded by blank lines or spaces decrypts, as with `age`. A test in `internal/agekey/agekey_test.go` or `internal/cli/age_test.go` puts a newline and two spaces in front of an armored file and expects the plaintext. Severity: minor. The file is intact and the reference tool reads it; the message does not say what to fix. Model: fable-5-1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/keyfunc#77