-
Notifications
You must be signed in to change notification settings - Fork 4
/
benchmarks_test.go
81 lines (73 loc) · 2.8 KB
/
benchmarks_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package passhash_test
import (
"testing"
)
import (
"github.com/dhui/passhash"
)
func BenchmarkDefaultWorkFactorPbkdfSha256(b *testing.B) {
kdf := passhash.Pbkdf2Sha256
config := passhash.Config{Kdf: kdf, WorkFactor: passhash.DefaultWorkFactor[kdf],
SaltSize: 16, KeyLength: 32, AuditLogger: &passhash.DummyAuditLogger{},
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
}
userID := passhash.UserID(0)
for i := 0; i < b.N; i++ {
config.NewCredential(userID, testPassword) // nolint: errcheck
}
}
func BenchmarkDefaultWorkFactorPbkdfSha512(b *testing.B) {
kdf := passhash.Pbkdf2Sha512
config := passhash.Config{Kdf: kdf, WorkFactor: passhash.DefaultWorkFactor[kdf],
SaltSize: 16, KeyLength: 32, AuditLogger: &passhash.DummyAuditLogger{},
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
}
userID := passhash.UserID(0)
for i := 0; i < b.N; i++ {
config.NewCredential(userID, testPassword) // nolint: errcheck
}
}
func BenchmarkDefaultWorkFactorPbkdfSha3_256(b *testing.B) {
kdf := passhash.Pbkdf2Sha3_256
config := passhash.Config{Kdf: kdf, WorkFactor: passhash.DefaultWorkFactor[kdf],
SaltSize: 16, KeyLength: 32, AuditLogger: &passhash.DummyAuditLogger{},
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
}
userID := passhash.UserID(0)
for i := 0; i < b.N; i++ {
config.NewCredential(userID, testPassword) // nolint: errcheck
}
}
func BenchmarkDefaultWorkFactorPbkdfSha3_512(b *testing.B) {
kdf := passhash.Pbkdf2Sha3_512
config := passhash.Config{Kdf: kdf, WorkFactor: passhash.DefaultWorkFactor[kdf],
SaltSize: 16, KeyLength: 32, AuditLogger: &passhash.DummyAuditLogger{},
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
}
userID := passhash.UserID(0)
for i := 0; i < b.N; i++ {
config.NewCredential(userID, testPassword) // nolint: errcheck
}
}
func BenchmarkDefaultWorkFactorBcrypt(b *testing.B) {
kdf := passhash.Bcrypt
config := passhash.Config{Kdf: kdf, WorkFactor: passhash.DefaultWorkFactor[kdf],
SaltSize: 16, KeyLength: 32, AuditLogger: &passhash.DummyAuditLogger{},
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
}
userID := passhash.UserID(0)
for i := 0; i < b.N; i++ {
config.NewCredential(userID, testPassword) // nolint: errcheck
}
}
func BenchmarkDefaultWorkFactorScrypt(b *testing.B) {
kdf := passhash.Scrypt
config := passhash.Config{Kdf: kdf, WorkFactor: passhash.DefaultWorkFactor[kdf],
SaltSize: 16, KeyLength: 32, AuditLogger: &passhash.DummyAuditLogger{},
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
}
userID := passhash.UserID(0)
for i := 0; i < b.N; i++ {
config.NewCredential(userID, testPassword) // nolint: errcheck
}
}