binaryurp/source/bridge.cxx                        |    4 --
 comphelper/source/misc/docpasswordhelper.cxx       |    4 --
 comphelper/source/misc/random.cxx                  |    4 --
 comphelper/source/misc/storagehelper.cxx           |    6 ----
 comphelper/source/xml/xmltools.cxx                 |    8 +----
 cppuhelper/source/bootstrap.cxx                    |    6 ----
 desktop/source/deployment/misc/dp_misc.cxx         |    5 ---
 include/rtl/random.h                               |   29 +++++++++++----------
 oox/source/crypto/Standard2007Engine.cxx           |    4 --
 package/inc/ZipPackageEntry.hxx                    |    4 --
 package/inc/ZipPackageFolder.hxx                   |    6 +---
 package/inc/ZipPackageStream.hxx                   |    3 --
 package/source/zippackage/ZipPackage.cxx           |   28 --------------------
 package/source/zippackage/ZipPackageFolder.cxx     |   14 ++++------
 package/source/zippackage/ZipPackageStream.cxx     |    7 ++---
 sal/rtl/random.cxx                                 |    5 +--
 sal/rtl/uuid.cxx                                   |   26 +++---------------
 sc/source/filter/excel/xeroot.cxx                  |    4 --
 sc/source/filter/excel/xestream.cxx                |    4 --
 stoc/source/javaloader/javaloader.cxx              |    5 ---
 svl/source/passwordcontainer/passwordcontainer.cxx |    3 --
 svl/source/passwordcontainer/passwordcontainer.hxx |   23 ----------------
 sw/source/filter/ww8/wrtww8.cxx                    |    4 --
 sw/source/filter/ww8/ww8par.cxx                    |    4 --
 xmlsecurity/source/xmlsec/nss/ciphercontext.cxx    |    4 --
 25 files changed, 54 insertions(+), 160 deletions(-)

New commits:
commit 3f15ad602da8a68d7cb63b02d9b456b0bd1d623b
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri May 3 16:33:11 2024 +0100
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Fri May 10 18:25:27 2024 +0200

    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.me...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/binaryurp/source/bridge.cxx b/binaryurp/source/bridge.cxx
index 523bbbf14ac5..f8c4cb232562 100644
--- a/binaryurp/source/bridge.cxx
+++ b/binaryurp/source/bridge.cxx
@@ -74,9 +74,7 @@ namespace {
 
 sal_Int32 random() {
     sal_Int32 n;
-    rtlRandomPool pool = rtl_random_createPool();
-    rtl_random_getBytes(pool, &n, sizeof n);
-    rtl_random_destroyPool(pool);
+    (void)rtl_random_getBytes(nullptr, &n, sizeof n);
     return n;
 }
 
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);
 
diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx
index bd975460f06c..bb8997d1ef3d 100644
--- a/cppuhelper/source/bootstrap.cxx
+++ b/cppuhelper/source/bootstrap.cxx
@@ -139,14 +139,10 @@ Reference< XComponentContext > SAL_CALL bootstrap()
             throw BootstrapException( "no local component context!" );
 
         // create a random pipe name
-        rtlRandomPool hPool = rtl_random_createPool();
-        if ( hPool == nullptr )
-            throw BootstrapException( "cannot create random pool!" );
         sal_uInt8 bytes[ 16 ];
