Skip to content

Commit

Permalink
fix AZL 3
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed Dec 20, 2024
1 parent 170f517 commit ff047fc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion evp.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func loadHash(ch crypto.Hash) *hashAlgorithm {
hash.md = md
}
}
hash.marshallable = isHashMarshallable(hash.md)
hash.marshallable = hash.magic != "" && isHashMarshallable(hash.md)
cacheMD.Store(ch, &hash)
return &hash
}
Expand Down
4 changes: 2 additions & 2 deletions hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func (d *evpHash) AppendBinary(buf []byte) ([]byte, error) {
case crypto.SHA512:
appender = (*sha512State)(state)
default:
return nil, errors.New("openssl: unsupported hash function: " + strconv.Itoa(int(d.alg.ch)))
panic("openssl: unsupported hash function: " + strconv.Itoa(int(d.alg.ch)))
}
buf = append(buf, d.alg.magic[:]...)
return appender.AppendBinary(buf)
Expand Down Expand Up @@ -422,7 +422,7 @@ func (d *evpHash) UnmarshalBinary(b []byte) error {
case crypto.SHA512:
unmarshaler = (*sha512State)(state)
default:
return errors.New("openssl: unsupported hash function: " + strconv.Itoa(int(d.alg.ch)))
panic("openssl: unsupported hash function: " + strconv.Itoa(int(d.alg.ch)))
}
return unmarshaler.UnmarshalBinary(b)
}
Expand Down
4 changes: 2 additions & 2 deletions hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestHash_BinaryMarshaler(t *testing.T) {

state, err := hashMarshaler.MarshalBinary()
if err != nil {
if strings.Contains(err.Error(), "unsupported hash function") {
if strings.Contains(err.Error(), "hash state is not marshallable") {
t.Skip("BinaryMarshaler not supported")
}
t.Fatalf("MarshalBinary failed: %v", err)
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestHash_BinaryAppender(t *testing.T) {
// Append binary data to the prebuilt slice
state, err := hashWithBinaryAppender.AppendBinary(prebuiltSlice)
if err != nil {
if strings.Contains(err.Error(), "unsupported hash function") {
if strings.Contains(err.Error(), "hash state is not marshallable") {
t.Skip("AppendBinary not supported")
}
t.Errorf("could not append binary: %v", err)
Expand Down

0 comments on commit ff047fc

Please sign in to comment.