X-Git-Url: http://www.git.cypherpunks.ru/?p=balloon.git;a=blobdiff_plain;f=balloon_test.go;h=5b0da2c48fcd7e5ce3a87ee68f2ef184ac2ae9c4;hp=68c108f4ac4b26c53df8d8a0a0fd2afe35c39c6b;hb=9a1a4ae452c536a3523b31269697c85479465b87;hpb=92c161713a13cc78403468c09f1557eb7c4a3a4a diff --git a/balloon_test.go b/balloon_test.go index 68c108f..5b0da2c 100644 --- a/balloon_test.go +++ b/balloon_test.go @@ -1,6 +1,6 @@ /* balloon -- Balloon password hashing function -Copyright (C) 2016-2018 Sergey Matveev +Copyright (C) 2016-2019 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -21,7 +21,7 @@ package balloon import ( "crypto/rand" - "crypto/sha256" + "crypto/sha512" "testing" "testing/quick" ) @@ -31,7 +31,7 @@ func TestB(t *testing.T) { if len(passwd) == 0 || len(salt) == 0 { return true } - B(sha256.New(), passwd, salt, int(s)%16+1, int(t)%16+1) + B(sha512.New(), passwd, salt, uint64(s)%16+1, uint64(t)%16+1) return true } if err := quick.Check(f, nil); err != nil { @@ -44,7 +44,7 @@ func TestH(t *testing.T) { if len(passwd) == 0 || len(salt) == 0 { return true } - H(sha256.New, passwd, salt, int(s)%16+1, int(t)%16+1, int(p)%8+1) + H(sha512.New, passwd, salt, int(s)%16+1, int(t)%16+1, int(p)%8+1) return true } if err := quick.Check(f, nil); err != nil { @@ -57,9 +57,11 @@ func BenchmarkB(b *testing.B) { rand.Read(passwd) salt := make([]byte, 8) rand.Read(salt) + h := sha512.New() + sCost := uint64(1 << 10 / h.Size()) b.ResetTimer() for i := 0; i < b.N; i++ { - B(sha256.New(), passwd, salt, 1<<10/sha256.New().Size(), 4) + B(h, passwd, salt, sCost, 4) } } @@ -68,8 +70,9 @@ func BenchmarkH(b *testing.B) { rand.Read(passwd) salt := make([]byte, 8) rand.Read(salt) + sCost := 1 << 10 / sha512.New().Size() b.ResetTimer() for i := 0; i < b.N; i++ { - H(sha256.New, passwd, salt, 1<<10/sha256.New().Size(), 4, 4) + H(sha512.New, passwd, salt, sCost, 4, 4) } }