Documentation ¶
Overview ¶
Package polyval implements POLYVAL per RFC 8452.
The universal hash function POLYVAL is the byte-wise reverse of GHASH.
Index ¶
- Constants
- func Sum(key, data []byte) [Size]byte
- type Polyval
- func (p *Polyval) BlockSize() int
- func (p *Polyval) Init(key []byte) error
- func (p *Polyval) MarshalBinary() ([]byte, error)
- func (p *Polyval) Reset()
- func (p *Polyval) Size() int
- func (p *Polyval) Sum(b []byte) []byte
- func (p *Polyval) UnmarshalBinary(data []byte) error
- func (p *Polyval) Update(blocks []byte)
Constants ¶
const (
// Size is the size in bytes of a POLYVAL checksum.
Size = 16
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Polyval ¶
type Polyval struct {
// contains filtered or unexported fields
}
Polyval is an implementation of POLYVAL.
It operates similar to the standard library's Hash interface, but only accepts full blocks. Callers should pad the input accordingly.
POLYVAL is similar to GHASH. It operates in GF(2^128) defined by the irreducible polynomial
x^128 + x^127 + x^126 + x^121 + 1.
The field has characteristic 2, so addition is performed with XOR. Multiplication is polynomial multiplication reduced modulo the polynomial.
For more information on POLYVAL, see [rfc8452].
func (*Polyval) Init ¶
Init initializes a Polyval.
The key must be exactly 16 bytes long and cannot be all zero.
func (*Polyval) MarshalBinary ¶
MarshalBinary implements BinaryMarshaler.
It does not return an error.
func (*Polyval) Sum ¶
Sum appends the current hash to b and returns the resulting slice.
It does not change the underlying hash state.
func (*Polyval) UnmarshalBinary ¶
Unmarshalbinary implements BinaryUnmarshaler.
data must be exactly 160 bytes.