Skip to content

Commit 23a5fa6

Browse files
committed
fix:add all supported hash
1 parent 4656435 commit 23a5fa6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
strategy:
66
fail-fast: false
77
matrix:
8-
go-version: [1.22.x, 1.23.x]
8+
go-version: [1.22.x, 1.23.x, 1.24.x]
99
venv: [windows-2019, windows-2022]
1010
fips: [1, 0]
1111
runs-on: ${{ matrix.venv }}

cng/hash_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ func TestHash_OneShot(t *testing.T) {
184184
func TestHashAllocations(t *testing.T) {
185185
msg := []byte("testing")
186186
n := int(testing.AllocsPerRun(10, func() {
187+
sink ^= cng.MD4(msg)[0]
188+
sink ^= cng.MD5(msg)[0]
187189
sink ^= cng.SHA1(msg)[0]
188190
sink ^= cng.SHA256(msg)[0]
189191
sink ^= cng.SHA384(msg)[0]
@@ -198,23 +200,31 @@ func TestHashAllocations(t *testing.T) {
198200
func TestHashStructAllocations(t *testing.T) {
199201
msg := []byte("testing")
200202

203+
md4Hash := cng.NewMD4()
204+
md5Hash := cng.NewMD5()
201205
sha1Hash := cng.NewSHA1()
202206
sha256Hash := cng.NewSHA256()
203207
sha384Hash := cng.NewSHA384()
204208
sha512Hash := cng.NewSHA512()
205209

206210
sum := make([]byte, sha512Hash.Size())
207211
n := int(testing.AllocsPerRun(10, func() {
212+
md4Hash.Write(msg)
213+
md5Hash.Write(msg)
208214
sha1Hash.Write(msg)
209215
sha256Hash.Write(msg)
210216
sha384Hash.Write(msg)
211217
sha512Hash.Write(msg)
212218

219+
md4Hash.Sum(sum[:0])
220+
md5Hash.Sum(sum[:0])
213221
sha1Hash.Sum(sum[:0])
214222
sha256Hash.Sum(sum[:0])
215223
sha384Hash.Sum(sum[:0])
216224
sha512Hash.Sum(sum[:0])
217225

226+
md4Hash.Reset()
227+
md5Hash.Reset()
218228
sha1Hash.Reset()
219229
sha256Hash.Reset()
220230
sha384Hash.Reset()

0 commit comments

Comments
 (0)