Table of Contents
1. Introduction
Persistent reports of website account and password leaks highlight the critical importance of information and password security. While website vulnerabilities are a factor, the inherent security of the password itself is paramount. Common insecure password practices include keyword-based passwords, popular phrase usage, incorporation of personal information, and password reuse. The rise of AI and large language models further empowers attackers to guess passwords more effectively.
This research proposes a secure password generator based on cryptographically secure Pseudo Random Number Generators (PRNGs). It constructs PRNGs using Keyed-Hash Message Authentication Code (HMAC), Cipher-based Message Authentication Code (CMAC), or KECCAK Message Authentication Code (KMAC) to produce secure random numbers, which are then used to generate passwords. The randomness of the generated numbers is validated against the NIST SP 800-90B standard through entropy and Independent and Identically Distributed (IID) tests.
Key Contributions:
- Construction of secure PRNGs based on HMAC, CMAC, and KMAC for password generation.
- Security analysis of passwords under different character sets and length constraints, with comparisons to AES-128/256.
- Empirical validation using NIST SP 800-90B entropy and IID tests.
2. Literature Review
2.1. Linear Congruential Generator-based PRNG
Commonly used in languages like C and Java, LCGs generate a sequence of numbers using a linear recurrence relation. Given a seed $k$, the initial value $f_0(k)$ is computed as $f_0(k) \equiv a \oplus k \ (\text{mod} \ m)$. Subsequent numbers are generated by $f_i(k) \equiv a \times f_{i-1}(k) + c \ (\text{mod} \ m)$. However, LCGs are insecure as the state can be reversed using $f_{i-1}(k) \equiv (f_i(k) - c) \times a^{-1} \ (\text{mod} \ m)$, exposing the seed and the entire sequence.
2.2. Secure Pseudo Random Number Generator
To address LCG vulnerabilities, cryptographically secure PRNGs are essential. This paper focuses on three NIST-recommended constructions.
2.2.1. HMAC-based PRNG
Security relies on the one-way property of hash functions (e.g., SHA2, SHA3). For a key $k$ and message $M$, the HMAC is computed as $r_{hmac}(k, M) = h((k \oplus opad) \ || \ h((k \oplus ipad) \ || \ M))$, where $ipad$ and $opad$ are constants. To generate a long bitstream, a counter mode is used: $M_i = i \ || \ KDF \ || \ 0x00 \ || \ M \ || \ L$, producing outputs $r_{hmac,i}$.
2.2.2. CMAC-based PRNG
Security is based on the Advanced Encryption Standard (AES). Using Cipher Block Chaining (CBC) mode with key $k$, the message $M$ is split into blocks $M'_1, M'_2, ...$. The ciphertext is computed iteratively: $c_{i+1} = AES(k, c_i \oplus M'_{i+1})$, with $c_0 = Pad0(0)$. The final output $r_{cmac}$ is derived from the last block.
2.2.3. KMAC-based PRNG
Based on the SHA-3 (KECCAK) hash function, KMAC provides a variable-length output and is considered a strong candidate for post-quantum cryptography. Its construction follows a similar authenticated hashing principle, offering high security guarantees.
2.3. Randomness Validation Methods
The NIST SP 800-90B standard provides methodologies for assessing the quality of random number generators. Two key aspects are evaluated:
- Entropy Validation: Measures the unpredictability or "randomness" per bit in the data. High entropy is crucial for secure passwords.
- IID (Independent and Identically Distributed) Validation: Tests whether the generated sequence is statistically independent and follows an identical distribution, ensuring no patterns or correlations exist.
3. Proposed Secure Password Generator
The system architecture involves two main stages:
- Secure Random Number Generation: A user can optionally provide a To-Be-Hashed Message (TBHM). This, along with a cryptographic key, is processed by the chosen secure PRNG (HMAC/CMAC/KMAC-based) to produce a cryptographically strong random bit sequence.
- Password Generation: The random bits are mapped onto a user-defined or system-defined character set (e.g., alphanumeric plus symbols) of a specified length to generate the final text-based password. The security strength is analyzed relative to AES-128/256, considering the entropy provided by the character set size and password length.
4. Experiments and Results
4.1. Experimental Setup
Experiments were conducted to validate the randomness of the PRNG outputs. The test suite implemented the NIST SP 800-90B assessment procedures for entropy estimation and IID testing on large samples of generated random numbers from all three PRNG types.
4.2. Randomness Validation Results
Result Summary: The proposed HMAC, CMAC, and KMAC-based PRNGs all successfully passed the NIST SP 800-90B entropy and IID validation tests. The generated sequences exhibited no statistically significant deviations from true randomness, confirming their suitability for cryptographic password generation.
Chart Description (Imagined): A bar chart comparing the min-entropy estimates (in bits per bit) for the three PRNG types against the NIST passing threshold. All three bars would be shown significantly above the threshold line, with KMAC potentially showing the highest value, followed closely by HMAC-SHA3 and CMAC-AES256.
4.3. Performance Analysis
A comparative analysis of the computational efficiency (e.g., generations per second) was performed. CMAC-based generators (using AES-NI hardware acceleration) typically showed the highest throughput, followed by HMAC-based (SHA2/SHA3), with KMAC being computationally heavier but offering robust post-quantum security properties.
5. Conclusion and Future Work
This research successfully designed and validated a secure password generator built upon cryptographically secure PRNGs (HMAC, CMAC, KMAC). The generated passwords derive their security from the proven robustness of these underlying cryptographic primitives and the verified high randomness of the PRNG output. Future work includes integrating the generator into browser extensions or password managers, exploring its use in generating cryptographic keys beyond passwords, and conducting side-channel attack resistance analysis on the complete system.
6. Original Analysis & Expert Commentary
Core Insight: This paper is a pragmatic, engineering-focused response to the perennial weak link in cybersecurity: human-chosen passwords. Its core value isn't in novel cryptography but in the correct application and rigorous validation of existing, battle-tested constructs (HMAC, CMAC, KMAC) for a specific, high-impact use case. It correctly identifies that moving password generation from user brains to a validated cryptographic process is a fundamental security upgrade, akin to the shift from symmetric to asymmetric crypto for key exchange.
Logical Flow: The logic is sound and follows a classic applied research pattern: problem definition (weak passwords) → critique of common solutions (insecure LCGs) → proposal of a robust solution (CSPRNG-based generator) → empirical validation (NIST tests). The choice of NIST SP 800-90B as the validation benchmark is excellent, as it's the de facto standard for evaluating randomness in cryptographic contexts, lending immediate credibility to the results.
Strengths & Flaws:
Strengths: The paper's greatest strength is its practical validation. Many proposals stop at the design phase. By subjecting the output to NIST's stringent tests, the authors provide concrete evidence of security, which is crucial for adoption. The inclusion of KMAC, based on SHA-3, shows foresight regarding post-quantum considerations, as noted in NIST's ongoing post-quantum cryptography standardization process.
Flaws/Omissions: The analysis is somewhat siloed. A significant flaw is the lack of discussion on seed management. The security of any PRNG collapses if its seed is predictable or泄露. How does the system generate, store, and protect the initial cryptographic key for HMAC/CMAC/KMAC? This is as critical as the algorithm itself. Furthermore, while comparing password strength to AES is useful, a more direct comparison to existing password generators (like those in KeePass or 1Password) and their underlying PRNGs (e.g., using ChaCha20) would provide better context for its competitive advantage.
Actionable Insights: For security practitioners, this paper serves as a blueprint. Action 1: Immediately deprecate any use of LCGs or similar non-cryptographic RNGs (like `rand()`) for security-sensitive tasks. Action 2: When building or auditing a password generator, the primary checklist items should be: 1) Use a CSPRNG (HMAC_DRBG, CTR_DRBG from NIST SP 800-90A, or the constructs here), 2) Validate its output with a suite like NIST SP 800-90B or Dieharder, and 3) Implement robust seed generation from a high-entropy source (e.g., `getrandom()` on Linux). The paper successfully focuses on point 2, but points 1 and 3 are equally vital parts of the complete picture.
7. Technical Details & Mathematical Formulation
The security of the proposed generator hinges on the underlying cryptographic functions. The key mathematical operations are:
- HMAC: $r_{hmac}(k, M) = h((k \oplus opad) \ || \ h((k \oplus ipad) \ || \ M))$
- CMAC (CBC-MAC): $c_{i+1} = E(k, c_i \oplus M_{i+1})$, where $E$ is the block cipher (AES).
- Password Entropy: The entropy $H$ of a generated password is $H = L \cdot \log_2(N)$, where $L$ is the password length and $N$ is the size of the character set. For a 16-character password from a 94-character set, $H \approx 16 \cdot \log_2(94) \approx 105$ bits.
8. Analysis Framework & Case Example
Case Example: Auditing a Web Application's Password Reset Function
Scenario: A web app generates a temporary password for users who click "Forgot Password."
Framework Application:
- Identify the RNG: Inspect the server-side code. Finding `Math.random()` (JavaScript) or a simple LCG in PHP would be a critical failure.
- Assess Entropy Source: How is the PRNG seeded? Is it using system entropy (`/dev/urandom`, `CryptGenRandom`)?
- Map to Proposed Solution: Recommend replacing the flawed RNG with a module implementing this paper's design—for instance, a Python function using `hmac.new` with SHA256 and a seed from `os.urandom(32)`.
- Validate Output (Post-Implementation): Generate a sample of 1,000,000 temporary passwords, convert to bitstream, and run the NIST STS suite (a related test suite) to ensure randomness.
9. Future Applications & Directions
The core technology has applications beyond user password generation:
- API Key & Token Generation: Generating secure, random API keys and session tokens for microservices architectures.
- Secure Default Credentials: Embedding such a generator in IoT device firmware to create unique, strong default passwords for each device, mitigating widespread attacks based on common defaults.
- Cryptographic Seed Generation: The high-quality output can be used to seed other cryptographic systems or to generate nonces and initialization vectors (IVs).
- Integration with Password Managers: The algorithm could be integrated as the core engine for open-source password managers, providing a transparent and auditable source of randomness.
- Post-Quantum Readiness: Further exploration and optimization of the KMAC-based generator, aligning with NIST's FIPS 202 and SP 800-185 standards, to prepare for a post-quantum computing era.
10. References
- M. Bishop, "Computer Security: Art and Science," Addison-Wesley, 2003.
- NIST, "Special Publication 800-63B: Digital Identity Guidelines," 2017.
- NIST, "Special Publication 800-90A: Recommendation for Random Number Generation Using Deterministic Random Bit Generators," 2015.
- NIST, "Special Publication 800-90B: Recommendation for the Entropy Sources Used for Random Bit Generation," 2018.
- J. Kelsey, B. Schneier, D. Wagner, "Secure Applications of Low-Entropy Keys," ISW '97.
- D. D. Hwang, B. B. Gupta, "A Study of Password Security and Its Implications," JIS, 2019.
- NIST, "FIPS 202: SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions," 2015.
- NIST, "SP 800-185: SHA-3 Derived Functions: cSHAKE, KMAC, TupleHash and ParallelHash," 2016.
- M. S. Turan, E. Barker, J. Kelsey, "Recommendation for Random Bit Generator (RBG) Constructions," NIST SP 800-90C, 2016.
- P. G. Neumann, "Illustrative Risks to the Public in the Use of Computer Systems and Related Technology," ACM SIGSOFT, 1995.