summaryrefslogtreecommitdiff
path: root/sal/rtl/uuid.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-05-03 16:33:11 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-05-08 11:29:54 +0200
commite5aa87aeeb66a8f8068b41275d23c491f2dbd0f2 (patch)
treed3ac3b25fdbfec19e77599fd860016f661f9f5fb /sal/rtl/uuid.cxx
parent1eaae3966db362b5094feee4ac9a462ee9993d90 (diff)
drop requirement for rtl_random_getBytes to have "Pool" arg
Seeing as since: commit e9531b792ddf0cfc2db11713b574c5fc7ae09e2c Date: Tue Feb 6 14:39:47 2024 +0100 sal: rtlRandomPool: require OS random device, abort if not present Both rtl_random_createPool() and rtl_random_getBytes() first try to get random data from the OS, via /dev/urandom or rand_s() (documented to call RtlGenRandom(), see [1]). we don't use the initial arg to rtl_random_getBytes anymore, drop the requirement to have one. Then simplify our usages of that, and addtionally deprecate rtl_random_createPool and rtl_random_destroyPool. Change-Id: I13dcc067714a8a741a4e8f2bfcf2006373f832c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167067 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sal/rtl/uuid.cxx')
-rw-r--r--sal/rtl/uuid.cxx26
1 files changed, 5 insertions, 21 deletions
diff --git a/sal/rtl/uuid.cxx b/sal/rtl/uuid.cxx
index 22e7f0fe0416..4249c7bddedb 100644
--- a/sal/rtl/uuid.cxx
+++ b/sal/rtl/uuid.cxx
@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <mutex>
#include <string.h>
#include <stdlib.h>
@@ -84,28 +83,13 @@ extern "C" void SAL_CALL rtl_createUuid(sal_uInt8 *pTargetUUID ,
SAL_UNUSED_PARAMETER const sal_uInt8 *,
SAL_UNUSED_PARAMETER sal_Bool)
{
+ if (rtl_random_getBytes(nullptr, pTargetUUID, 16) != rtl_Random_E_None)
{
- static rtlRandomPool pool = []() {
- rtlRandomPool aPool = rtl_random_createPool();
- if (!aPool)
- {
- abort();
- // only possible way to signal failure here (rtl_createUuid
- // being part of a fixed C API)
- }
- return aPool;
- }();
-
- static std::mutex aMutex;
-
- std::scoped_lock g(aMutex);
- if (rtl_random_getBytes(pool, pTargetUUID, 16) != rtl_Random_E_None)
- {
- abort();
- // only possible way to signal failure here (rtl_createUuid
- // being part of a fixed C API)
- }
+ abort();
+ // only possible way to signal failure here (rtl_createUuid
+ // being part of a fixed C API)
}
+
// See ITU-T Recommendation X.667:
pTargetUUID[6] &= 0x0F;
pTargetUUID[6] |= 0x40;