diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-05-03 16:33:11 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-05-08 11:29:54 +0200 |
commit | e5aa87aeeb66a8f8068b41275d23c491f2dbd0f2 (patch) | |
tree | d3ac3b25fdbfec19e77599fd860016f661f9f5fb /comphelper | |
parent | 1eaae3966db362b5094feee4ac9a462ee9993d90 (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 'comphelper')
-rw-r--r-- | comphelper/source/misc/docpasswordhelper.cxx | 4 | ||||
-rw-r--r-- | comphelper/source/misc/random.cxx | 4 | ||||
-rw-r--r-- | comphelper/source/misc/storagehelper.cxx | 6 | ||||
-rw-r--r-- | comphelper/source/xml/xmltools.cxx | 8 |
4 files changed, 5 insertions, 17 deletions
diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx index e4327acb8e40..084fb0d36601 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(u"rtl_random_getBytes failed"_ustr); } - rtl_random_destroyPool ( aRandomPool ); return aResult; } diff --git a/comphelper/source/misc/random.cxx b/comphelper/source/misc/random.cxx index 058eb99813eb..5e763beb6c0a 100644 --- a/comphelper/source/misc/random.cxx +++ b/comphelper/source/misc/random.cxx @@ -60,10 +60,8 @@ struct RandomNumberGenerator } size_t seed = 0; - 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 = 0; - 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 ab6f71c7c734..b00e8c543752 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -437,17 +437,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(u"rtl_random_getBytes failed"_ustr); } - 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 6ae8fceed5b9..155436a744a1 100644 --- a/comphelper/source/xml/xmltools.cxx +++ b/comphelper/source/xml/xmltools.cxx @@ -77,17 +77,13 @@ namespace comphelper::xml // See SvXMLExport::addChaffWhenEncryptedStorage OString makeXMLChaff() { - rtlRandomPool pool = rtl_random_createPool(); - sal_Int8 n; - (void)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); - (void)rtl_random_getBytes(pool, aChaff.data(), nLength); - - rtl_random_destroyPool(pool); + (void)rtl_random_getBytes(nullptr, aChaff.data(), nLength); encodeChaff(aChaff); |