Class PasswordWorkGate
java.lang.Object
com.revetsec.password.PasswordWorkGate
Explicit in-memory, process-local admission for expensive password work. Share one instance
across every hasher in a process; each JVM needs its own gate to bound that JVM's CPU and memory.
Its temporary counters are discarded on restart and are never shared across nodes.
Admission waits interruptibly for short reservation-counter updates. The gate never queues
for KDF capacity or starts worker threads; exhausted capacity yields an operation result.
Password preparation, hashing and application callbacks run outside the accounting lock.
One permit covers normalization/encoding, pepper lookup and KDF cleanup; it is not released
between those phases. Input length caps do not guarantee a normalization wall-time bound.
Applications separately own shared per-account/edge attempt admission and durable credential storage.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull PasswordWorkGatefromInMemoryLimits(@NonNull Integer maximumConcurrentCalls, @NonNull Integer maximumMemoryKiB) Creates a bounded in-memory work gate for one JVM.Returns the concurrency limit for admitted password operations.Returns the shared memory reservation limit.
-
Method Details
-
fromInMemoryLimits
public static @NonNull PasswordWorkGate fromInMemoryLimits(@NonNull Integer maximumConcurrentCalls, @NonNull Integer maximumMemoryKiB) Creates a bounded in-memory work gate for one JVM. Reuse the returned instance across all hashers in that JVM. Separate calls create independent gates; this factory supplies no default concurrency or memory budget and performs no distributed attempt throttling.- Parameters:
maximumConcurrentCalls- maximum simultaneous password operations, from 1 through 256maximumMemoryKiB- aggregate Argon2id memory reservation in KiB, from 19,456 through 4,194,304- Returns:
- the gate
- Throws:
IllegalArgumentException- if either limit is outside its supported range- Since:
- 1.0.0
-
getMaximumConcurrentCalls
Returns the concurrency limit for admitted password operations.- Returns:
- the maximum simultaneous password operations
- Since:
- 1.0.0
-
getMaximumMemoryKiB
Returns the shared memory reservation limit.- Returns:
- the aggregate Argon2id memory reservation in KiB
- Since:
- 1.0.0
-