diff options
author | Malfurious <m@lfurio.us> | 2024-10-22 03:06:21 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2024-10-24 06:41:41 -0400 |
commit | 48006196407251eaeb0a52297e4a412d76fce086 (patch) | |
tree | aed83ee52a25674b2a7d0a5b189efaa2734313de /Cryptor.cpp | |
parent | a01e8dfb054fae877e4b94ece6b6f18dd5fd67f8 (diff) | |
download | compass-48006196407251eaeb0a52297e4a412d76fce086.tar.gz compass-48006196407251eaeb0a52297e4a412d76fce086.zip |
Refactor random password generation to use mbedtls entropy source
Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'Cryptor.cpp')
-rw-r--r-- | Cryptor.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/Cryptor.cpp b/Cryptor.cpp index 25a2ae9..9db2bdc 100644 --- a/Cryptor.cpp +++ b/Cryptor.cpp @@ -153,9 +153,7 @@ std::string Cryptor::loadAndDecrypt(std::string remoteHost, std::string port, st }
std::string Cryptor::createRandomPassword(PasswordSpec spec) {
- CryptoPP::AutoSeededRandomPool randl;
std::string password;
-
std::vector<char> validChars;
// Always allow lower-case alphabetic characters
@@ -208,14 +206,11 @@ std::string Cryptor::createRandomPassword(PasswordSpec spec) { validChars.push_back('0' + i);
}
-
// Build string
for (int i = 0; i < spec.ml; i++) {
- unsigned char r[1];
- char c;
- randl.GenerateBlock(r, sizeof(r));
- c = validChars[r[0] % validChars.size()];
- password += c;
+ unsigned char c;
+ generateRandom(&c, sizeof(c));
+ password += validChars[c % validChars.size()];
}
return password;
|