summaryrefslogtreecommitdiff
path: root/src/mongo/crypto/mechanism_scram.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/crypto/mechanism_scram.h')
-rw-r--r--src/mongo/crypto/mechanism_scram.h12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/mongo/crypto/mechanism_scram.h b/src/mongo/crypto/mechanism_scram.h
index fcb16331830..5e0265679ea 100644
--- a/src/mongo/crypto/mechanism_scram.h
+++ b/src/mongo/crypto/mechanism_scram.h
@@ -102,15 +102,9 @@ public:
}
static std::vector<std::uint8_t> generateSecureRandomSalt() {
- // Express salt length as a number of quad words, rounded up.
- constexpr auto qwords = (saltLength() + sizeof(std::int64_t) - 1) / sizeof(std::int64_t);
- std::array<std::int64_t, qwords> userSalt;
-
- std::unique_ptr<SecureRandom> sr(SecureRandom::create());
- std::generate(userSalt.begin(), userSalt.end(), [&sr] { return sr->nextInt64(); });
- return std::vector<std::uint8_t>(reinterpret_cast<std::uint8_t*>(userSalt.data()),
- reinterpret_cast<std::uint8_t*>(userSalt.data()) +
- saltLength());
+ std::vector<std::uint8_t> salt(saltLength());
+ SecureRandom().fill(salt.data(), salt.size());
+ return salt;
}
private: