auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package auth implements bounded handshake authentication state.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidReplayLimit indicates a non-positive replay-cache capacity.
	ErrInvalidReplayLimit = errors.New("invalid replay cache limit")
	// ErrInvalidNonce indicates an unset handshake nonce.
	ErrInvalidNonce = errors.New("invalid nonce")
	// ErrReplay indicates a nonce already retained by the cache.
	ErrReplay = errors.New("replayed nonce")
	// ErrReplayCacheFull indicates admission would exceed the bounded cache.
	ErrReplayCacheFull = errors.New("replay cache full")
	// ErrTimestampOutsideWindow indicates stale or excessively future authentication time.
	ErrTimestampOutsideWindow = errors.New("timestamp outside authentication window")
)

Functions

func ReplayExpiry

func ReplayExpiry(timestampUnix int64, skew time.Duration) (int64, error)

ReplayExpiry returns the first Unix second after timestamp can pass the inclusive skew window.

func ValidateTimestamp

func ValidateTimestamp(timestampUnix, nowUnix int64, skew time.Duration) error

ValidateTimestamp verifies timestamp against a symmetric wall-clock skew window.

Types

type ReplayCache

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

ReplayCache retains authenticated nonces until their replay window expires.

func NewReplayCache

func NewReplayCache(limit int) (*ReplayCache, error)

NewReplayCache returns an empty replay cache with a fixed entry limit.

func (*ReplayCache) CheckAndStore

func (c *ReplayCache) CheckAndStore(nonce protocol.Nonce, nowUnix, expiresAtUnix int64) error

CheckAndStore atomically rejects a retained nonce or stores it through expiresAtUnix.

Jump to

Keyboard shortcuts

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