Use low-security scrypt KDF parameters for testing
This commit is contained in:
parent
8e24c51233
commit
a3492d69dd
3 changed files with 21 additions and 1 deletions
|
@ -40,6 +40,8 @@ func parseIDsFromReader(t testing.TB, rd io.Reader) backend.IDs {
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdInit(t testing.TB, global GlobalOptions) {
|
func cmdInit(t testing.TB, global GlobalOptions) {
|
||||||
|
repository.TestUseLowSecurityKDFParameters(t)
|
||||||
|
|
||||||
cmd := &CmdInit{global: &global}
|
cmd := &CmdInit{global: &global}
|
||||||
OK(t, cmd.Execute(nil))
|
OK(t, cmd.Execute(nil))
|
||||||
|
|
||||||
|
|
|
@ -239,6 +239,8 @@ func induceError(data []byte) {
|
||||||
func TestCheckerModifiedData(t *testing.T) {
|
func TestCheckerModifiedData(t *testing.T) {
|
||||||
be := mem.New()
|
be := mem.New()
|
||||||
|
|
||||||
|
repository.TestUseLowSecurityKDFParameters(t)
|
||||||
|
|
||||||
repo := repository.New(be)
|
repo := repository.New(be)
|
||||||
OK(t, repo.Init(TestPassword))
|
OK(t, repo.Init(TestPassword))
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,25 @@ import (
|
||||||
"restic/backend"
|
"restic/backend"
|
||||||
"restic/backend/local"
|
"restic/backend/local"
|
||||||
"restic/backend/mem"
|
"restic/backend/mem"
|
||||||
|
"restic/crypto"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/chunker"
|
"github.com/restic/chunker"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// testKDFParams are the parameters for the KDF to be used during testing.
|
||||||
|
var testKDFParams = crypto.KDFParams{
|
||||||
|
N: 128,
|
||||||
|
R: 1,
|
||||||
|
P: 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestUseLowSecurityKDFParameters configures low-security KDF parameters for testing.
|
||||||
|
func TestUseLowSecurityKDFParameters(t testing.TB) {
|
||||||
|
t.Logf("using low-security KDF parameters for test")
|
||||||
|
KDFParams = &testKDFParams
|
||||||
|
}
|
||||||
|
|
||||||
// TestBackend returns a fully configured in-memory backend.
|
// TestBackend returns a fully configured in-memory backend.
|
||||||
func TestBackend(t testing.TB) (be backend.Backend, cleanup func()) {
|
func TestBackend(t testing.TB) (be backend.Backend, cleanup func()) {
|
||||||
return mem.New(), func() {}
|
return mem.New(), func() {}
|
||||||
|
@ -22,8 +36,10 @@ const testChunkerPol = chunker.Pol(0x3DA3358B4DC173)
|
||||||
|
|
||||||
// TestRepositoryWithBackend returns a repository initialized with a test
|
// TestRepositoryWithBackend returns a repository initialized with a test
|
||||||
// password. If be is nil, an in-memory backend is used. A constant polynomial
|
// password. If be is nil, an in-memory backend is used. A constant polynomial
|
||||||
// is used for the chunker.
|
// is used for the chunker and low-security test parameters.
|
||||||
func TestRepositoryWithBackend(t testing.TB, be backend.Backend) (r *Repository, cleanup func()) {
|
func TestRepositoryWithBackend(t testing.TB, be backend.Backend) (r *Repository, cleanup func()) {
|
||||||
|
TestUseLowSecurityKDFParameters(t)
|
||||||
|
|
||||||
var beCleanup func()
|
var beCleanup func()
|
||||||
if be == nil {
|
if be == nil {
|
||||||
be, beCleanup = TestBackend(t)
|
be, beCleanup = TestBackend(t)
|
||||||
|
|
Loading…
Reference in a new issue