security

package
v0.0.0-...-1aa3d2a Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package security provides security utilities for the Tor client implementation

Index

Constants

View Source
const (
	TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = 0xc02b
	TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256   = 0xc02f
	TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = 0xc02c
	TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384   = 0xc030
	TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305  = 0xcca9
	TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305    = 0xcca8
)

TLS cipher suite constants

View Source
const (
	VersionTLS12 = 0x0303
)

TLS version constants

Variables

This section is empty.

Functions

func ConstantTimeCompare

func ConstantTimeCompare(a, b []byte) bool

ConstantTimeCompare performs constant-time comparison of two byte slices Returns true if the slices are equal, false otherwise This prevents timing attacks when comparing sensitive data like keys, MACs, etc.

func SafeInt64ToUint64

func SafeInt64ToUint64(val int64) (uint64, error)

SafeInt64ToUint64 safely converts an int64 to uint64 Returns error if the value is negative

func SafeIntToUint16

func SafeIntToUint16(val int) (uint16, error)

SafeIntToUint16 safely converts an int to uint16 Returns error if the value is negative or exceeds uint16 range

func SafeIntToUint32

func SafeIntToUint32(val int) (uint32, error)

SafeIntToUint32 safely converts an int to uint32 Returns error if the value is negative or exceeds uint32 range

func SafeIntToUint64

func SafeIntToUint64(val int) (uint64, error)

SafeIntToUint64 safely converts an int to uint64 Returns error if the value is negative

func SafeLenToUint16

func SafeLenToUint16(data []byte) (uint16, error)

SafeLenToUint16 is a convenience function to safely convert a slice length to uint16 This is commonly needed for protocol length fields

func SafeUint64ToInt64

func SafeUint64ToInt64(val uint64) (int64, error)

SafeUint64ToInt64 safely converts a uint64 to int64 Returns error if the value would overflow int64

func SafeUnixToUint32

func SafeUnixToUint32(t time.Time) (uint32, error)

SafeUnixToUint32 safely converts a Unix timestamp to uint32 Returns error if the timestamp is negative or would overflow uint32 Note: Will overflow in year 2106 (max uint32 = 4294967295)

func SafeUnixToUint64

func SafeUnixToUint64(t time.Time) (uint64, error)

SafeUnixToUint64 safely converts a Unix timestamp to uint64 Returns error if the timestamp is negative or would overflow

func SecureZeroMemory

func SecureZeroMemory(data []byte)

SecureZeroMemory zeros out a byte slice to prevent sensitive data from remaining in memory Uses a method that should prevent compiler optimization from removing the zeroing

Types

type Config

type Config struct {
	MinVersion               uint16
	CipherSuites             []uint16
	PreferServerCipherSuites bool
}

Config represents a TLS configuration for testing

type RateLimiter

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

RateLimiter implements token bucket rate limiting

func (*RateLimiter) Allow

func (rl *RateLimiter) Allow() bool

Allow checks if an operation is allowed

type ResourceManager

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

ResourceManager manages resource allocation limits

func (*ResourceManager) Allocate

func (rm *ResourceManager) Allocate(resourceType string) error

Allocate attempts to allocate a resource

func (*ResourceManager) Release

func (rm *ResourceManager) Release()

Release releases a resource

Jump to

Keyboard shortcuts

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