From c83b09ab19e72818f38266808e109efd0f1f64c0 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Thu, 7 Dec 2017 23:44:03 +0100 Subject: rtlRandomPool: remove pointless seeding with system time Change-Id: I88647a66a72d092303560a4348ce3dc55ee6c321 Reviewed-on: https://gerrit.libreoffice.org/46055 Tested-by: Jenkins Reviewed-by: Michael Stahl --- comphelper/source/misc/docpasswordhelper.cxx | 3 --- comphelper/source/misc/storagehelper.cxx | 4 ---- oox/source/crypto/Standard2007Engine.cxx | 3 --- package/source/zippackage/ZipPackage.cxx | 4 ---- sc/source/filter/excel/xeroot.cxx | 4 ---- sc/source/filter/excel/xestream.cxx | 3 --- sw/source/filter/ww8/wrtww8.cxx | 4 ---- sw/source/filter/ww8/ww8par.cxx | 5 ----- xmlsecurity/source/xmlsec/nss/ciphercontext.cxx | 3 --- 9 files changed, 33 deletions(-) diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx index 7d761bb9c740..79af2be034d6 100644 --- a/comphelper/source/misc/docpasswordhelper.cxx +++ b/comphelper/source/misc/docpasswordhelper.cxx @@ -248,10 +248,7 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence( { uno::Sequence< sal_Int8 > aResult( nLength ); - TimeValue aTime; - osl_getSystemTime( &aTime ); rtlRandomPool aRandomPool = rtl_random_createPool (); - rtl_random_addBytes ( aRandomPool, &aTime, 8 ); rtl_random_getBytes ( aRandomPool, aResult.getArray(), nLength ); rtl_random_destroyPool ( aRandomPool ); diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index d51055211e8a..a6f2109ba37e 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -436,11 +436,7 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat // generate session key // -------------------- - // Get a random number generator and seed it with current timestamp - TimeValue aTime; - osl_getSystemTime( &aTime ); rtlRandomPool aRandomPool = rtl_random_createPool(); - rtl_random_addBytes(aRandomPool, &aTime, 8); // get 16 random chars out of it uno::Sequence < sal_Int8 > aVector(16); diff --git a/oox/source/crypto/Standard2007Engine.cxx b/oox/source/crypto/Standard2007Engine.cxx index 748911612a8f..c70b120e3666 100644 --- a/oox/source/crypto/Standard2007Engine.cxx +++ b/oox/source/crypto/Standard2007Engine.cxx @@ -30,10 +30,7 @@ namespace void lclRandomGenerateValues(sal_uInt8* aArray, sal_uInt32 aSize) { - TimeValue aTime; - osl_getSystemTime(&aTime); rtlRandomPool aRandomPool = rtl_random_createPool(); - rtl_random_addBytes(aRandomPool, &aTime, 8); rtl_random_getBytes(aRandomPool, aArray, aSize); rtl_random_destroyPool(aRandomPool); } diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 769c7f662bba..faf6c9dedceb 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -1100,11 +1100,7 @@ namespace public: RandomPool() { - // Get a random number generator and seed it with current timestamp - TimeValue aTime; - osl_getSystemTime( &aTime ); m_aRandomPool = rtl_random_createPool (); - rtl_random_addBytes (m_aRandomPool, &aTime, 8); } rtlRandomPool get() { diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx index b9de58daf698..d7957dcc2e08 100644 --- a/sc/source/filter/excel/xeroot.cxx +++ b/sc/source/filter/excel/xeroot.cxx @@ -314,11 +314,7 @@ uno::Sequence< beans::NamedValue > XclExpRoot::GenerateEncryptionData( const OUS if ( !aPass.isEmpty() && aPass.getLength() < 16 ) { - TimeValue aTime; - osl_getSystemTime( &aTime ); rtlRandomPool aRandomPool = rtl_random_createPool (); - rtl_random_addBytes ( aRandomPool, &aTime, 8 ); - sal_uInt8 pnDocId[16]; rtl_random_getBytes( aRandomPool, pnDocId, 16 ); diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index 94ff1308dd6d..bd165ceb279e 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -547,10 +547,7 @@ void XclExpBiff8Encrypter::Init( const Sequence< NamedValue >& rEncryptionData ) maCodec.GetDocId( mpnDocId ); // generate the salt here - TimeValue aTime; - osl_getSystemTime( &aTime ); rtlRandomPool aRandomPool = rtl_random_createPool (); - rtl_random_addBytes( aRandomPool, &aTime, 8 ); rtl_random_getBytes( aRandomPool, mpnSalt, 16 ); rtl_random_destroyPool( aRandomPool ); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 12a8ef8b6f89..8c6df1deafee 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3230,11 +3230,7 @@ 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. - TimeValue aTime; - osl_getSystemTime( &aTime ); rtlRandomPool aRandomPool = rtl_random_createPool (); - rtl_random_addBytes ( aRandomPool, &aTime, 8 ); - sal_uInt8 pDocId[ 16 ]; rtl_random_getBytes( aRandomPool, pDocId, 16 ); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 4e7b346a90fd..a60a0971f687 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -5589,12 +5589,7 @@ namespace // in the MediaDescriptor ::msfilter::MSCodec_Std97 aCodec97; - // Generate random number with a seed of time as salt. - TimeValue aTime; - osl_getSystemTime( &aTime ); rtlRandomPool aRandomPool = rtl_random_createPool(); - rtl_random_addBytes ( aRandomPool, &aTime, 8 ); - sal_uInt8 pDocId[ 16 ]; rtl_random_getBytes( aRandomPool, pDocId, 16 ); diff --git a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx index a3a29e20d6a0..d7d7d951adf4 100644 --- a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx +++ b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx @@ -203,10 +203,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL OCipherContext::finalizeCipherContextAndDis if ( nPaddingSize > 1 ) { - TimeValue aTime; - osl_getSystemTime( &aTime ); rtlRandomPool aRandomPool = rtl_random_createPool(); - rtl_random_addBytes( aRandomPool, &aTime, 8 ); rtl_random_getBytes( aRandomPool, m_aLastBlock.getArray() + nOldLastBlockLen, nPaddingSize - 1 ); rtl_random_destroyPool ( aRandomPool ); } -- cgit