Authentication factors (something you know, have, are) in Cybersecurity - Time & Space Complexity
We want to understand how the time needed to verify a user's identity changes as the number of authentication factors grows.
How does adding more factors affect the time it takes to check them all?
Analyze the time complexity of the following authentication check process.
function authenticate(userInput, factors) {
for (let factor of factors) {
if (!verify(factor, userInput[factor.type])) {
return false;
}
}
return true;
}
// verify() checks each factor like password, token, or biometric
This code checks each authentication factor one by one to confirm the user's identity.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Loop over each authentication factor to verify it.
- How many times: Once for each factor in the list.
As the number of factors increases, the time to check them grows in a straight line.
| Input Size (n) | Approx. Operations |
|---|---|
| 1 | 1 verification |
| 3 | 3 verifications |
| 5 | 5 verifications |
Pattern observation: Doubling the number of factors roughly doubles the work needed.
Time Complexity: O(n)
This means the time to authenticate grows directly with the number of factors checked.
[X] Wrong: "Adding more factors won't affect authentication time much because each check is fast."
[OK] Correct: Even if each check is quick, doing many checks one after another adds up, increasing total time linearly.
Understanding how authentication time grows helps you design secure systems that stay efficient as more factors are added.
"What if the verification process for each factor ran in parallel instead of one after another? How would the time complexity change?"