diff --git a/cng/hash.go b/cng/hash.go index a674496..b97e638 100644 --- a/cng/hash.go +++ b/cng/hash.go @@ -9,6 +9,7 @@ package cng import ( "bytes" "crypto" + "errors" "hash" "runtime" "unsafe" @@ -250,6 +251,18 @@ func (h *hashX) BlockSize() int { return int(h.alg.blockSize) } +func (hx *hashX) MarshalBinary() ([]byte, error) { + return nil, errors.New("cng: hash state is not marshallable") +} + +func (hx *hashX) AppendBinary(b []byte) ([]byte, error) { + return nil, errors.New("cng: hash state is not marshallable") +} + +func (hx *hashX) UnmarshalBinary(data []byte) error { + return errors.New("cng: hash state is not marshallable") +} + // hashData writes p to ctx. It panics on error. func hashData(ctx bcrypt.HASH_HANDLE, p []byte) { var n int diff --git a/cng/sha3.go b/cng/sha3.go index 4d7a31a..15c1345 100644 --- a/cng/sha3.go +++ b/cng/sha3.go @@ -7,6 +7,7 @@ package cng import ( + "errors" "hash" "runtime" "unsafe" @@ -164,6 +165,18 @@ func (h *DigestSHA3) BlockSize() int { return int(h.alg.blockSize) } +func (ds *DigestSHA3) MarshalBinary() ([]byte, error) { + return nil, errors.New("cng: hash state is not marshallable") +} + +func (ds *DigestSHA3) AppendBinary(b []byte) ([]byte, error) { + return nil, errors.New("cng: hash state is not marshallable") +} + +func (ds *DigestSHA3) UnmarshalBinary(data []byte) error { + return errors.New("cng: hash state is not marshallable") +} + // NewSHA3_256 returns a new SHA256 hash. func NewSHA3_256() *DigestSHA3 { return newDigestSHA3(bcrypt.SHA3_256_ALGORITHM) @@ -284,3 +297,15 @@ func (s *SHAKE) Reset() { func (s *SHAKE) BlockSize() int { return int(s.blockSize) } + +func (s *SHAKE) MarshalBinary() ([]byte, error) { + return nil, errors.New("cng: hash state is not marshallable") +} + +func (s *SHAKE) AppendBinary(b []byte) ([]byte, error) { + return nil, errors.New("cng: hash state is not marshallable") +} + +func (s *SHAKE) UnmarshalBinary(data []byte) error { + return errors.New("cng: hash state is not marshallable") +}