@@ -115,14 +115,14 @@ var isMarshallableMap sync.Map
115
115
116
116
// isHashMarshallable returns true if the memory layout of cb
117
117
// is known by this library and can therefore be marshalled.
118
- func isHashMarshallable (cb crypto.Hash ) bool {
118
+ func isHashMarshallable (ch crypto.Hash ) bool {
119
119
if vMajor == 1 {
120
120
return true
121
121
}
122
- if v , ok := isMarshallableMap .Load (cb ); ok {
122
+ if v , ok := isMarshallableMap .Load (ch ); ok {
123
123
return v .(bool )
124
124
}
125
- md := cryptoHashToMD (cb )
125
+ md := cryptoHashToMD (ch )
126
126
if md == nil {
127
127
return false
128
128
}
@@ -138,7 +138,7 @@ func isHashMarshallable(cb crypto.Hash) bool {
138
138
// We only know the memory layout of the built-in providers.
139
139
// See evpHash.hashState for more details.
140
140
marshallable := name == "default" || name == "fips"
141
- isMarshallableMap .Store (cb , marshallable )
141
+ isMarshallableMap .Store (ch , marshallable )
142
142
return marshallable
143
143
}
144
144
@@ -276,11 +276,11 @@ func (h *md4Hash) Sum(in []byte) []byte {
276
276
277
277
// NewMD5 returns a new MD5 hash.
278
278
func NewMD5 () hash.Hash {
279
- h := newEvpHash (crypto .MD5 , 16 , 64 )
279
+ h := md5Hash { evpHash : newEvpHash (crypto .MD5 , 16 , 64 )}
280
280
if isHashMarshallable (crypto .MD5 ) {
281
- return & md5Marshal {md5Hash { evpHash : h } }
281
+ return & md5Marshal {h }
282
282
}
283
- return & md5Hash { evpHash : h }
283
+ return & h
284
284
}
285
285
286
286
// md5State layout is taken from
@@ -354,11 +354,11 @@ func (h *md5Marshal) UnmarshalBinary(b []byte) error {
354
354
355
355
// NewSHA1 returns a new SHA1 hash.
356
356
func NewSHA1 () hash.Hash {
357
- h := newEvpHash (crypto .SHA1 , 20 , 64 )
357
+ h := sha1Hash { evpHash : newEvpHash (crypto .SHA1 , 20 , 64 )}
358
358
if isHashMarshallable (crypto .SHA1 ) {
359
- return & sha1Marshal {sha1Hash { evpHash : h } }
359
+ return & sha1Marshal {h }
360
360
}
361
- return & sha1Hash { evpHash : h }
361
+ return & h
362
362
}
363
363
364
364
type sha1Hash struct {
@@ -434,11 +434,11 @@ func (h *sha1Marshal) UnmarshalBinary(b []byte) error {
434
434
435
435
// NewSHA224 returns a new SHA224 hash.
436
436
func NewSHA224 () hash.Hash {
437
- h := newEvpHash (crypto .SHA224 , 224 / 8 , 64 )
437
+ h := sha224Hash { evpHash : newEvpHash (crypto .SHA224 , 224 / 8 , 64 )}
438
438
if isHashMarshallable (crypto .SHA224 ) {
439
- return & sha224Marshal {sha224Hash { evpHash : h } }
439
+ return & sha224Marshal {h }
440
440
}
441
- return & sha224Hash { evpHash : h }
441
+ return & h
442
442
}
443
443
444
444
type sha224Hash struct {
@@ -453,11 +453,11 @@ func (h *sha224Hash) Sum(in []byte) []byte {
453
453
454
454
// NewSHA256 returns a new SHA256 hash.
455
455
func NewSHA256 () hash.Hash {
456
- h := newEvpHash (crypto .SHA256 , 256 / 8 , 64 )
456
+ h := sha256Hash { evpHash : newEvpHash (crypto .SHA256 , 256 / 8 , 64 )}
457
457
if isHashMarshallable (crypto .SHA256 ) {
458
- return & sha256Marshal {sha256Hash { evpHash : h } }
458
+ return & sha256Marshal {h }
459
459
}
460
- return & sha256Hash { evpHash : h }
460
+ return & h
461
461
}
462
462
463
463
type sha256Hash struct {
@@ -593,11 +593,11 @@ func (h *sha256Marshal) UnmarshalBinary(b []byte) error {
593
593
594
594
// NewSHA384 returns a new SHA384 hash.
595
595
func NewSHA384 () hash.Hash {
596
- h := newEvpHash (crypto .SHA384 , 384 / 8 , 128 )
596
+ h := sha384Hash { evpHash : newEvpHash (crypto .SHA384 , 384 / 8 , 128 )}
597
597
if isHashMarshallable (crypto .SHA384 ) {
598
- return & sha384Marshal {sha384Hash { evpHash : h } }
598
+ return & sha384Marshal {h }
599
599
}
600
- return & sha384Hash { evpHash : h }
600
+ return & h
601
601
}
602
602
603
603
type sha384Hash struct {
@@ -612,11 +612,11 @@ func (h *sha384Hash) Sum(in []byte) []byte {
612
612
613
613
// NewSHA512 returns a new SHA512 hash.
614
614
func NewSHA512 () hash.Hash {
615
- h := newEvpHash (crypto .SHA512 , 512 / 8 , 128 )
615
+ h := sha512Hash { evpHash : newEvpHash (crypto .SHA512 , 512 / 8 , 128 )}
616
616
if isHashMarshallable (crypto .SHA512 ) {
617
- return & sha512Marshal {sha512Hash { evpHash : h } }
617
+ return & sha512Marshal {h }
618
618
}
619
- return & sha512Hash { evpHash : h }
619
+ return & h
620
620
}
621
621
622
622
type sha512Hash struct {
0 commit comments