diff --git a/internal/testkit/testkit.go b/internal/testkit/testkit.go deleted file mode 100644 index f6bb52b..0000000 --- a/internal/testkit/testkit.go +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package testkit - -import ( - "bytes" - "crypto/hmac" - "crypto/sha256" - "encoding/base64" - "encoding/hex" - "fmt" - "io" - "os" - "strconv" - "strings" - - "filippo.io/age/internal/bech32" - "golang.org/x/crypto/chacha20" - "golang.org/x/crypto/chacha20poly1305" - "golang.org/x/crypto/curve25519" - "golang.org/x/crypto/hkdf" - "golang.org/x/crypto/scrypt" -) - -var TestFileKey = []byte("YELLOW SUBMARINE") - -var _, TestX25519Identity, _ = bech32.Decode( - "AGE-SECRET-KEY-1EGTZVFFV20835NWYV6270LXYVK2VKNX2MMDKWYKLMGR48UAWX40Q2P2LM0") - -var TestX25519Recipient, _ = curve25519.X25519(TestX25519Identity, curve25519.Basepoint) - -// These are the file key and nonce used to encrypt any full/multiple-chunk -// tests. They were generated by a previous iteration of this test suite. -// Reusing them across files and history makes the repository easier to pack and -// the test suite easier to compress. -var LargeTestFileKey, _ = hex.DecodeString("7aa5bdac0e6afeed3dd0a7eccb42af44") -var LargeTestNonce, _ = hex.DecodeString("c82f71eb82029b77136399e485e879f4") -var LargeTestFirstChunk = bytes.Repeat([]byte{0}, 64*1024) -var LargeTestSecondChunk = bytes.Repeat([]byte{1}, 64*1024) -var LargeTestThirdChunk = bytes.Repeat([]byte{2}, 64*1024) - -func NotCanonicalBase64(s string) string { - // Assuming there are spare zero bits at the end of the encoded bitstring, - // the character immediately after in the alphabet compared to the last one - // in the encoding will only flip the last bit to one, making the string a - // non-canonical encoding of the same value. - alphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" - idx := strings.IndexByte(alphabet, s[len(s)-1]) - return s[:len(s)-1] + string(alphabet[idx+1]) -} - -type TestFile struct { - Buf bytes.Buffer - Rand func(n int) []byte - - fileKey []byte - streamKey []byte - nonce [12]byte - payload bytes.Buffer - expect string - comment string - identities []string - passphrases []string - armor bool -} - -func NewTestFile() *TestFile { - c, _ := chacha20.NewUnauthenticatedCipher( - []byte("TEST RANDOMNESS TEST RANDOMNESS!"), make([]byte, chacha20.NonceSize)) - rand := func(n int) []byte { - out := make([]byte, n) - c.XORKeyStream(out, out) - return out - } - return &TestFile{Rand: rand, expect: "success", fileKey: TestFileKey} -} - -func (f *TestFile) FileKey(key []byte) { - f.fileKey = key -} - -func (f *TestFile) TextLine(s string) { - f.Buf.WriteString(s) - f.Buf.WriteString("\n") -} - -func (f *TestFile) UnreadLine() string { - buf := bytes.TrimSuffix(f.Buf.Bytes(), []byte("\n")) - idx := bytes.LastIndex(buf, []byte("\n")) + 1 - f.Buf.Reset() - f.Buf.Write(buf[:idx]) - return string(buf[idx:]) -} - -func (f *TestFile) VersionLine(v string) { - f.TextLine("age-encryption.org/" + v) -} - -func (f *TestFile) ArgsLine(args ...string) { - f.TextLine(strings.Join(append([]string{"->"}, args...), " ")) -} - -func (f *TestFile) UnreadArgsLine() []string { - line := strings.TrimPrefix(f.UnreadLine(), "-> ") - return strings.Split(line, " ") -} - -var b64 = base64.RawStdEncoding.EncodeToString - -func (f *TestFile) Body(body []byte) { - for { - line := body - if len(line) > 48 { - line = line[:48] - } - f.TextLine(b64(line)) - body = body[len(line):] - if len(line) < 48 { - break - } - } -} - -func (f *TestFile) Base64Padding() { - line := f.UnreadLine() - paddingLen := 4 - len(line)%4 - if paddingLen == 4 { - paddingLen = 0 - } - padding := strings.Repeat("=", paddingLen) - f.TextLine(line + padding) -} - -func (f *TestFile) AEADBody(key, body []byte) { - aead, _ := chacha20poly1305.New(key) - f.Body(aead.Seal(nil, make([]byte, chacha20poly1305.NonceSize), body, nil)) -} - -func x25519(scalar, point []byte) []byte { - secret, err := curve25519.X25519(scalar, point) - if err != nil { - if err.Error() == "bad input point: low order point" { - return make([]byte, 32) - } - panic(err) - } - return secret -} - -func (f *TestFile) X25519(identity []byte) { - f.X25519RecordIdentity(identity) - f.X25519NoRecordIdentity(identity) -} - -func (f *TestFile) X25519RecordIdentity(identity []byte) { - id, _ := bech32.Encode("AGE-SECRET-KEY-", identity) - f.identities = append(f.identities, id) -} - -func (f *TestFile) X25519NoRecordIdentity(identity []byte) { - share := x25519(f.Rand(32), curve25519.Basepoint) - f.X25519Stanza(share, identity) -} - -func (f *TestFile) X25519Stanza(share, identity []byte) { - recipient := x25519(identity, curve25519.Basepoint) - f.ArgsLine("X25519", b64(share)) - // This would be ordinarily done as [ephemeral]recipient rather than - // [identity]share, but for some tests we don't have the dlog of share. - secret := x25519(identity, share) - key := make([]byte, 32) - hkdf.New(sha256.New, secret, append(share, recipient...), - []byte("age-encryption.org/v1/X25519")).Read(key) - f.AEADBody(key, f.fileKey) -} - -func (f *TestFile) Scrypt(passphrase string, workFactor int) { - f.ScryptRecordPassphrase(passphrase) - f.ScryptNoRecordPassphrase(passphrase, workFactor) -} - -func (f *TestFile) ScryptRecordPassphrase(passphrase string) { - f.passphrases = append(f.passphrases, passphrase) -} - -func (f *TestFile) ScryptNoRecordPassphrase(passphrase string, workFactor int) { - salt := f.Rand(16) - f.ScryptNoRecordPassphraseWithSalt(passphrase, workFactor, salt) -} - -func (f *TestFile) ScryptNoRecordPassphraseWithSalt(passphrase string, workFactor int, salt []byte) { - f.ArgsLine("scrypt", b64(salt), strconv.Itoa(workFactor)) - key, err := scrypt.Key([]byte(passphrase), append([]byte("age-encryption.org/v1/scrypt"), salt...), - 1< %s\n", generator, vector) - out, err := exec.Command("go", "run", generator).Output() - if err != nil { - if err, ok := err.(*exec.ExitError); ok { - log.Fatalf("%s", err.Stderr) - } - log.Fatal(err) - } - os.WriteFile(vector, out, 0664) - } +func TestVectors(t *testing.T) { + if _, err := exec.LookPath("go"); err != nil { + t.Skipf("skipping test because 'go' command is unavailable: %v", err) } - os.Exit(m.Run()) -} - -func TestVectors(t *testing.T) { - tests, err := filepath.Glob("testdata/testkit/*") + // Download the testkit files from CCTV using `go mod download -json` so the + // cached source of the testdata can be reused. + path := "c2sp.org/CCTV/age@v0.0.0-20221027185432-cfaa74dc42af" + cmd := exec.Command("go", "mod", "download", "-json", path) + output, err := cmd.Output() if err != nil { - log.Fatal(err) + t.Fatalf("failed to run `go mod download -json %s`, output: %s", path, output) + } + var dm struct { + Dir string // absolute path to cached source root directory + } + if err := json.Unmarshal(output, &dm); err != nil { + t.Fatal(err) + } + testkitDir := filepath.Join(dm.Dir, "testdata") + + tests, err := filepath.Glob(testkitDir + "/*") + if err != nil { + t.Fatal(err) } for _, test := range tests { contents, err := os.ReadFile(test) if err != nil { t.Fatal(err) } - name := strings.TrimPrefix(test, "testdata/testkit/") + name := filepath.Base(test) t.Run(name, func(t *testing.T) { testVector(t, contents) }) diff --git a/tests/armor.go b/tests/armor.go deleted file mode 100644 index 1c00ead..0000000 --- a/tests/armor.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.Generate() -} diff --git a/tests/armor_crlf.go b/tests/armor_crlf.go deleted file mode 100644 index 8b2f569..0000000 --- a/tests/armor_crlf.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "bytes" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - armored := f.Bytes() - f.Buf.Reset() - f.Buf.Write(bytes.Replace(armored, []byte("\n"), []byte("\r\n"), -1)) - f.Comment("CRLF is allowed as a end of line for armored files") - f.Generate() -} diff --git a/tests/armor_empty_line_begin.go b/tests/armor_empty_line_begin.go deleted file mode 100644 index 75dfff2..0000000 --- a/tests/armor_empty_line_begin.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.TextLine("") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_empty_line_end.go b/tests/armor_empty_line_end.go deleted file mode 100644 index 68ff502..0000000 --- a/tests/armor_empty_line_end.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.TextLine("") - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_eol_between_padding.go b/tests/armor_eol_between_padding.go deleted file mode 100644 index eaef051..0000000 --- a/tests/armor_eol_between_padding.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "strings" - - "filippo.io/age/internal/testkit" -) - -// See base64finl in RFC 7468. -// ; ...AB= = is not good, but is valid - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age12") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - line := f.UnreadLine() - if !strings.Contains(line, "==") { - panic("need two padding characters") - } - line = strings.Replace(line, "==", "=\n=", 1) - f.TextLine(line) - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_full_last_line.go b/tests/armor_full_last_line.go deleted file mode 100644 index be76f87..0000000 --- a/tests/armor_full_last_line.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age age age age age age age age age age ") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - if len(file)%48 != 0 { - println(len(file) % 48) - panic("last line is not full") - } - f.Body(file) - f.UnreadLine() // Body leaves an empty line, PEM doesn't. - f.EndArmor("AGE ENCRYPTED FILE") - f.Generate() -} diff --git a/tests/armor_garbage_encoded.go b/tests/armor_garbage_encoded.go deleted file mode 100644 index 1898582..0000000 --- a/tests/armor_garbage_encoded.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunkFinal(testkit.LargeTestFirstChunk) - f.Buf.Write(f.Rand(20)) - f.ExpectPartialPayload(64 * 1024) - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.Comment("there is trailing garbage encoded after the final chunk") - f.Generate() -} diff --git a/tests/armor_garbage_leading.go b/tests/armor_garbage_leading.go deleted file mode 100644 index a700abc..0000000 --- a/tests/armor_garbage_leading.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.TextLine("garbage") - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_garbage_trailing.go b/tests/armor_garbage_trailing.go deleted file mode 100644 index 5126143..0000000 --- a/tests/armor_garbage_trailing.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.TextLine("garbage") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_header_crlf.go b/tests/armor_header_crlf.go deleted file mode 100644 index 5a90246..0000000 --- a/tests/armor_header_crlf.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "bytes" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - hdr := f.Buf.Bytes() - f.Buf.Reset() - f.Buf.Write(bytes.Replace(hdr, []byte("\n"), []byte("\r\n"), -1)) - f.HMAC() - f.Buf.WriteString(f.UnreadLine() + "\r\n") - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("lines in the header end with CRLF instead of LF") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.Generate() -} diff --git a/tests/armor_headers.go b/tests/armor_headers.go deleted file mode 100644 index 7cfd549..0000000 --- a/tests/armor_headers.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.TextLine("Headers: are") - f.TextLine("Not: allowed") - f.TextLine("") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_invalid_character_header.go b/tests/armor_invalid_character_header.go deleted file mode 100644 index cfc7d72..0000000 --- a/tests/armor_invalid_character_header.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "strings" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - begin, rest, _ := strings.Cut(string(f.Bytes()), "\n") - f.Buf.Reset() - f.TextLine(begin) - f.Buf.WriteString(rest[:4] + "*" + rest[5:]) - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_invalid_character_payload.go b/tests/armor_invalid_character_payload.go deleted file mode 100644 index 0738b5f..0000000 --- a/tests/armor_invalid_character_payload.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - line := f.UnreadLine() - f.TextLine("*" + line[1:]) - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_long_line.go b/tests/armor_long_line.go deleted file mode 100644 index aae9f94..0000000 --- a/tests/armor_long_line.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "encoding/base64" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.TextLine(base64.StdEncoding.EncodeToString(file)) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_lowercase.go b/tests/armor_lowercase.go deleted file mode 100644 index cb823b4..0000000 --- a/tests/armor_lowercase.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("age ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.EndArmor("age ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_no_end_line.go b/tests/armor_no_end_line.go deleted file mode 100644 index 46b8f03..0000000 --- a/tests/armor_no_end_line.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_no_eol.go b/tests/armor_no_eol.go deleted file mode 100644 index e9b673d..0000000 --- a/tests/armor_no_eol.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.Buf.WriteString("-----END AGE ENCRYPTED FILE-----") - f.Comment("there is no end of line at the end of the file") - f.Generate() -} diff --git a/tests/armor_no_match.go b/tests/armor_no_match.go deleted file mode 100644 index 130956d..0000000 --- a/tests/armor_no_match.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - identity := f.Rand(32) - f.X25519RecordIdentity(identity) - f.X25519NoRecordIdentity(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - f.ExpectNoMatch() - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.Generate() -} diff --git a/tests/armor_no_padding.go b/tests/armor_no_padding.go deleted file mode 100644 index 789efb9..0000000 --- a/tests/armor_no_padding.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - if len(file)%3 == 0 { - panic("no need for padding") - } - f.Body(file) - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Comment("missing base64 padding") - f.Generate() -} diff --git a/tests/armor_not_canonical.go b/tests/armor_not_canonical.go deleted file mode 100644 index 92efb83..0000000 --- a/tests/armor_not_canonical.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.TextLine(testkit.NotCanonicalBase64(f.UnreadLine())) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Comment("base64 is not canonical") - f.Generate() -} diff --git a/tests/armor_pgp_checksum.go b/tests/armor_pgp_checksum.go deleted file mode 100644 index 4172f09..0000000 --- a/tests/armor_pgp_checksum.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "filippo.io/age/internal/testkit" - "golang.org/x/crypto/openpgp/armor" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - w, _ := armor.Encode(&f.Buf, "AGE ENCRYPTED FILE", nil) - w.Write(file) - w.Close() - f.Buf.WriteString("\n") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_short_line.go b/tests/armor_short_line.go deleted file mode 100644 index 7a4df09..0000000 --- a/tests/armor_short_line.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file[:12]) - f.Body(file[12:]) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_whitespace_begin.go b/tests/armor_whitespace_begin.go deleted file mode 100644 index bf34a9a..0000000 --- a/tests/armor_whitespace_begin.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.TextLine("----- BEGIN AGE ENCRYPTED FILE -----") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_whitespace_end.go b/tests/armor_whitespace_end.go deleted file mode 100644 index c85bac1..0000000 --- a/tests/armor_whitespace_end.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.TextLine("----- END AGE ENCRYPTED FILE -----") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_whitespace_eol.go b/tests/armor_whitespace_eol.go deleted file mode 100644 index 32419d8..0000000 --- a/tests/armor_whitespace_eol.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - line2, line1 := f.UnreadLine(), f.UnreadLine() - f.TextLine(line1 + " ") - f.TextLine(line2) - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_whitespace_last_line.go b/tests/armor_whitespace_last_line.go deleted file mode 100644 index e287f0a..0000000 --- a/tests/armor_whitespace_last_line.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.TextLine(f.UnreadLine() + " ") - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_whitespace_line_start.go b/tests/armor_whitespace_line_start.go deleted file mode 100644 index cb17c9e..0000000 --- a/tests/armor_whitespace_line_start.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - line2, line1 := f.UnreadLine(), f.UnreadLine() - f.TextLine(" " + line1) - f.TextLine(line2) - f.EndArmor("AGE ENCRYPTED FILE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/armor_whitespace_outside.go b/tests/armor_whitespace_outside.go deleted file mode 100644 index 516c5fa..0000000 --- a/tests/armor_whitespace_outside.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.Buf.Write([]byte("\n\r \t\n")) - f.BeginArmor("AGE ENCRYPTED FILE") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED FILE") - f.Buf.Write([]byte("\n\r \t\n")) - f.Comment("whitespace is allowed before and after armored files") - f.Generate() -} diff --git a/tests/armor_wrong_type.go b/tests/armor_wrong_type.go deleted file mode 100644 index de8521d..0000000 --- a/tests/armor_wrong_type.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Bytes() - f.Buf.Reset() - f.BeginArmor("AGE ENCRYPTED MESSAGE") - f.Body(file) - f.Base64Padding() - f.EndArmor("AGE ENCRYPTED MESSAGE") - f.ExpectArmorFailure() - f.Generate() -} diff --git a/tests/header_crlf.go b/tests/header_crlf.go deleted file mode 100644 index 9071490..0000000 --- a/tests/header_crlf.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "bytes" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - hdr := f.Buf.Bytes() - f.Buf.Reset() - f.Buf.Write(bytes.Replace(hdr, []byte("\n"), []byte("\r\n"), -1)) - f.HMAC() - f.Buf.WriteString(f.UnreadLine() + "\r\n") - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("lines in the header end with CRLF instead of LF") - f.Generate() -} diff --git a/tests/hmac_bad.go b/tests/hmac_bad.go deleted file mode 100644 index 801f45d..0000000 --- a/tests/hmac_bad.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.FileKey(make([]byte, 16)) - f.HMAC() - f.FileKey(testkit.TestFileKey) - f.Payload("age") - f.ExpectHMACFailure() - f.Generate() -} diff --git a/tests/hmac_extra_space.go b/tests/hmac_extra_space.go deleted file mode 100644 index 300a76f..0000000 --- a/tests/hmac_extra_space.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "strings" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.TextLine(strings.Replace(f.UnreadLine(), "--- ", "--- ", -1)) - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/hmac_garbage.go b/tests/hmac_garbage.go deleted file mode 100644 index 0756f7d..0000000 --- a/tests/hmac_garbage.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.TextLine(f.UnreadLine() + "AAA") - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/hmac_missing.go b/tests/hmac_missing.go deleted file mode 100644 index 9b1b042..0000000 --- a/tests/hmac_missing.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMACLine(nil) - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/hmac_no_space.go b/tests/hmac_no_space.go deleted file mode 100644 index a249368..0000000 --- a/tests/hmac_no_space.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "strings" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.TextLine(strings.Replace(f.UnreadLine(), "--- ", "---", -1)) - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/hmac_not_canonical.go b/tests/hmac_not_canonical.go deleted file mode 100644 index 81968c7..0000000 --- a/tests/hmac_not_canonical.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.TextLine(testkit.NotCanonicalBase64(f.UnreadLine())) - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("the base64 encoding of the HMAC is not canonical") - f.Generate() -} diff --git a/tests/hmac_trailing_space.go b/tests/hmac_trailing_space.go deleted file mode 100644 index 93eecc6..0000000 --- a/tests/hmac_trailing_space.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.TextLine(f.UnreadLine() + " ") - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/hmac_truncated.go b/tests/hmac_truncated.go deleted file mode 100644 index 4336bea..0000000 --- a/tests/hmac_truncated.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.TextLine(f.UnreadLine()[:len("--- 1234")]) - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt.go b/tests/scrypt.go deleted file mode 100644 index 8bdb40e..0000000 --- a/tests/scrypt.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - f.HMAC() - f.Payload("age") - f.Generate() -} diff --git a/tests/scrypt_and_x25519.go b/tests/scrypt_and_x25519.go deleted file mode 100644 index efdc9fd..0000000 --- a/tests/scrypt_and_x25519.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519RecordIdentity(f.Rand(32)) - f.X25519NoRecordIdentity(testkit.TestX25519Identity) - f.Scrypt("password", 10) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("scrypt stanzas must be alone in the header") - f.Generate() -} diff --git a/tests/scrypt_bad_tag.go b/tests/scrypt_bad_tag.go deleted file mode 100644 index ee687ae..0000000 --- a/tests/scrypt_bad_tag.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "encoding/base64" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, _ := base64.RawStdEncoding.DecodeString(f.UnreadLine()) - body[len(body)-1] ^= 0xff - f.TextLine(base64.RawStdEncoding.EncodeToString(body)) - f.HMAC() - f.Payload("age") - f.ExpectNoMatch() - f.Comment("the ChaCha20Poly1305 authentication tag on the body of the scrypt stanza is wrong") - f.Generate() -} diff --git a/tests/scrypt_double.go b/tests/scrypt_double.go deleted file mode 100644 index 8118295..0000000 --- a/tests/scrypt_double.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - f.Scrypt("hunter2", 10) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("scrypt stanzas must be alone in the header") - f.Generate() -} diff --git a/tests/scrypt_extra_argument.go b/tests/scrypt_extra_argument.go deleted file mode 100644 index 7439b24..0000000 --- a/tests/scrypt_extra_argument.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadLine() - f.TextLine(args + " 10") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("the base64 encoding of the share is not canonical") - f.Generate() -} diff --git a/tests/scrypt_long_file_key.go b/tests/scrypt_long_file_key.go deleted file mode 100644 index d9da560..0000000 --- a/tests/scrypt_long_file_key.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey([]byte("A LONGER YELLOW SUBMARINE")) - f.VersionLine("v1") - f.Scrypt("password", 10) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("the file key must be checked to be 16 bytes before decrypting it") - f.Generate() -} diff --git a/tests/scrypt_no_match.go b/tests/scrypt_no_match.go deleted file mode 100644 index 32754eb..0000000 --- a/tests/scrypt_no_match.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.ScryptRecordPassphrase("wrong") - f.ScryptNoRecordPassphrase("password", 10) - f.HMAC() - f.Payload("age") - f.ExpectNoMatch() - f.Generate() -} diff --git a/tests/scrypt_not_canonical_body.go b/tests/scrypt_not_canonical_body.go deleted file mode 100644 index 35f83fe..0000000 --- a/tests/scrypt_not_canonical_body.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body := f.UnreadLine() - f.TextLine(testkit.NotCanonicalBase64(body)) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("the base64 encoding of the share is not canonical") - f.Generate() -} diff --git a/tests/scrypt_not_canonical_salt.go b/tests/scrypt_not_canonical_salt.go deleted file mode 100644 index 383ad0b..0000000 --- a/tests/scrypt_not_canonical_salt.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], testkit.NotCanonicalBase64(args[1]), args[2]) - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_salt_long.go b/tests/scrypt_salt_long.go deleted file mode 100644 index f2522c8..0000000 --- a/tests/scrypt_salt_long.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.ScryptRecordPassphrase("password") - f.ScryptNoRecordPassphraseWithSalt("password", 10, f.Rand(20)) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_salt_missing.go b/tests/scrypt_salt_missing.go deleted file mode 100644 index aa227a8..0000000 --- a/tests/scrypt_salt_missing.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.ScryptRecordPassphrase("password") - f.ScryptNoRecordPassphraseWithSalt("password", 10, nil) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[2]) - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_salt_short.go b/tests/scrypt_salt_short.go deleted file mode 100644 index 30ae21f..0000000 --- a/tests/scrypt_salt_short.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.ScryptRecordPassphrase("password") - f.ScryptNoRecordPassphraseWithSalt("password", 10, f.Rand(12)) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_uppercase.go b/tests/scrypt_uppercase.go deleted file mode 100644 index ec3e5ef..0000000 --- a/tests/scrypt_uppercase.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine("Scrypt", args[1], args[2]) - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectNoMatch() - f.Generate() -} diff --git a/tests/scrypt_work_factor_23.go b/tests/scrypt_work_factor_23.go deleted file mode 100644 index 5e6a786..0000000 --- a/tests/scrypt_work_factor_23.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - // Hardcoded because it would be too slow to regenerate every time. - // f.Scrypt("password", 23) - f.ScryptRecordPassphrase("password") - f.ArgsLine("scrypt", "rF0/NwblUHHTpgQgRpe5CQ", "23") - f.TextLine("qW9eVsT0NVb/Vswtw8kPIxUnaYmm9Px1dYmq2+4+qZA") - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("work factor is very high, would take a long time to compute") - f.Generate() -} diff --git a/tests/scrypt_work_factor_hex.go b/tests/scrypt_work_factor_hex.go deleted file mode 100644 index 59c5b03..0000000 --- a/tests/scrypt_work_factor_hex.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1], "0xa") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_work_factor_leading_garbage.go b/tests/scrypt_work_factor_leading_garbage.go deleted file mode 100644 index 50b2e21..0000000 --- a/tests/scrypt_work_factor_leading_garbage.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1], "aaaa10") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_work_factor_leading_plus.go b/tests/scrypt_work_factor_leading_plus.go deleted file mode 100644 index 9b84967..0000000 --- a/tests/scrypt_work_factor_leading_plus.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1], "+10") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_work_factor_leading_zero_decimal.go b/tests/scrypt_work_factor_leading_zero_decimal.go deleted file mode 100644 index 62f1e2e..0000000 --- a/tests/scrypt_work_factor_leading_zero_decimal.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1], "010") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_work_factor_leading_zero_octal.go b/tests/scrypt_work_factor_leading_zero_octal.go deleted file mode 100644 index 2485643..0000000 --- a/tests/scrypt_work_factor_leading_zero_octal.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1], "012") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_work_factor_missing.go b/tests/scrypt_work_factor_missing.go deleted file mode 100644 index fc6f580..0000000 --- a/tests/scrypt_work_factor_missing.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 18) // cmd/age default - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1]) - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_work_factor_negative.go b/tests/scrypt_work_factor_negative.go deleted file mode 100644 index 5ff675e..0000000 --- a/tests/scrypt_work_factor_negative.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1], "-10") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_work_factor_overflow.go b/tests/scrypt_work_factor_overflow.go deleted file mode 100644 index deb9cbc..0000000 --- a/tests/scrypt_work_factor_overflow.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "math" - "strconv" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1], strconv.FormatUint(math.MaxInt64+1+10, 10)) - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_work_factor_trailing_garbage.go b/tests/scrypt_work_factor_trailing_garbage.go deleted file mode 100644 index 50b2e21..0000000 --- a/tests/scrypt_work_factor_trailing_garbage.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1], "aaaa10") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/scrypt_work_factor_wrong.go b/tests/scrypt_work_factor_wrong.go deleted file mode 100644 index bb6101f..0000000 --- a/tests/scrypt_work_factor_wrong.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 18) // cmd/go default - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1], "10") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectNoMatch() - f.Generate() -} diff --git a/tests/scrypt_work_factor_zero.go b/tests/scrypt_work_factor_zero.go deleted file mode 100644 index 541f9d0..0000000 --- a/tests/scrypt_work_factor_zero.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.Scrypt("password", 10) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine(args[0], args[1], "0") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/stanza_bad_start.go b/tests/stanza_bad_start.go deleted file mode 100644 index 53542e7..0000000 --- a/tests/stanza_bad_start.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.TextLine("-- stanza") - f.Body([]byte("")) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/stanza_base64_padding.go b/tests/stanza_base64_padding.go deleted file mode 100644 index 76fb221..0000000 --- a/tests/stanza_base64_padding.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "bytes" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("stanza") - f.Body(bytes.Repeat([]byte("A"), 50)) - f.TextLine(f.UnreadLine() + "=") - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/stanza_empty_argument.go b/tests/stanza_empty_argument.go deleted file mode 100644 index 71c2c25..0000000 --- a/tests/stanza_empty_argument.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("stanza", "", "argument") - f.Body([]byte("")) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/stanza_empty_body.go b/tests/stanza_empty_body.go deleted file mode 100644 index 5013e94..0000000 --- a/tests/stanza_empty_body.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("empty") - f.Body([]byte("")) - f.HMAC() - f.Payload("age") - f.Generate() -} diff --git a/tests/stanza_empty_last_line.go b/tests/stanza_empty_last_line.go deleted file mode 100644 index f1e3777..0000000 --- a/tests/stanza_empty_last_line.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "bytes" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("stanza") - f.Body(bytes.Repeat([]byte("A"), 48*2)) - f.HMAC() - f.Payload("age") - f.Generate() -} diff --git a/tests/stanza_invalid_character.go b/tests/stanza_invalid_character.go deleted file mode 100644 index 143b488..0000000 --- a/tests/stanza_invalid_character.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("stanza", "รจ") - f.Body([]byte("")) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/stanza_long_line.go b/tests/stanza_long_line.go deleted file mode 100644 index 9debef1..0000000 --- a/tests/stanza_long_line.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "strings" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("stanza") - f.TextLine(strings.Repeat("A", 68)) - f.TextLine("") - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("a body line is longer than 64 columns") - f.Generate() -} diff --git a/tests/stanza_missing_body.go b/tests/stanza_missing_body.go deleted file mode 100644 index fc401ad..0000000 --- a/tests/stanza_missing_body.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("empty") - // Missing body. - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("every stanza must end with a short body line, even if empty") - f.Generate() -} diff --git a/tests/stanza_missing_final_line.go b/tests/stanza_missing_final_line.go deleted file mode 100644 index 5722283..0000000 --- a/tests/stanza_missing_final_line.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "strings" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("stanza") - f.TextLine(strings.Repeat("A", 64)) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("every stanza must end with a short body line") - f.Generate() -} diff --git a/tests/stanza_multiple_short_lines.go b/tests/stanza_multiple_short_lines.go deleted file mode 100644 index 427873f..0000000 --- a/tests/stanza_multiple_short_lines.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "strings" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("stanza") - f.TextLine(strings.Repeat("A", 32)) - f.TextLine(strings.Repeat("A", 32)) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("a short body line ends the stanza") - f.Generate() -} diff --git a/tests/stanza_no_arguments.go b/tests/stanza_no_arguments.go deleted file mode 100644 index 8963802..0000000 --- a/tests/stanza_no_arguments.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine() - f.Body([]byte("")) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/stanza_not_canonical.go b/tests/stanza_not_canonical.go deleted file mode 100644 index 3473f80..0000000 --- a/tests/stanza_not_canonical.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "bytes" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("stanza") - f.Body(bytes.Repeat([]byte("A"), 50)) - f.TextLine(testkit.NotCanonicalBase64(f.UnreadLine())) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/stanza_spurious_cr.go b/tests/stanza_spurious_cr.go deleted file mode 100644 index a1eddce..0000000 --- a/tests/stanza_spurious_cr.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "strings" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("stanza") - f.TextLine(strings.Repeat("A", 32) + "\r" + strings.Repeat("A", 31)) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/stanza_valid_characters.go b/tests/stanza_valid_characters.go deleted file mode 100644 index 74fc211..0000000 --- a/tests/stanza_valid_characters.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.ArgsLine("!\"#$%&'", "()*+,-./", "01234567", "89:;<=>?", "@ABCDEFG", "HIJKLMNO") - f.Body([]byte("")) - f.ArgsLine("PQRSTUVW", "XYZ[\\]^_", "`abcdefg", "hijklmno", "pqrstuvw", "xyz{|}~") - f.Body([]byte("")) - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - f.Generate() -} diff --git a/tests/stream_bad_tag.go b/tests/stream_bad_tag.go deleted file mode 100644 index e6a383b..0000000 --- a/tests/stream_bad_tag.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Buf.Bytes() - f.Buf.Reset() - file[len(file)-1] ^= 0b0010_0000 - f.Buf.Write(file) - f.ExpectPayloadFailure() - f.Generate() -} diff --git a/tests/stream_bad_tag_second_chunk.go b/tests/stream_bad_tag_second_chunk.go deleted file mode 100644 index bc3ffb0..0000000 --- a/tests/stream_bad_tag_second_chunk.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunk(testkit.LargeTestFirstChunk) - f.PayloadChunkFinal([]byte("age")) - file := f.Buf.Bytes() - f.Buf.Reset() - file[len(file)-1] ^= 0b0010_0000 - f.Buf.Write(file) - f.ExpectPartialPayload(64 * 1024) - f.Generate() -} diff --git a/tests/stream_bad_tag_second_chunk_full.go b/tests/stream_bad_tag_second_chunk_full.go deleted file mode 100644 index 58dd46f..0000000 --- a/tests/stream_bad_tag_second_chunk_full.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunk(testkit.LargeTestFirstChunk) - f.PayloadChunkFinal(testkit.LargeTestSecondChunk) - file := f.Buf.Bytes() - f.Buf.Reset() - file[len(file)-1] ^= 0b0010_0000 - f.Buf.Write(file) - f.ExpectPartialPayload(64 * 1024) - f.Generate() -} diff --git a/tests/stream_empty_payload.go b/tests/stream_empty_payload.go deleted file mode 100644 index 89e086b..0000000 --- a/tests/stream_empty_payload.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("") - f.Generate() -} diff --git a/tests/stream_last_chunk_empty.go b/tests/stream_last_chunk_empty.go deleted file mode 100644 index dcbcc0b..0000000 --- a/tests/stream_last_chunk_empty.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunk(testkit.LargeTestFirstChunk) - f.PayloadChunkFinal([]byte{}) - f.Comment("final STREAM chunk can't be empty unless whole payload is empty") - f.ExpectPartialPayload(64 * 1024) - f.Generate() -} diff --git a/tests/stream_last_chunk_full.go b/tests/stream_last_chunk_full.go deleted file mode 100644 index 09502e4..0000000 --- a/tests/stream_last_chunk_full.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunkFinal(testkit.LargeTestFirstChunk) - f.Generate() -} diff --git a/tests/stream_last_chunk_full_second.go b/tests/stream_last_chunk_full_second.go deleted file mode 100644 index ceeec8a..0000000 --- a/tests/stream_last_chunk_full_second.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunk(testkit.LargeTestFirstChunk) - f.PayloadChunkFinal(testkit.LargeTestSecondChunk) - f.Generate() -} diff --git a/tests/stream_missing_tag.go b/tests/stream_missing_tag.go deleted file mode 100644 index a0d407f..0000000 --- a/tests/stream_missing_tag.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - file := f.Buf.Bytes() - f.Buf.Reset() - f.Buf.Write(file[:len(file)-16]) - f.ExpectPayloadFailure() - f.Generate() -} diff --git a/tests/stream_no_chunks.go b/tests/stream_no_chunks.go deleted file mode 100644 index c0114a3..0000000 --- a/tests/stream_no_chunks.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Nonce(f.Rand(16)) - f.ExpectPayloadFailure() - f.Generate() -} diff --git a/tests/stream_no_final.go b/tests/stream_no_final.go deleted file mode 100644 index da820de..0000000 --- a/tests/stream_no_final.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Nonce(f.Rand(16)) - f.PayloadChunk([]byte("age")) - f.ExpectPayloadFailure() - f.Generate() -} diff --git a/tests/stream_no_final_full.go b/tests/stream_no_final_full.go deleted file mode 100644 index 374a96e..0000000 --- a/tests/stream_no_final_full.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunk(testkit.LargeTestFirstChunk) - f.ExpectPartialPayload(64 * 1024) - f.Generate() -} diff --git a/tests/stream_no_final_two_chunks.go b/tests/stream_no_final_two_chunks.go deleted file mode 100644 index 8b47572..0000000 --- a/tests/stream_no_final_two_chunks.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunk(testkit.LargeTestFirstChunk) - f.PayloadChunk([]byte("age")) - f.ExpectPartialPayload(64 * 1024) - f.Generate() -} diff --git a/tests/stream_no_final_two_chunks_full.go b/tests/stream_no_final_two_chunks_full.go deleted file mode 100644 index 41c2f3c..0000000 --- a/tests/stream_no_final_two_chunks_full.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunk(testkit.LargeTestFirstChunk) - f.PayloadChunk(testkit.LargeTestSecondChunk) - f.ExpectPartialPayload(64 * 1024 * 2) - f.Generate() -} diff --git a/tests/stream_no_nonce.go b/tests/stream_no_nonce.go deleted file mode 100644 index 6fb3dd8..0000000 --- a/tests/stream_no_nonce.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - // Marked as header failure because we read the nonce while reading the - // header, before handing off to the STREAM implementation. - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/stream_short_chunk.go b/tests/stream_short_chunk.go deleted file mode 100644 index 27cb10d..0000000 --- a/tests/stream_short_chunk.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Nonce(f.Rand(16)) - f.Nonce(f.Rand(12)) // less than the length of a Poly1305 tag - f.ExpectPayloadFailure() - f.Generate() -} diff --git a/tests/stream_short_nonce.go b/tests/stream_short_nonce.go deleted file mode 100644 index 6ba67e4..0000000 --- a/tests/stream_short_nonce.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Nonce(f.Rand(12)) - // Marked as header failure because we read the nonce while reading the - // header, before handing off to the STREAM implementation. - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/stream_short_second_chunk.go b/tests/stream_short_second_chunk.go deleted file mode 100644 index 7e16b0e..0000000 --- a/tests/stream_short_second_chunk.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunk(testkit.LargeTestFirstChunk) - f.Nonce(f.Rand(12)) // less than the length of a Poly1305 tag - f.ExpectPartialPayload(64 * 1024) - f.Generate() -} diff --git a/tests/stream_three_chunks.go b/tests/stream_three_chunks.go deleted file mode 100644 index 82df78a..0000000 --- a/tests/stream_three_chunks.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunk(testkit.LargeTestFirstChunk) - f.PayloadChunk(testkit.LargeTestSecondChunk) - f.PayloadChunkFinal(testkit.LargeTestThirdChunk) - f.Generate() -} diff --git a/tests/stream_trailing_garbage_long.go b/tests/stream_trailing_garbage_long.go deleted file mode 100644 index fd4b2ed..0000000 --- a/tests/stream_trailing_garbage_long.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunkFinal(testkit.LargeTestFirstChunk) - f.Buf.Write(f.Rand(20)) - f.ExpectPartialPayload(64 * 1024) - f.Generate() -} diff --git a/tests/stream_trailing_garbage_short.go b/tests/stream_trailing_garbage_short.go deleted file mode 100644 index 3ac584e..0000000 --- a/tests/stream_trailing_garbage_short.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunkFinal(testkit.LargeTestFirstChunk) - f.Buf.Write(f.Rand(12)) - f.ExpectPartialPayload(64 * 1024) - f.Generate() -} diff --git a/tests/stream_two_chunks.go b/tests/stream_two_chunks.go deleted file mode 100644 index ceeec8a..0000000 --- a/tests/stream_two_chunks.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunk(testkit.LargeTestFirstChunk) - f.PayloadChunkFinal(testkit.LargeTestSecondChunk) - f.Generate() -} diff --git a/tests/stream_two_final_chunks.go b/tests/stream_two_final_chunks.go deleted file mode 100644 index 3059fb3..0000000 --- a/tests/stream_two_final_chunks.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey(testkit.LargeTestFileKey) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Nonce(testkit.LargeTestNonce) - f.PayloadChunkFinal(testkit.LargeTestFirstChunk) - f.PayloadChunkFinal([]byte("age")) - f.ExpectPartialPayload(64 * 1024) - f.Generate() -} diff --git a/tests/version_unsupported.go b/tests/version_unsupported.go deleted file mode 100644 index c9d477c..0000000 --- a/tests/version_unsupported.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1234") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Generate() -} diff --git a/tests/x25519.go b/tests/x25519.go deleted file mode 100644 index 52e1a90..0000000 --- a/tests/x25519.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - f.Generate() -} diff --git a/tests/x25519_bad_tag.go b/tests/x25519_bad_tag.go deleted file mode 100644 index c6eb7b5..0000000 --- a/tests/x25519_bad_tag.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "encoding/base64" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - body, _ := base64.RawStdEncoding.DecodeString(f.UnreadLine()) - body[len(body)-1] ^= 0xff - f.TextLine(base64.RawStdEncoding.EncodeToString(body)) - f.HMAC() - f.Payload("age") - f.ExpectNoMatch() - f.Comment("the ChaCha20Poly1305 authentication tag on the body of the X25519 stanza is wrong") - f.Generate() -} diff --git a/tests/x25519_extra_argument.go b/tests/x25519_extra_argument.go deleted file mode 100644 index 5febbdc..0000000 --- a/tests/x25519_extra_argument.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - body, args := f.UnreadLine(), f.UnreadLine() - f.TextLine(args + " 1234") - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("the base64 encoding of the share is not canonical") - f.Generate() -} diff --git a/tests/x25519_grease.go b/tests/x25519_grease.go deleted file mode 100644 index 8c95722..0000000 --- a/tests/x25519_grease.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.ArgsLine("grease") - f.Body(nil) - f.X25519(testkit.TestX25519Recipient) - f.ArgsLine("grease") - f.Body(nil) - f.HMAC() - f.Payload("age") - f.Generate() -} diff --git a/tests/x25519_identity.go b/tests/x25519_identity.go deleted file mode 100644 index b7bc11c..0000000 --- a/tests/x25519_identity.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519RecordIdentity(testkit.TestX25519Identity) - share := make([]byte, 32) - f.X25519Stanza(share, testkit.TestX25519Identity) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("the X25519 share is a low-order point, so the shared secret is the disallowed all-zero value") - f.Generate() -} diff --git a/tests/x25519_long_file_key.go b/tests/x25519_long_file_key.go deleted file mode 100644 index dd648fe..0000000 --- a/tests/x25519_long_file_key.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.FileKey([]byte("A LONGER YELLOW SUBMARINE")) - f.VersionLine("v1") - f.X25519(testkit.TestX25519Identity) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("the file key must be checked to be 16 bytes before decrypting it") - f.Generate() -} diff --git a/tests/x25519_long_share.go b/tests/x25519_long_share.go deleted file mode 100644 index de9cea3..0000000 --- a/tests/x25519_long_share.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "encoding/base64" - - "filippo.io/age/internal/testkit" - "golang.org/x/crypto/curve25519" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - share, _ := curve25519.X25519(f.Rand(32), curve25519.Basepoint) - f.X25519RecordIdentity(testkit.TestX25519Identity) - f.X25519Stanza(share, testkit.TestX25519Identity) - body, _ := f.UnreadLine(), f.UnreadLine() - f.TextLine("-> X25519 " + base64.RawStdEncoding.EncodeToString(append(share, 0x00))) - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("a trailing zero is missing from the X25519 share") - f.Generate() -} diff --git a/tests/x25519_low_order.go b/tests/x25519_low_order.go deleted file mode 100644 index e45c5bd..0000000 --- a/tests/x25519_low_order.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519RecordIdentity(testkit.TestX25519Identity) - // Point of order 8 on Curve25519, chosen to be the least likely to be - // flagged by hardcoded list exclusions. - share := []byte{0x5f, 0x9c, 0x95, 0xbc, 0xa3, 0x50, 0x8c, 0x24, 0xb1, 0xd0, - 0xb1, 0x55, 0x9c, 0x83, 0xef, 0x5b, 0x04, 0x44, 0x5c, 0xc4, 0x58, 0x1c, - 0x8e, 0x86, 0xd8, 0x22, 0x4e, 0xdd, 0xd0, 0x9f, 0x11, 0xd7} - f.X25519Stanza(share, testkit.TestX25519Identity) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("the X25519 share is a low-order point, so the shared secret" + - "is the disallowed all-zero value") - f.Generate() -} diff --git a/tests/x25519_lowercase.go b/tests/x25519_lowercase.go deleted file mode 100644 index cdb8384..0000000 --- a/tests/x25519_lowercase.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - body, args := f.UnreadLine(), f.UnreadArgsLine() - f.ArgsLine("x25519", args[1]) - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectNoMatch() - f.Comment("the first argument in the X25519 stanza is lowercase") - f.Generate() -} diff --git a/tests/x25519_multiple_recipients.go b/tests/x25519_multiple_recipients.go deleted file mode 100644 index 993fa55..0000000 --- a/tests/x25519_multiple_recipients.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519NoRecordIdentity(f.Rand(32)) - f.X25519(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - f.Generate() -} diff --git a/tests/x25519_no_match.go b/tests/x25519_no_match.go deleted file mode 100644 index 5f3b4db..0000000 --- a/tests/x25519_no_match.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - identity := f.Rand(32) - f.X25519RecordIdentity(identity) - f.X25519NoRecordIdentity(testkit.TestX25519Recipient) - f.HMAC() - f.Payload("age") - f.ExpectNoMatch() - f.Generate() -} diff --git a/tests/x25519_not_canonical_body.go b/tests/x25519_not_canonical_body.go deleted file mode 100644 index 6b22626..0000000 --- a/tests/x25519_not_canonical_body.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - body := f.UnreadLine() - f.TextLine(testkit.NotCanonicalBase64(body)) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("the base64 encoding of the share is not canonical") - f.Generate() -} diff --git a/tests/x25519_not_canonical_share.go b/tests/x25519_not_canonical_share.go deleted file mode 100644 index d31b3ff..0000000 --- a/tests/x25519_not_canonical_share.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import "filippo.io/age/internal/testkit" - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - f.X25519(testkit.TestX25519Recipient) - body, args := f.UnreadLine(), f.UnreadLine() - f.TextLine(testkit.NotCanonicalBase64(args)) - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("the base64 encoding of the share is not canonical") - f.Generate() -} diff --git a/tests/x25519_short_share.go b/tests/x25519_short_share.go deleted file mode 100644 index 01ea193..0000000 --- a/tests/x25519_short_share.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2022 The age Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore -// +build ignore - -package main - -import ( - "encoding/base64" - "encoding/hex" - - "filippo.io/age/internal/testkit" -) - -func main() { - f := testkit.NewTestFile() - f.VersionLine("v1") - share, _ := hex.DecodeString("97ba38a135fd5f9137fca3836bfec24340ab03d7ca316b26f482636334a52600") - f.X25519RecordIdentity(testkit.TestX25519Identity) - f.X25519Stanza(share, testkit.TestX25519Identity) - body, _ := f.UnreadLine(), f.UnreadLine() - f.TextLine("-> X25519 " + base64.RawStdEncoding.EncodeToString(share[:31])) - f.TextLine(body) - f.HMAC() - f.Payload("age") - f.ExpectHeaderFailure() - f.Comment("a trailing zero is missing from the X25519 share") - f.Generate() -}