FiloSottile / age

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

Home Page:https://age-encryption.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error trying to read both passphrase and input from stdin on Windows

SirRandom opened this issue · comments

commented

Environment

  • OS: Windows 10 Pro (x86_64) Build 19041.804
  • age version: v1.0.0-rc.1

What I was trying to do

Not sure if I have the correct cmdline for this but I was trying to password-encrypt some arbitrary words from stdin using

age -p -o out

What happened

Seems like age is trying to open /dev/tty which does not exist on Windows.

Command line: age -p -o out

Enter passphrase (leave empty to autogenerate a secure one): Error: could not read passphrase: standard input is not available or not a terminal, and opening /dev/tty failed: open /dev/tty: The system cannot find the path specified.
[ Did age not do what you expected? Could an error be more useful? Tell us: https://filippo.io/age/report ]

We need to improve the error message, but the issue here is that age is refusing to use stdin for both the passphrase and the input. We could read one line for the passphrase and then consider the rest the input, but it feels like something that's easy to get wrong.

Ok, so the logic will have to be a bit more complicated to be safe, since we don't want to read both passphrase and input from a pipe, but doing it from a terminal sounds reasonable, and I think we can make the behavior cross-platform.