diff options
Diffstat (limited to '')
-rw-r--r-- | tests/benchmarks/hash/scrypt.go | 6 | ||||
-rw-r--r-- | tests/functional/hash-and-check/scrypt.go | 32 | ||||
-rw-r--r-- | tests/fuzz/api/scrypt.go | 6 | ||||
-rw-r--r-- | tests/scrypt.go | 22 |
4 files changed, 53 insertions, 13 deletions
diff --git a/tests/benchmarks/hash/scrypt.go b/tests/benchmarks/hash/scrypt.go index 82f9ed5..54657d0 100644 --- a/tests/benchmarks/hash/scrypt.go +++ b/tests/benchmarks/hash/scrypt.go @@ -18,9 +18,13 @@ func MainTest() { password := []byte("password") salt := []byte("salt0123456789abcdef0123456789abcdef") + input := HashInput{ + Password: password, + Salt: salt, + } for i := 0; i < n; i++ { - _, err := Hash(password, salt) + _, err := Hash(input) if err != nil { panic(err) } diff --git a/tests/functional/hash-and-check/scrypt.go b/tests/functional/hash-and-check/scrypt.go index 17f2982..065b9b5 100644 --- a/tests/functional/hash-and-check/scrypt.go +++ b/tests/functional/hash-and-check/scrypt.go @@ -9,15 +9,24 @@ import ( func MainTest() { g.Testing("from a known input we check the hash", func() { - const ( - password = "a fixed password" - salt = "a fixed salt____________________" + var ( + password = []byte("a fixed password") + salt = []byte("a fixed salt____________________") ) - hash, err := Hash([]byte(password), []byte(salt)) + hashInput := HashInput{ + Password: password, + Salt: salt, + } + hash, err := Hash(hashInput) g.TErrorIf(err) - ok, err := Check([]byte(password), []byte(salt), hash) + checkInput := CheckInput{ + Password: password, + Salt: salt, + Hash: hash, + } + ok, err := Check(checkInput) g.TErrorIf(err) g.TAssertEqual(ok, true) }) @@ -29,10 +38,19 @@ func MainTest() { salt, err := Salt() g.TErrorIf(err) - hash, err := Hash(password, salt) + hashInput := HashInput{ + Password: password, + Salt: salt, + } + hash, err := Hash(hashInput) g.TErrorIf(err) - ok, err := Check(password, salt, hash) + checkInput := CheckInput{ + Password: password, + Salt: salt, + Hash: hash, + } + ok, err := Check(checkInput) g.TErrorIf(err) g.TAssertEqual(ok, true) diff --git a/tests/fuzz/api/scrypt.go b/tests/fuzz/api/scrypt.go index 8e785a5..c037add 100644 --- a/tests/fuzz/api/scrypt.go +++ b/tests/fuzz/api/scrypt.go @@ -14,7 +14,11 @@ func api(f *testing.F) { return } - _, err := Hash(password, salt) + input := HashInput{ + Password: password, + Salt: salt, + } + _, err := Hash(input) if err != nil { t.Errorf("Failed on: %#v\n", err) } diff --git a/tests/scrypt.go b/tests/scrypt.go index f499f84..710ea82 100644 --- a/tests/scrypt.go +++ b/tests/scrypt.go @@ -217,10 +217,15 @@ func test_Hash() { salt, err := Salt() g.TErrorIf(err) - hash1, err := Hash(password, salt) + input := HashInput{ + Password: password, + Salt: salt, + } + + hash1, err := Hash(input) g.TErrorIf(err) - hash2, err := Hash(password, salt) + hash2, err := Hash(input) g.TErrorIf(err) g.TAssertEqual(hash1, hash2) @@ -231,13 +236,22 @@ func test_Check() { g.TestStart("Check()") h := func(password []byte, salt []byte) []byte { - hash, err := Hash(password, salt) + input := HashInput{ + Password: password, + Salt: salt, + } + hash, err := Hash(input) g.TErrorIf(err) return hash } chk := func(password []byte, salt []byte, hash []byte) bool { - ok, err := Check(password, salt, hash) + input := CheckInput{ + Password: password, + Salt: salt, + Hash: hash, + } + ok, err := Check(input) g.TErrorIf(err) return ok } |