func RandomBytes(n int) ([]byte, error)
RandomBytes returns n random bytes by reading from crypto/rand.Reader
HMACStrategy is responsible for generating and validating challenges.
type HMACStrategy struct { TokenEntropy int GlobalSecret []byte RotatedGlobalSecrets [][]byte Hash func() hash.Hash // Hash is a hash.Hash function to use to generate and validate challenges. If nil, sha512.New512_256 is used. sync.Mutex }
func (c *HMACStrategy) Generate() (string, string, error)
Generate generates a token and a matching signature or returns an error. This method implements rfc6819 Section 5.1.4.2.2: Use High Entropy for Secrets.
func (c *HMACStrategy) Signature(token string) string
func (c *HMACStrategy) Validate(token string) (err error)
Validate validates a token and returns its signature or an error if the token is not valid.