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.
This commit is contained in:
Filippo Valsorda
2020-05-17 13:47:13 -04:00
parent 7088a73234
commit a7c4274d23
5 changed files with 26 additions and 49 deletions

View File

@@ -112,13 +112,6 @@ func Parse(input io.Reader) (*Header, io.Reader, error) {
h := &Header{}
rr := bufio.NewReader(input)
// TODO: find a way to communicate to the caller that the file was armored,
// as they might not appreciate the malleability.
if start, _ := rr.Peek(len(armorPreamble)); string(start) == armorPreamble {
input = ArmoredReader(rr)
rr = bufio.NewReader(input)
}
line, err := rr.ReadString('\n')
if err != nil {
return nil, nil, errorf("failed to read intro: %v", err)