nonce_cache

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package nonce_cache provides a mechanism for managing nonce storage and checking for replay attacks. It implements a NonceCache type that stores nonces with timestamps and allows for expiration of old nonces to prevent memory exhaustion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NonceCache

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

NonceCache manages nonce storage and checks for replay attacks.

func NewNonceCache

func NewNonceCache(expiryTime time.Duration) *NonceCache

NewNonceCache creates a new NonceCache with the specified expiry time for nonces.

func (*NonceCache) CleanupExpiredNonces

func (nc *NonceCache) CleanupExpiredNonces()

CleanupExpiredNonces removes nonces that have expired from the cache.

func (*NonceCache) Exists

func (nc *NonceCache) Exists(nonce []byte) bool

Exists checks if a nonce exists in the cache or not

func (*NonceCache) Load

func (nc *NonceCache) Load(nonce []byte) (any, bool)

Load loads a nonce from the cache.

func (*NonceCache) StartCleanupRoutine

func (nc *NonceCache) StartCleanupRoutine(ctx context.Context, cleanupInterval time.Duration)

StartCleanupRoutine starts a background routine to periodically clean up expired nonces. It runs the cleanup every cleanupInterval, and listens for cancellation via context.

func (*NonceCache) Store

func (nc *NonceCache) Store(nonce []byte) error

Store stores a nonce in the cache. If the nonce already exists, it returns an error.

Jump to

Keyboard shortcuts

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