hmac

package
v0.48.0-dev2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimedHMAC

type TimedHMAC struct {
	// contains filtered or unexported fields
}

TimedHMAC generates a token with TTL and uses a pre-shared secret known to the relay server

func NewTimedHMAC

func NewTimedHMAC(secret string, timeToLive time.Duration) *TimedHMAC

NewTimedHMAC creates a new TimedHMAC instance

func (*TimedHMAC) GenerateToken

func (m *TimedHMAC) GenerateToken(algo func() hash.Hash) (*Token, error)

GenerateToken generates new time-based secret token - basically Payload is a unix timestamp and Signature is a HMAC hash of a timestamp with a preshared TURN secret

func (*TimedHMAC) Validate

func (m *TimedHMAC) Validate(algo func() hash.Hash, token Token) error

Validate checks if the token is valid

type TimedHMACValidator

type TimedHMACValidator struct {
	*TimedHMAC
}

func NewTimedHMACValidator

func NewTimedHMACValidator(secret string, duration time.Duration) *TimedHMACValidator

func (*TimedHMACValidator) Validate

func (a *TimedHMACValidator) Validate(credentials any) error

type Token

type Token struct {
	Payload   string
	Signature string
}

type TokenStore

type TokenStore struct {
	// contains filtered or unexported fields
}

TokenStore is a simple in-memory store for token With this can update the token in thread safe way

func (*TokenStore) TokenBinary

func (a *TokenStore) TokenBinary() []byte

func (*TokenStore) UpdateToken

func (a *TokenStore) UpdateToken(token *Token) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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