summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-06-28 21:28:38 +0300
committerEd Tanous <ed@tanous.net>2023-07-12 22:48:32 +0300
commit2c6ffdb08b2207ff7c31041f77cc3755508d45c4 (patch)
tree5b2b58102221318866a06a11751d2efa76782fe4 /src
parent9eef578458f6dc3587bd27039f1ebb367041000b (diff)
downloadbmcweb-2c6ffdb08b2207ff7c31041f77cc3755508d45c4.tar.xz
Use openssl random number generator
We already have a generator class. We should use it. Wrap this into a function that can be unit tested, and add unit tests. Note, some files also needed to change name, because random.hpp conflicts with the built in random, and causes circular build problems. This commit changes it to ossl_random. Tested: Unit tests pass. Now has coverage. Redfish service validator passes. Change-Id: I5f8eee1af5f4843a352c6fd0e26d67fd3320ef53 Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/ossl_random.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ossl_random.cpp b/src/ossl_random.cpp
new file mode 100644
index 0000000000..f196a8b5a3
--- /dev/null
+++ b/src/ossl_random.cpp
@@ -0,0 +1,12 @@
+#include "ossl_random.hpp"
+
+#include <boost/uuid/uuid_generators.hpp>
+#include <boost/uuid/uuid_io.hpp>
+
+std::string bmcweb::getRandomUUID()
+{
+ using bmcweb::OpenSSLGenerator;
+ OpenSSLGenerator ossl;
+ return boost::uuids::to_string(
+ boost::uuids::basic_random_generator<OpenSSLGenerator>(ossl)());
+}