mirror of https://github.com/golang/go.git
hash: add XOF interface
For #69518 Change-Id: I68c7057c776522514eed37cf4dc0cfddec034d3a Reviewed-on: https://go-review.googlesource.com/c/go/+/644235 Reviewed-by: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org>
This commit is contained in:
parent
eb4069127a
commit
9112511725
|
|
@ -0,0 +1,5 @@
|
||||||
|
pkg hash, type XOF interface { BlockSize, Read, Reset, Write } #69518
|
||||||
|
pkg hash, type XOF interface, BlockSize() int #69518
|
||||||
|
pkg hash, type XOF interface, Read([]uint8) (int, error) #69518
|
||||||
|
pkg hash, type XOF interface, Reset() #69518
|
||||||
|
pkg hash, type XOF interface, Write([]uint8) (int, error) #69518
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
The new [XOF](/pkg/hash#XOF) interface can be implemented by "extendable output
|
||||||
|
functions", which are hash functions with arbitrary or unlimited output length
|
||||||
|
such as [BLAKE2Xb](https://pkg.go.dev/golang.org/x/crypto/blake2b).
|
||||||
|
|
@ -56,3 +56,23 @@ type Hash64 interface {
|
||||||
Hash
|
Hash
|
||||||
Sum64() uint64
|
Sum64() uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XOF (extendable output function) is a hash function with arbitrary or unlimited output length.
|
||||||
|
type XOF interface {
|
||||||
|
// Write absorbs more data into the XOF's state. It panics if called
|
||||||
|
// after Read.
|
||||||
|
io.Writer
|
||||||
|
|
||||||
|
// Read reads more output from the XOF. It may return io.EOF if there
|
||||||
|
// is a limit to the XOF output length.
|
||||||
|
io.Reader
|
||||||
|
|
||||||
|
// Reset resets the XOF to its initial state.
|
||||||
|
Reset()
|
||||||
|
|
||||||
|
// BlockSize returns the XOF's underlying block size.
|
||||||
|
// The Write method must be able to accept any amount
|
||||||
|
// of data, but it may operate more efficiently if all writes
|
||||||
|
// are a multiple of the block size.
|
||||||
|
BlockSize() int
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue