X-Git-Url: http://www.git.cypherpunks.ru/?p=balloon.git;a=blobdiff_plain;f=balloon_test.go;h=a881578ff957e9705d88a5b8890247d258fb03d6;hp=87449272df6484571b4aa4798a0f7134cc306764;hb=6542cd28c0f00e04d8e47d7648fe1305aae0fc77;hpb=2be074075c635f95406490655039988c8e3633d8 diff --git a/balloon_test.go b/balloon_test.go index 8744927..a881578 100644 --- a/balloon_test.go +++ b/balloon_test.go @@ -1,26 +1,26 @@ /* balloon -- Balloon password hashing function -Copyright (C) 2016-2017 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 General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +it under the terms of the GNU Lesser General Public License as +the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +GNU Lesser General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . +You should have received a copy of the GNU Lesser General Public +License along with this program. If not, see +. */ package balloon import ( "crypto/rand" - "crypto/sha256" + "crypto/sha512" "testing" "testing/quick" ) @@ -30,7 +30,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 { @@ -43,7 +43,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 { @@ -56,9 +56,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) } } @@ -67,8 +69,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) } }