-        if ( rtl_random_getBytes( hPool, bytes, std::size( bytes ) )
+        if ( rtl_random_getBytes( nullptr, bytes, std::size( bytes ) )
             != rtl_Random_E_None )
             throw BootstrapException( "random pool error!" );
-        rtl_random_destroyPool( hPool );
         OUStringBuffer buf("uno");
         for (unsigned char byte : bytes)
             buf.append( static_cast< sal_Int32 >( byte ) );
diff --git a/desktop/source/deployment/misc/dp_misc.cxx 
b/desktop/source/deployment/misc/dp_misc.cxx
index 01fb414a7909..2954eef6d542 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -410,12 +410,9 @@ oslProcess raiseProcess(
 OUString generateRandomPipeId()
 {
     // compute some good pipe id:
-    static rtlRandomPool s_hPool = rtl_random_createPool();
-    if (s_hPool == nullptr)
-        throw RuntimeException( "cannot create random pool!?", nullptr );
     sal_uInt8 bytes[ 32 ];
     if (rtl_random_getBytes(
-            s_hPool, bytes, std::size(bytes) ) != rtl_Random_E_None) {
+            nullptr, bytes, std::size(bytes) ) != rtl_Random_E_None) {
         throw RuntimeException( "random pool error!?", nullptr );
     }
     OUStringBuffer buf;
diff --git a/include/rtl/random.h b/include/rtl/random.h
index bc43d8ca5563..1833fa362ce0 100644
--- a/include/rtl/random.h
+++ b/include/rtl/random.h
@@ -53,15 +53,29 @@ enum __rtl_RandomError
  */
 typedef enum __rtl_RandomError rtlRandomError;
 
+/** Retrieve random bytes
+    @param[in] Pool use NULL, non-NULL Random Pools are deprecated
+    @param[in,out] Buffer a buffer to receive the random bytes.
+    @param[in] Bytes the number of bytes to write to the buffer.
+    @retval rtl_Random_E_None upon success.
+ */
+SAL_DLLPUBLIC rtlRandomError SAL_CALL rtl_random_getBytes (
+    rtlRandomPool  Pool,
+    void          *Buffer,
+    sal_Size       Bytes
+) SAL_THROW_EXTERN_C();
+
 
 /** Create a Random Pool.
     @return initialized Random Pool, or NULL upon failure.
+    @deprecated Instead use rtl_random_getBytes with a NULL Pool
  */
 SAL_DLLPUBLIC rtlRandomPool SAL_CALL rtl_random_createPool (void) 
SAL_THROW_EXTERN_C();
 
 
 /** Destroy a Random Pool.
     @param[in] Pool a Random Pool.
+    @deprecated Instead use rtl_random_getBytes with a NULL Pool
  */
 SAL_DLLPUBLIC void SAL_CALL rtl_random_destroyPool (
     rtlRandomPool Pool
@@ -73,7 +87,8 @@ SAL_DLLPUBLIC void SAL_CALL rtl_random_destroyPool (
     @param[in] Buffer a buffer containing the bytes to add.
     @param[in] Bytes  the number of bytes to read from the buffer.
     @retval rtl_Random_E_None upon success.
-    @deprecated This now does nothing.
+    @deprecated This now does nothing, instead use rtl_random_getBytes with a
+    NULL Pool
  */
 SAL_DLLPUBLIC rtlRandomError SAL_CALL rtl_random_addBytes (
     rtlRandomPool  Pool,
@@ -82,18 +97,6 @@ SAL_DLLPUBLIC rtlRandomError SAL_CALL rtl_random_addBytes (
 ) SAL_THROW_EXTERN_C();
 
 
-/** Retrieve bytes from a Random Pool.
-    @param[in] Pool    a Random Pool.
-    @param[in,out] Buffer a buffer to receive the random bytes.
-    @param[in] Bytes the number of bytes to write to the buffer.
-    @retval rtl_Random_E_None upon success.
- */
-SAL_DLLPUBLIC rtlRandomError SAL_CALL rtl_random_getBytes (
-    rtlRandomPool  Pool,
-    void          *Buffer,
-    sal_Size       Bytes
-) SAL_THROW_EXTERN_C();
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/oox/source/crypto/Standard2007Engine.cxx 
b/oox/source/crypto/Standard2007Engine.cxx
index 9fe18ad17e0c..bcc3dc558ff3 100644
--- a/oox/source/crypto/Standard2007Engine.cxx
+++ b/oox/source/crypto/Standard2007Engine.cxx
@@ -27,12 +27,10 @@ namespace
 
 void lclRandomGenerateValues(sal_uInt8* aArray, sal_uInt32 aSize)
 {
-    rtlRandomPool aRandomPool = rtl_random_createPool();
-    if (rtl_random_getBytes(aRandomPool, aArray, aSize) != rtl_Random_E_None)
+    if (rtl_random_getBytes(nullptr, aArray, aSize) != rtl_Random_E_None)
     {
         throw css::uno::RuntimeException("rtl_random_getBytes failed");
     }
-    rtl_random_destroyPool(aRandomPool);
 }
 
 constexpr OUString lclCspName = u"Microsoft Enhanced RSA and AES Cryptographic 
Provider"_ustr;
diff --git a/package/inc/ZipPackageEntry.hxx b/package/inc/ZipPackageEntry.hxx
index f25cdc19bdc9..412b0d5f37f2 100644
--- a/package/inc/ZipPackageEntry.hxx
+++ b/package/inc/ZipPackageEntry.hxx
@@ -32,7 +32,6 @@
 #include <optional>
 #include <tuple>
 
-typedef void* rtlRandomPool;
 class ZipOutputStream;
 class ZipPackageFolder;
 
@@ -69,8 +68,7 @@ public:
                             ZipOutputStream & rZipOut,
                             const css::uno::Sequence < sal_Int8 >& 
rEncryptionKey,
                             ::std::optional<sal_Int32> oPBKDF2IterationCount,
-                            ::std::optional<::std::tuple<sal_Int32, sal_Int32, 
sal_Int32>> oArgon2Args,
-                            const rtlRandomPool &rRandomPool ) = 0;
+                            ::std::optional<::std::tuple<sal_Int32, sal_Int32, 
sal_Int32>> oArgon2Args) = 0;
 
     void clearParent()
     {
diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx
index 2b1b98191302..7598c25c304d 100644
--- a/package/inc/ZipPackageFolder.hxx
+++ b/package/inc/ZipPackageFolder.hxx
@@ -99,8 +99,7 @@ public:
                             ZipOutputStream & rZipOut,
                             const css::uno::Sequence < sal_Int8 >& 
rEncryptionKey,
                             ::std::optional<sal_Int32> oPBKDF2IterationCount,
-                            ::std::optional<::std::tuple<sal_Int32, sal_Int32, 
sal_Int32>> oArgon2Args,
-                            const rtlRandomPool &rRandomPool ) override;
+                            ::std::optional<::std::tuple<sal_Int32, sal_Int32, 
sal_Int32>> oArgon2Args) override;
 
     // Recursive functions
     /// @throws css::uno::RuntimeException
@@ -110,8 +109,7 @@ public:
             ZipOutputStream & rZipOut,
             const css::uno::Sequence< sal_Int8 > &rEncryptionKey,
             ::std::optional<sal_Int32> oPBKDF2IterationCount,
-            ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> 
oArgon2Args,
-            const rtlRandomPool & rRandomPool) const;
+            ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> 
oArgon2Args) const;
 
     // XNameContainer
     virtual void SAL_CALL insertByName( const OUString& aName, const 
css::uno::Any& aElement ) override;
diff --git a/package/inc/ZipPackageStream.hxx b/package/inc/ZipPackageStream.hxx
index 0cb52e88c892..a6f874b0d4d7 100644
--- a/package/inc/ZipPackageStream.hxx
+++ b/package/inc/ZipPackageStream.hxx
@@ -139,8 +139,7 @@ public:
                             ZipOutputStream & rZipOut,
                             const css::uno::Sequence < sal_Int8 >& 
rEncryptionKey,
                             ::std::optional<sal_Int32> oPBKDF2IterationCount,
-                            ::std::optional<::std::tuple<sal_Int32, sal_Int32, 
sal_Int32>> oArgon2Args,
-                            const rtlRandomPool &rRandomPool ) override;
+                            ::std::optional<::std::tuple<sal_Int32, sal_Int32, 
sal_Int32>> oArgon2Args) override;
 
     void setZipEntryOnLoading( const ZipEntry &rInEntry);
     void successfullyWritten( ZipEntry const *pEntry );
diff --git a/package/source/zippackage/ZipPackage.cxx 
b/package/source/zippackage/ZipPackage.cxx
index 0f3fa6ff7dba..913baff52056 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1216,28 +1216,6 @@ void ZipPackage::ConnectTo( const uno::Reference< 
io::XInputStream >& xInStream
         m_pZipFile.emplace(m_aMutexHolder, m_xContentStream, m_xContext, 
false);
 }
 
-namespace
-{
-    class RandomPool
-    {
-    private:
-        rtlRandomPool m_aRandomPool;
-    public:
-        RandomPool() : m_aRandomPool(rtl_random_createPool ())
-        {
-        }
-        rtlRandomPool get()
-        {
-            return m_aRandomPool;
-        }
-        ~RandomPool()
-        {
-            // Clean up random pool memory
-            rtl_random_destroyPool(m_aRandomPool);
-        }
-    };
-}
-
 uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
 {
     // In case the target local file does not exist or empty
@@ -1349,10 +1327,6 @@ uno::Reference< io::XInputStream > 
ZipPackage::writeTempFile()
         }
 
         {
-            // This will be used to generate random salt and initialisation 
vectors
-            // for encrypted streams
-            RandomPool aRandomPool;
-
             ::std::optional<sal_Int32> oPBKDF2IterationCount;
             ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> 
oArgon2Args;
 
@@ -1371,7 +1345,7 @@ uno::Reference< io::XInputStream > 
ZipPackage::writeTempFile()
 
             // call saveContents - it will recursively save sub-directories
             m_xRootFolder->saveContents("", aManList, aZipOut, 
GetEncryptionKey(),
-                oPBKDF2IterationCount, oArgon2Args, aRandomPool.get());
+                oPBKDF2IterationCount, oArgon2Args);
         }
 
         if( m_nFormat == embed::StorageFormats::PACKAGE )
