mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 22:05:21 +00:00
* Extract each type to a separate file * NoiseSessionManager: Remove unused functions --------- Co-authored-by: jack <212554440+jackjackbits@users.noreply.github.com>
38 lines
1.2 KiB
Swift
38 lines
1.2 KiB
Swift
//
|
|
// NoiseSecurityConstants.swift
|
|
// bitchat
|
|
//
|
|
// This is free and unencumbered software released into the public domain.
|
|
// For more information, see <https://unlicense.org>
|
|
//
|
|
|
|
import Foundation
|
|
|
|
enum NoiseSecurityConstants {
|
|
// Maximum message size to prevent memory exhaustion
|
|
static let maxMessageSize = 65535 // 64KB as per Noise spec
|
|
|
|
// Maximum handshake message size
|
|
static let maxHandshakeMessageSize = 2048 // 2KB to accommodate XX pattern
|
|
|
|
// Session timeout - sessions older than this should be renegotiated
|
|
static let sessionTimeout: TimeInterval = 86400 // 24 hours
|
|
|
|
// Maximum number of messages before rekey (2^64 - 1 is the nonce limit)
|
|
static let maxMessagesPerSession: UInt64 = 1_000_000_000 // 1 billion messages
|
|
|
|
// Handshake timeout - abandon incomplete handshakes
|
|
static let handshakeTimeout: TimeInterval = 60 // 1 minute
|
|
|
|
// Maximum concurrent sessions per peer
|
|
static let maxSessionsPerPeer = 3
|
|
|
|
// Rate limiting
|
|
static let maxHandshakesPerMinute = 10
|
|
static let maxMessagesPerSecond = 100
|
|
|
|
// Global rate limiting (across all peers)
|
|
static let maxGlobalHandshakesPerMinute = 30
|
|
static let maxGlobalMessagesPerSecond = 500
|
|
}
|