FiloSottile / age

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.
https://age-encryption.org
BSD 3-Clause "New" or "Revised" License
15.95k stars 482 forks source link

"invalid armor closing line" on inputs with specific lengths #263

Closed pennae closed 3 years ago

pennae commented 3 years ago

Environment

What were you trying to do

encrypt a thing that's 38 bytes long without having age crash because it emits invalid armored output

What happened

~ % priv=$(age-keygen)
Public key: age1c73ql4n652jz792gwfvyxx53086kyfu95p9t458pqhk8te85yg2qpwcfqg
~ % pub=$(age-keygen -y <(echo $priv))
~ % ct=$(echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | age -e -a -r $pub)                                                          
~ % age -d -i <(echo $priv) <(echo $ct)
Error: invalid armor closing line: 
[ Did age not do what you expected? Could an error be more useful? Tell us: https://filippo.io/age/report ]
1 ~ % echo $ct
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBIZlV5Ly8yL05tYVZ5ZnJG
ZmRhVjlLeVJNK3lhU2oyV1crSmFNeUs2ZkI0CkRtY0RRdW02N0JvZnBXenJOcUZo
MG8yV3hMQVlWR2RXOG5jQTJ6Z2tkOHcKLS0tIGRWdHhJMzZJOXE1OEExbm1wYisr
VGhMaVBhUE1BbUVWSzU0RUgzREFWWW8Kpj8xwx+HyZJOsYUmyDeI328XeMVg2inz
eMFGurvx6Y9ylAQjIV93WwSJqWDVraeIRpzZfXWeF+yPszZvT75GjNuJuZjsoKo=

-----END AGE ENCRYPTED FILE-----
FiloSottile commented 3 years ago

This is now fixed in v1.0.0-rc.2. Thank you for reporting it.

If anyone needs to decrypt a file that suffered from this issue, you can remove the empty line before the -----END AGE ENCRYPTED FILE----- line, and the file will decrypt successfully. Sorry for the bug!