mirror of
https://github.com/FiloSottile/age.git
synced 2026-01-03 10:55:14 +00:00
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.
This commit is contained in:
@@ -32,8 +32,6 @@ func Encrypt(dst io.Writer, recipients ...Recipient) (io.WriteCloser, error) {
|
||||
}
|
||||
|
||||
hdr := &format.Header{}
|
||||
// TODO: remove the AEAD marker from v1.
|
||||
hdr.AEAD = "ChaChaPoly"
|
||||
for i, r := range recipients {
|
||||
if r.Type() == "scrypt" && len(recipients) != 1 {
|
||||
return nil, errors.New("an scrypt recipient must be the only one")
|
||||
@@ -74,9 +72,6 @@ func Decrypt(src io.Reader, identities ...Identity) (io.Reader, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read header: %v", err)
|
||||
}
|
||||
if hdr.AEAD != "ChaChaPoly" {
|
||||
return nil, fmt.Errorf("unsupported AEAD: %v", hdr.AEAD)
|
||||
}
|
||||
if len(hdr.Recipients) > 20 {
|
||||
return nil, errors.New("too many recipients")
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
type Header struct {
|
||||
Recipients []*Recipient
|
||||
AEAD string
|
||||
MAC []byte
|
||||
}
|
||||
|
||||
@@ -61,7 +60,7 @@ func (h *Header) MarshalWithoutMAC(w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err := fmt.Fprintf(w, "%s %s", footerPrefix, h.AEAD)
|
||||
_, err := fmt.Fprintf(w, "%s", footerPrefix)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -107,11 +106,10 @@ func Parse(input io.Reader) (*Header, io.Reader, error) {
|
||||
|
||||
if bytes.HasPrefix(line, footerPrefix) {
|
||||
prefix, args := splitArgs(line)
|
||||
if prefix != string(footerPrefix) || len(args) != 2 {
|
||||
if prefix != string(footerPrefix) || len(args) != 1 {
|
||||
return nil, nil, errorf("malformed closing line: %q", line)
|
||||
}
|
||||
h.AEAD = args[0]
|
||||
h.MAC, err = DecodeString(args[1])
|
||||
h.MAC, err = DecodeString(args[0])
|
||||
if err != nil {
|
||||
return nil, nil, errorf("malformed closing line %q: %v", line, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user