hmac

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSignedHMAC added in v1.0.4

func GenerateSignedHMAC(data []byte, key *[32]byte) []byte

func RandomBytes added in v0.4.0

func RandomBytes(n int) ([]byte, error)

RandomBytes returns n random bytes by reading from crypto/rand.Reader

Types

type HMACStrategy

type HMACStrategy struct {
	TokenEntropy         int
	GlobalSecret         []byte
	RotatedGlobalSecrets [][]byte
	PrivateKey           *rsa.PrivateKey
	sync.Mutex
}

HMACStrategy is responsible for generating and validating challenges.

func (*HMACStrategy) Generate

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 (*HMACStrategy) GetExpirationTime added in v1.0.5

func (c *HMACStrategy) GetExpirationTime(token string) (time.Time, error)

GetExpirationTime - Get Expiration Time from Token in UTC

func (*HMACStrategy) Signature

func (c *HMACStrategy) Signature(token string) string

Signature - Return Signature Out of HmacToken

func (*HMACStrategy) Valid added in v1.0.5

func (c *HMACStrategy) Valid(token string) bool

Valid - Check for Expiry of HMAC Token

func (*HMACStrategy) Validate

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.

type OldHMACStrategy added in v1.0.5

type OldHMACStrategy struct {
	TokenEntropy         int
	GlobalSecret         []byte
	RotatedGlobalSecrets [][]byte
	sync.Mutex
}

OldHMACStrategy is responsible for generating and validating challenges.

func (*OldHMACStrategy) Generate added in v1.0.5

func (c *OldHMACStrategy) 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 (*OldHMACStrategy) Signature added in v1.0.5

func (c *OldHMACStrategy) Signature(token string) string

func (*OldHMACStrategy) Validate added in v1.0.5

func (c *OldHMACStrategy) Validate(token string) (err error)

Validate validates a token and returns its signature or an error if the token is not valid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL