Documentation
¶
Overview ¶
Package security provides security utilities for the Tor client implementation
Index ¶
- Constants
- func ConstantTimeCompare(a, b []byte) bool
- func SafeInt64ToUint64(val int64) (uint64, error)
- func SafeIntToUint16(val int) (uint16, error)
- func SafeIntToUint32(val int) (uint32, error)
- func SafeIntToUint64(val int) (uint64, error)
- func SafeLenToUint16(data []byte) (uint16, error)
- func SafeUint64ToInt64(val uint64) (int64, error)
- func SafeUnixToUint32(t time.Time) (uint32, error)
- func SafeUnixToUint64(t time.Time) (uint64, error)
- func SecureZeroMemory(data []byte)
- type Config
- type RateLimiter
- type ResourceManager
Constants ¶
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
const (
VersionTLS12 = 0x0303
)
TLS version constants
Variables ¶
This section is empty.
Functions ¶
func ConstantTimeCompare ¶
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 ¶
SafeInt64ToUint64 safely converts an int64 to uint64 Returns error if the value is negative
func SafeIntToUint16 ¶
SafeIntToUint16 safely converts an int to uint16 Returns error if the value is negative or exceeds uint16 range
func SafeIntToUint32 ¶
SafeIntToUint32 safely converts an int to uint32 Returns error if the value is negative or exceeds uint32 range
func SafeIntToUint64 ¶
SafeIntToUint64 safely converts an int to uint64 Returns error if the value is negative
func SafeLenToUint16 ¶
SafeLenToUint16 is a convenience function to safely convert a slice length to uint16 This is commonly needed for protocol length fields
func SafeUint64ToInt64 ¶
SafeUint64ToInt64 safely converts a uint64 to int64 Returns error if the value would overflow int64
func SafeUnixToUint32 ¶
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 ¶
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 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