diff --git a/package/source/zippackage/ZipPackageFolder.cxx 
b/package/source/zippackage/ZipPackageFolder.cxx
index bca4e46e1bc2..729b9a31a8df 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -232,8 +232,7 @@ bool ZipPackageFolder::saveChild(
         ZipOutputStream & rZipOut,
         const uno::Sequence < sal_Int8 >& rEncryptionKey,
         ::std::optional<sal_Int32> const oPBKDF2IterationCount,
-        ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> const 
oArgon2Args,
-        const rtlRandomPool &rRandomPool)
+        ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> const 
oArgon2Args)
 {
     uno::Sequence < PropertyValue > aPropSet (PKG_SIZE_NOENCR_MNFST);
     OUString sTempName = rPath + "/";
@@ -251,7 +250,7 @@ bool ZipPackageFolder::saveChild(
     else
         aPropSet.realloc( 0 );
 
-    saveContents(sTempName, rManList, rZipOut, rEncryptionKey, 
oPBKDF2IterationCount, oArgon2Args, rRandomPool);
+    saveContents(sTempName, rManList, rZipOut, rEncryptionKey, 
oPBKDF2IterationCount, oArgon2Args);
 
     // folder can have a mediatype only in package format
     if ( aPropSet.hasElements() && ( m_nFormat == 
embed::StorageFormats::PACKAGE ) )
@@ -266,8 +265,7 @@ void ZipPackageFolder::saveContents(
         ZipOutputStream & rZipOut,
         const uno::Sequence < sal_Int8 >& rEncryptionKey,
         ::std::optional<sal_Int32> const oPBKDF2IterationCount,
-        ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> const 
oArgon2Args,
-        const rtlRandomPool &rRandomPool ) const
+        ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> const 
oArgon2Args) const
 {
     if ( maContents.empty() && !rPath.isEmpty() && m_nFormat != 
embed::StorageFormats::OFOPXML )
     {
@@ -303,7 +301,7 @@ void ZipPackageFolder::saveContents(
         {
             bMimeTypeStreamStored = true;
             if (!aIter->second.pStream->saveChild(rPath + aIter->first, 
rManList, rZipOut,
-                    rEncryptionKey, oPBKDF2IterationCount, oArgon2Args, 
rRandomPool))
+                    rEncryptionKey, oPBKDF2IterationCount, oArgon2Args))
             {
                 throw uno::RuntimeException( THROW_WHERE );
             }
@@ -317,7 +315,7 @@ void ZipPackageFolder::saveContents(
             if (rInfo.bFolder)
             {
                 if (!rInfo.pFolder->saveChild(rPath + rShortName, rManList, 
rZipOut,
-                        rEncryptionKey, oPBKDF2IterationCount, oArgon2Args, 
rRandomPool))
+                        rEncryptionKey, oPBKDF2IterationCount, oArgon2Args))
                 {
                     throw uno::RuntimeException( THROW_WHERE );
                 }
@@ -325,7 +323,7 @@ void ZipPackageFolder::saveContents(
             else
             {
                 if (!rInfo.pStream->saveChild(rPath + rShortName, rManList, 
rZipOut,
-                        rEncryptionKey, oPBKDF2IterationCount, oArgon2Args, 
rRandomPool))
+                        rEncryptionKey, oPBKDF2IterationCount, oArgon2Args))
                 {
                     throw uno::RuntimeException( THROW_WHERE );
                 }
diff --git a/package/source/zippackage/ZipPackageStream.cxx 
b/package/source/zippackage/ZipPackageStream.cxx
index a5d4a0f7ce3d..35863f96c81f 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -452,8 +452,7 @@ bool ZipPackageStream::saveChild(
         ZipOutputStream & rZipOut,
         const uno::Sequence < sal_Int8 >& rEncryptionKey,
         ::std::optional<sal_Int32> const oPBKDF2IterationCount,
-        ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> const 
oArgon2Args,
-        const rtlRandomPool &rRandomPool)
+        ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> const 
oArgon2Args)
 {
     bool bSuccess = true;
 
@@ -592,11 +591,11 @@ bool ZipPackageStream::saveChild(
                 uno::Sequence<sal_Int8> aSalt(16);
                 // note: for GCM it's particularly important that IV is unique
                 uno::Sequence<sal_Int8> aVector(GetIVSize());
-                if (rtl_random_getBytes(rRandomPool, aSalt.getArray(), 16) != 
rtl_Random_E_None)
+                if (rtl_random_getBytes(nullptr, aSalt.getArray(), 16) != 
rtl_Random_E_None)
                 {
                     throw uno::RuntimeException("rtl_random_getBytes failed");
                 }
-                if (rtl_random_getBytes(rRandomPool, 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");
                 }
diff --git a/sal/rtl/random.cxx b/sal/rtl/random.cxx
index 8420d4ca8049..dd57103cfc8a 100644
--- a/sal/rtl/random.cxx
+++ b/sal/rtl/random.cxx
@@ -63,12 +63,11 @@ rtlRandomError SAL_CALL rtl_random_addBytes(
 }
 
 rtlRandomError SAL_CALL rtl_random_getBytes (
-    rtlRandomPool Pool, void *Buffer, sal_Size Bytes) SAL_THROW_EXTERN_C()
+    rtlRandomPool, void *Buffer, sal_Size Bytes) SAL_THROW_EXTERN_C()
 {
-    RandomPool_Impl *pImpl = static_cast< RandomPool_Impl* >(Pool);
     sal_uInt8 *pBuffer = static_cast< sal_uInt8* >(Buffer);
 
-    if (!pImpl || !pBuffer)
+    if (!pBuffer)
         return rtl_Random_E_Argument;
 
     if (!osl_get_system_random_data(static_cast<char*>(Buffer), Bytes))
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;
diff --git a/sc/source/filter/excel/xeroot.cxx 
b/sc/source/filter/excel/xeroot.cxx
index c1959767d97d..aac4ecc62938 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -315,13 +315,11 @@ uno::Sequence< beans::NamedValue > 
XclExpRoot::GenerateEncryptionData( std::u16s
 
     if ( !aPass.empty() && aPass.size() < 16 )
     {
-        rtlRandomPool aRandomPool = rtl_random_createPool ();
         sal_uInt8 pnDocId[16];
-        if (rtl_random_getBytes(aRandomPool, pnDocId, 16) != rtl_Random_E_None)
+        if (rtl_random_getBytes(nullptr, pnDocId, 16) != rtl_Random_E_None)
         {
             throw uno::RuntimeException("rtl_random_getBytes failed");
         }
-        rtl_random_destroyPool( aRandomPool );
 
         sal_uInt16 pnPasswd[16] = {};
         for( size_t nChar = 0; nChar < aPass.size(); ++nChar )
diff --git a/sc/source/filter/excel/xestream.cxx 
b/sc/source/filter/excel/xestream.cxx
index e4ae036ead48..443326462af3 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -563,12 +563,10 @@ void XclExpBiff8Encrypter::Init( const Sequence< 
NamedValue >& rEncryptionData )
     maCodec.GetDocId( mpnDocId );
 
     // generate the salt here
-    rtlRandomPool aRandomPool = rtl_random_createPool ();
-    if (rtl_random_getBytes(aRandomPool, mpnSalt, 16) != rtl_Random_E_None)
+    if (rtl_random_getBytes(nullptr, mpnSalt, 16) != rtl_Random_E_None)
     {
         throw uno::RuntimeException("rtl_random_getBytes failed");
     }
-    rtl_random_destroyPool( aRandomPool );
 
     memset( mpnSaltDigest, 0, sizeof( mpnSaltDigest ) );
 
diff --git a/stoc/source/javaloader/javaloader.cxx 
b/stoc/source/javaloader/javaloader.cxx
index e54ce9b2d776..b0cd09e2f21f 100644
--- a/stoc/source/javaloader/javaloader.cxx
+++ b/stoc/source/javaloader/javaloader.cxx
@@ -90,12 +90,9 @@ namespace {
 OUString generateRandomPipeId()
 {
     // compute some good pipe id:
-    static rtlRandomPool s_hPool = rtl_random_createPool();
-    if (s_hPool == nullptr)
-        throw RuntimeException( "cannot create random pool!?", nullptr );
     sal_uInt8 bytes[ 32 ];
     if (rtl_random_getBytes(
-            s_hPool, bytes, SAL_N_ELEMENTS(bytes) ) != rtl_Random_E_None) {
+            nullptr, bytes, SAL_N_ELEMENTS(bytes) ) != rtl_Random_E_None) {
         throw RuntimeException( "random pool error!?", nullptr );
     }
     OUStringBuffer buf;
diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx 
b/svl/source/passwordcontainer/passwordcontainer.cxx
index 90b27c29f7b0..d030b0a2cedf 100644
--- a/svl/source/passwordcontainer/passwordcontainer.cxx
+++ b/svl/source/passwordcontainer/passwordcontainer.cxx
@@ -652,9 +652,8 @@ void SAL_CALL PasswordContainer::addPersistent( const 
OUString& Url, const OUStr
 
 OUString PasswordContainer::createIV()
 {
-    rtlRandomPool randomPool = mRandomPool.get();
     unsigned char iv[RTL_DIGEST_LENGTH_MD5];
-    if (rtl_random_getBytes(randomPool, iv, RTL_DIGEST_LENGTH_MD5) != 
rtl_Random_E_None)
+    if (rtl_random_getBytes(nullptr, iv, RTL_DIGEST_LENGTH_MD5) != 
rtl_Random_E_None)
     {
         throw uno::RuntimeException("rtl_random_getBytes failed");
     }
diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx 
b/svl/source/passwordcontainer/passwordcontainer.hxx
index 80fae574f175..2dbed6ee1399 100644
--- a/svl/source/passwordcontainer/passwordcontainer.hxx
+++ b/svl/source/passwordcontainer/passwordcontainer.hxx
@@ -245,28 +245,7 @@ private:
     css::uno::Reference< css::lang::XComponent > mComponent;
     SysCredentialsConfig mUrlContainer;
 
-    class RandomPool
-    {
-    private:
-        rtlRandomPool m_aRandomPool;
-    public:
-        RandomPool() : m_aRandomPool(rtl_random_createPool())
-        {
-        }
-        rtlRandomPool get()
-        {
-            return m_aRandomPool;
-        }
-        ~RandomPool()
-        {
-            // Clean up random pool memory
-            rtl_random_destroyPool(m_aRandomPool);
-        }
-    };
-
-    RandomPool mRandomPool;
-
-    OUString createIV();
+    static OUString createIV();
 
     /// @throws css::uno::RuntimeException
     css::uno::Sequence< css::task::UserRecord > CopyToUserRecordSequence(
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index d79876eb5524..32581a995a9c 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3515,13 +3515,11 @@ bool SwWW8Writer::InitStd97CodecUpdateMedium( 
::msfilter::MSCodec_Std97& rCodec
             if ( pPasswordItem && !pPasswordItem->GetValue().isEmpty() && 
pPasswordItem->GetValue().getLength() <= 15 )
             {
                 // Generate random number with a seed of time as salt.
-                rtlRandomPool aRandomPool = rtl_random_createPool ();
                 sal_uInt8 pDocId[ 16 ];
-                if (rtl_random_getBytes(aRandomPool, pDocId, 16) != 
rtl_Random_E_None)
+                if (rtl_random_getBytes(nullptr, pDocId, 16) != 
rtl_Random_E_None)
                 {
                     throw uno::RuntimeException("rtl_random_getBytes failed");
                 }
-                rtl_random_destroyPool( aRandomPool );
 
                 sal_uInt16 aPassword[16] = {};
 
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index a2d959d7d3f7..c88990a5f663 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5672,13 +5672,11 @@ namespace
                 // in the MediaDescriptor
                 ::msfilter::MSCodec_Std97 aCodec97;
 
-                rtlRandomPool aRandomPool = rtl_random_createPool();
                 sal_uInt8 pDocId[ 16 ];
-                if (rtl_random_getBytes(aRandomPool, pDocId, 16) != 
rtl_Random_E_None)
+                if (rtl_random_getBytes(nullptr, pDocId, 16) != 
rtl_Random_E_None)
                 {
                     throw uno::RuntimeException("rtl_random_getBytes failed");
                 }
-                rtl_random_destroyPool( aRandomPool );
 
                 sal_uInt16 pStd97Pass[16] = {};
                 for( sal_Int32 nChar = 0; nChar < nLen; ++nChar )
diff --git a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx 
b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
index e5f2a89d113d..c6031b7e1566 100644
--- a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
+++ b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
@@ -325,12 +325,10 @@ uno::Sequence< ::sal_Int8 > SAL_CALL 
OCipherContext::finalizeCipherContextAndDis
 
         if ( nPaddingSize > 1 )
         {
-            rtlRandomPool aRandomPool = rtl_random_createPool();
-            if (rtl_random_getBytes(aRandomPool, pLastBlock + 
nOldLastBlockLen, nPaddingSize - 1) != rtl_Random_E_None)
+            if (rtl_random_getBytes(nullptr, pLastBlock + nOldLastBlockLen, 
nPaddingSize - 1) != rtl_Random_E_None)
             {
                 throw uno::RuntimeException("rtl_random_getBytes failed");
             }
-            rtl_random_destroyPool ( aRandomPool );
         }
         pLastBlock[m_aLastBlock.getLength() - 1] = static_cast< sal_Int8 >( 
nPaddingSize );
     }

Reply via email to