Skip to content

Commit 20fc256

Browse files
committed
fix:add binary interface
1 parent 0e4a51c commit 20fc256

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

cng/hash.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package cng
99
import (
1010
"bytes"
1111
"crypto"
12+
"errors"
1213
"hash"
1314
"runtime"
1415
"unsafe"
@@ -250,6 +251,18 @@ func (h *hashX) BlockSize() int {
250251
return int(h.alg.blockSize)
251252
}
252253

254+
func (hx *hashX) MarshalBinary() ([]byte, error) {
255+
return nil, errors.New("cng: hash state is not marshallable")
256+
}
257+
258+
func (hx *hashX) AppendBinary(b []byte) ([]byte, error) {
259+
return nil, errors.New("cng: hash state is not marshallable")
260+
}
261+
262+
func (hx *hashX) UnmarshalBinary(data []byte) error {
263+
return errors.New("cng: hash state is not marshallable")
264+
}
265+
253266
// hashData writes p to ctx. It panics on error.
254267
func hashData(ctx bcrypt.HASH_HANDLE, p []byte) {
255268
var n int

cng/sha3.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package cng
88

99
import (
10+
"errors"
1011
"hash"
1112
"runtime"
1213
"unsafe"
@@ -164,6 +165,18 @@ func (h *DigestSHA3) BlockSize() int {
164165
return int(h.alg.blockSize)
165166
}
166167

168+
func (ds *DigestSHA3) MarshalBinary() ([]byte, error) {
169+
return nil, errors.New("cng: hash state is not marshallable")
170+
}
171+
172+
func (ds *DigestSHA3) AppendBinary(b []byte) ([]byte, error) {
173+
return nil, errors.New("cng: hash state is not marshallable")
174+
}
175+
176+
func (ds *DigestSHA3) UnmarshalBinary(data []byte) error {
177+
return errors.New("cng: hash state is not marshallable")
178+
}
179+
167180
// NewSHA3_256 returns a new SHA256 hash.
168181
func NewSHA3_256() *DigestSHA3 {
169182
return newDigestSHA3(bcrypt.SHA3_256_ALGORITHM)
@@ -284,3 +297,15 @@ func (s *SHAKE) Reset() {
284297
func (s *SHAKE) BlockSize() int {
285298
return int(s.blockSize)
286299
}
300+
301+
func (s *SHAKE) MarshalBinary() ([]byte, error) {
302+
return nil, errors.New("cng: hash state is not marshallable")
303+
}
304+
305+
func (s *SHAKE) AppendBinary(b []byte) ([]byte, error) {
306+
return nil, errors.New("cng: hash state is not marshallable")
307+
}
308+
309+
func (s *SHAKE) UnmarshalBinary(data []byte) error {
310+
return errors.New("cng: hash state is not marshallable")
311+
}

0 commit comments

Comments
 (0)