Documentation
¶
Index ¶
- Constants
- func KMAC128(key, customization, msg []byte, outLen int) []byte
- func KMAC256(key, customization, msg []byte, outLen int) []byte
- func NewKMAC128(key, customization []byte) stdhash.Hash
- func NewKMAC128WithSize(key, customization []byte, outLen int) stdhash.Hash
- func NewKMAC256(key, customization []byte) stdhash.Hash
- func NewKMAC256WithSize(key, customization []byte, outLen int) stdhash.Hash
- func Sum(key, data []byte) []byte
- func SumPoly1305(key, msg []byte) ([]byte, error)
- func Verify(key, data, mac []byte) bool
- func VerifyPoly1305(key, msg, tag []byte) (bool, error)
- type KMAC
- type Poly1305
Constants ¶
const ( // Poly1305KeySize is the size in bytes of the one-time key accepted by Poly1305. Poly1305KeySize = 32 // Poly1305TagSize is the size in bytes of the authenticator produced by Poly1305. Poly1305TagSize = internal.TagSize )
Variables ¶
This section is empty.
Functions ¶
func NewKMAC128 ¶
NewKMAC128 constructs a streaming KMAC128 instance producing a 32-byte MAC.
func NewKMAC128WithSize ¶
NewKMAC128WithSize constructs a streaming KMAC128 instance with a custom output length.
func NewKMAC256 ¶
NewKMAC256 constructs a streaming KMAC256 instance producing a 64-byte MAC.
func NewKMAC256WithSize ¶
NewKMAC256WithSize constructs a streaming KMAC256 instance with a custom output length.
func SumPoly1305 ¶
SumPoly1305 computes a Poly1305 authenticator over msg with the provided one-time key and returns the 16-byte tag. The key must be used only once.
func Verify ¶
Verify recomputes HMAC-SHA256 over data and compares it with mac in constant time. It returns true if and only if the MACs match.
func VerifyPoly1305 ¶
VerifyPoly1305 recomputes the Poly1305 authenticator for msg and compares it to tag using constant-time comparison.
Types ¶
type KMAC ¶
type KMAC struct {
// contains filtered or unexported fields
}
KMAC implements the SP 800-185 KMAC construction backed by cSHAKE.
func (*KMAC) Reset ¶
func (k *KMAC) Reset()
Reset restores the MAC to its initial state, ready to absorb a new message.
type Poly1305 ¶
type Poly1305 struct {
// contains filtered or unexported fields
}
Poly1305 provides a minimal helper for computing standalone Poly1305 MACs.
The helper wraps the internal Poly1305 implementation reused by the AEAD constructions. Callers must supply a unique one-time key for every message.
func NewPoly1305 ¶
NewPoly1305 initialises a Poly1305 helper with the provided one-time key. The key must be exactly 32 bytes as specified by RFC 7539.
func (*Poly1305) Sum ¶
Sum finalises the MAC and returns the authenticator. Further writes will panic, matching the behaviour of the underlying implementation.