summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-05-03 16:33:11 +0100
committerMichael Meeks <michael.meeks@collabora.com>2024-05-10 18:25:27 +0200
commit3f15ad602da8a68d7cb63b02d9b456b0bd1d623b (patch)
treed13afbe3e22d68812a74f46d3ad78b8e18d7937e /comphelper
parente747e6df648a7ff076663ab376a4dbbc041b5180 (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/+/167335 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/docpasswordhelper.cxx4
-rw-r--r--comphelper/source/misc/random.cxx4
-rw-r--r--comphelper/source/misc/storagehelper.cxx6
-rw-r--r--comphelper/source/xml/xmltools.cxx8
4 files changed, 5 insertions, 17 deletions
diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx
index 1f73bd8d7026..9082efa054e0 100644
--- a/comphelper/source/misc/docpasswordhelper.cxx
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -426,12 +426,10 @@ OUString DocPasswordHelper::GetOoxHashAsBase64(
{
uno::Sequence< sal_Int8 > aResult( nLength );
- rtlRandomPool aRandomPool = rtl_random_createPool ();
- if (rtl_random_getBytes(aRandomPool, aResult.getArray(), nLength) != rtl_Random_E_None)
+ if (rtl_random_getBytes(nullptr, aResult.getArray(), nLength) != rtl_Random_E_None)
{
throw uno::RuntimeException("rtl_random_getBytes failed");
}
- rtl_random_destroyPool ( aRandomPool );
return aResult;
}
diff --git a/comphelper/source/misc/random.cxx b/comphelper/source/misc/random.cxx
index b8358344e5b0..4e5ad979b171 100644
--- a/comphelper/source/misc/random.cxx
+++ b/comphelper/source/misc/random.cxx
@@ -60,10 +60,8 @@ struct RandomNumberGenerator
}
size_t seed = -1;
- rtlRandomPool aRandomPool = rtl_random_createPool();
- if (rtl_random_getBytes(aRandomPool, &seed, sizeof(seed)) != rtl_Random_E_None)
+ if (rtl_random_getBytes(nullptr, &seed, sizeof(seed)) != rtl_Random_E_None)
seed = -1;
- rtl_random_destroyPool(aRandomPool);
// initialises the state of the global random number generator
// should only be called once.
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 1d504cb91725..5ba710862d6d 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -443,17 +443,13 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat
// generate session key
// --------------------
- rtlRandomPool aRandomPool = rtl_random_createPool();
-
// get 32 random chars out of it
uno::Sequence < sal_Int8 > aVector(32);
- if (rtl_random_getBytes(aRandomPool, aVector.getArray(), aVector.getLength()) != rtl_Random_E_None)
+ if (rtl_random_getBytes(nullptr, aVector.getArray(), aVector.getLength()) != rtl_Random_E_None)
{
throw uno::RuntimeException("rtl_random_getBytes failed");
}
- rtl_random_destroyPool(aRandomPool);
-
std::vector< uno::Sequence< beans::NamedValue > > aGpgEncryptions;
uno::Reference< security::XDocumentDigitalSignatures > xSigner(
diff --git a/comphelper/source/xml/xmltools.cxx b/comphelper/source/xml/xmltools.cxx
index 1b10964b1a35..a5c4ff1bd519 100644
--- a/comphelper/source/xml/xmltools.cxx
+++ b/comphelper/source/xml/xmltools.cxx
@@ -73,17 +73,13 @@ namespace comphelper::xml
{
OString makeXMLChaff()
{
- rtlRandomPool pool = rtl_random_createPool();
-
sal_Int8 n;
- rtl_random_getBytes(pool, &n, 1);
+ (void)rtl_random_getBytes(nullptr, &n, 1);
sal_Int32 nLength = 1024+n;
// coverity[tainted_data] - 1024 deliberate random minus max -127/plus max 128
std::vector<sal_uInt8> aChaff(nLength);
- rtl_random_getBytes(pool, aChaff.data(), nLength);
-
- rtl_random_destroyPool(pool);
+ (void)rtl_random_getBytes(nullptr, aChaff.data(), nLength);
encodeChaff(aChaff);