mirror of
https://github.com/FiloSottile/age.git
synced 2026-01-09 13:23:07 +00:00
tests: add scrypt tests and move Go files from testdata
This commit is contained in:
21
testdata/bad_hmac.go
vendored
21
testdata/bad_hmac.go
vendored
@@ -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
|
||||
|
||||
package main
|
||||
|
||||
import "filippo.io/age/internal/testkit"
|
||||
|
||||
func main() {
|
||||
f := testkit.NewTestFile()
|
||||
f.VersionLine("v1")
|
||||
f.X25519(testkit.TestX25519Identity)
|
||||
f.FileKey(f.Rand(16))
|
||||
f.HMAC()
|
||||
f.FileKey(testkit.TestFileKey)
|
||||
f.Payload("age")
|
||||
f.ExpectHeaderFailure()
|
||||
f.Generate()
|
||||
}
|
||||
21
testdata/long_file_key.go
vendored
21
testdata/long_file_key.go
vendored
@@ -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
|
||||
|
||||
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()
|
||||
}
|
||||
21
testdata/no_match.go
vendored
21
testdata/no_match.go
vendored
@@ -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
|
||||
|
||||
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.ExpectHeaderFailure()
|
||||
f.Generate()
|
||||
}
|
||||
20
testdata/stanza_empty_body.go
vendored
20
testdata/stanza_empty_body.go
vendored
@@ -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
|
||||
|
||||
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()
|
||||
}
|
||||
24
testdata/stanza_empty_last_line.go
vendored
24
testdata/stanza_empty_last_line.go
vendored
@@ -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
|
||||
|
||||
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))
|
||||
f.HMAC()
|
||||
f.Payload("age")
|
||||
f.Generate()
|
||||
}
|
||||
22
testdata/stanza_missing_body.go
vendored
22
testdata/stanza_missing_body.go
vendored
@@ -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
|
||||
|
||||
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()
|
||||
}
|
||||
26
testdata/stanza_missing_final_line.go
vendored
26
testdata/stanza_missing_final_line.go
vendored
@@ -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
|
||||
|
||||
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()
|
||||
}
|
||||
27
testdata/stanza_multiple_short_lines.go
vendored
27
testdata/stanza_multiple_short_lines.go
vendored
@@ -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
|
||||
|
||||
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()
|
||||
}
|
||||
18
testdata/stream_empty_payload.go
vendored
18
testdata/stream_empty_payload.go
vendored
@@ -1,18 +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
|
||||
|
||||
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()
|
||||
}
|
||||
32
testdata/stream_last_chunk_empty.go
vendored
32
testdata/stream_last_chunk_empty.go
vendored
@@ -1,32 +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
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
|
||||
"filippo.io/age/internal/testkit"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f := testkit.NewTestFile()
|
||||
// Reuse the file key and nonce from a previous test vector to avoid
|
||||
// bloating the git history with two versions that can't be compressed.
|
||||
fileKey, _ := hex.DecodeString("7aa5bdac0e6afeed3dd0a7eccb42af44")
|
||||
f.FileKey(fileKey)
|
||||
f.VersionLine("v1")
|
||||
f.X25519(testkit.TestX25519Identity)
|
||||
f.HMAC()
|
||||
nonce, _ := hex.DecodeString("c82f71eb82029b77136399e485e879f4")
|
||||
f.Nonce(nonce)
|
||||
f.PayloadChunk(bytes.Repeat([]byte{0}, 64*1024))
|
||||
f.PayloadChunkFinal([]byte{})
|
||||
f.Comment("final STREAM chunk can't be empty unless whole payload is empty")
|
||||
f.ExpectPayloadFailure()
|
||||
f.Generate()
|
||||
}
|
||||
29
testdata/stream_last_chunk_full.go
vendored
29
testdata/stream_last_chunk_full.go
vendored
@@ -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
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
|
||||
"filippo.io/age/internal/testkit"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f := testkit.NewTestFile()
|
||||
// Reuse the file key and nonce from a previous test vector to avoid
|
||||
// bloating the git history with two versions that can't be compressed.
|
||||
fileKey, _ := hex.DecodeString("5085919e0d59b19d6cbd00330f03861c")
|
||||
f.FileKey(fileKey)
|
||||
f.VersionLine("v1")
|
||||
f.X25519(testkit.TestX25519Identity)
|
||||
f.HMAC()
|
||||
nonce, _ := hex.DecodeString("32521791a6f22e11637fb69ead3f2d5f")
|
||||
f.Nonce(nonce)
|
||||
f.PayloadChunkFinal(bytes.Repeat([]byte{0}, 64*1024))
|
||||
f.Generate()
|
||||
}
|
||||
BIN
testdata/testkit/long_file_key_scrypt
vendored
Normal file
BIN
testdata/testkit/long_file_key_scrypt
vendored
Normal file
Binary file not shown.
BIN
testdata/testkit/scrypt
vendored
Normal file
BIN
testdata/testkit/scrypt
vendored
Normal file
Binary file not shown.
12
testdata/testkit/scrypt_and_x25519
vendored
Normal file
12
testdata/testkit/scrypt_and_x25519
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
expect: header failure
|
||||
file key: 59454c4c4f57205355424d4152494e45
|
||||
passphrase: password
|
||||
comment: scrypt stanzas must be alone in the header
|
||||
|
||||
age-encryption.org/v1
|
||||
-> X25519 TEiF0ypqr+bpvcqXNyCVJpL7OuwPdVwPL7KQEbFDOCc
|
||||
hjabGXwSLQ9c3S6Lw2i+S2Tu2fiwQHHslbBN6B41FLE
|
||||
-> scrypt 7s9ix86RtDMnTmjU8vkTTA 10
|
||||
0U4Pbxsl9pr9g4nHjPgkvtYkNrGiYJ43x1vbM5X5mhg
|
||||
--- f2AoyFXU2R5Cn7s38vH1pFkuKqzPh3ibwwHc/7y6RRU
|
||||
[æè.½Ó#ÈwÏ…=a×Yök×z©66Ú¦<01>âRùÛL
|
||||
BIN
testdata/testkit/scrypt_no_match
vendored
Normal file
BIN
testdata/testkit/scrypt_no_match
vendored
Normal file
Binary file not shown.
9
testdata/testkit/scrypt_work_factor_23
vendored
Normal file
9
testdata/testkit/scrypt_work_factor_23
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
expect: header failure
|
||||
file key: 59454c4c4f57205355424d4152494e45
|
||||
comment: work factor is very high, would take a long time to compute
|
||||
|
||||
age-encryption.org/v1
|
||||
-> scrypt rF0/NwblUHHTpgQgRpe5CQ 23
|
||||
qW9eVsT0NVb/Vswtw8kPIxUnaYmm9Px1dYmq2+4+qZA
|
||||
--- 38TpQMxQRRNMfmYYpBX6DDrPx4/QY5UmJnhPyVoX/cw
|
||||
¬]?7åPqÓ¦ F—¹ •Â÷õÛ®è
zŒ(rŠóÎ|
|
||||
Binary file not shown.
12
testdata/testkit/valid_characters
vendored
Normal file
12
testdata/testkit/valid_characters
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
expect: success
|
||||
payload: 013f54400c82da08037759ada907a8b864e97de81c088a182062c4b5622fd2ab
|
||||
file key: 59454c4c4f57205355424d4152494e45
|
||||
identity: AGE-SECRET-KEY-1XMWWC06LY3EE5RYTXM9MFLAZ2U56JJJ36S0MYPDRWSVLUL66MV4QX3S7F6
|
||||
|
||||
age-encryption.org/v1
|
||||
-> !"#$%&' ()*+,-./ 01234567 89:;<=>? @ABCDEFG HIJKLMNO PQRSTUVW XYZ[\]^_ `abcdefg hijklmno pqrstuvw xyz{|}~
|
||||
|
||||
-> X25519 TEiF0ypqr+bpvcqXNyCVJpL7OuwPdVwPL7KQEbFDOCc
|
||||
EmECAEcKN+n/Vs9SbWiV+Hu0r+E8R77DdWYyd83nw7U
|
||||
--- XdSsgCFKtyPBxU0ard+ElUYUfOp6XQtDhzDGFUCLbjo
|
||||
îÏbÇΑ´3'NhÔòùL·L[þ÷¾ªRÈð¼™,ƒ1ûf
|
||||
12
testdata/testkit/x25519_multiple_recipients
vendored
Normal file
12
testdata/testkit/x25519_multiple_recipients
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
expect: success
|
||||
payload: 013f54400c82da08037759ada907a8b864e97de81c088a182062c4b5622fd2ab
|
||||
file key: 59454c4c4f57205355424d4152494e45
|
||||
identity: AGE-SECRET-KEY-1XMWWC06LY3EE5RYTXM9MFLAZ2U56JJJ36S0MYPDRWSVLUL66MV4QX3S7F6
|
||||
|
||||
age-encryption.org/v1
|
||||
-> X25519 ajtqAvDEkVNr2B7zUOtq2mAQXDSBlNrVAuM/dKb5sT4
|
||||
0evrK/HQXVsQ4YaDe+659l5OQzvAzD2ytLGHQLQiqxg
|
||||
-> X25519 0qC7u6AbLxuwnM8tPFOWVtWZn/ZZe7z7gcsP5kgA0FI
|
||||
T/PZg76MmVt2IaLntrxppzDnzeFDYHsHFcnTnhbRLQ8
|
||||
--- 7W07ef2PhsTAl74pn+9vSj/Xzukwa6SuTqMc16cdBk0
|
||||
ð¸¾5TB9™ €„–Ko•Ãm³^OYØøž<òo-¥B
|
||||
18
testdata/x25519.go
vendored
18
testdata/x25519.go
vendored
@@ -1,18 +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
|
||||
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user