oox,svl,vcl: use more appropriate random numbers
Signed-off-by: Michael Stahl <michael.stahl@collabora.com> Change-Id: I9d6f200cc5a146f46dca64af270b77d0ce6abf6b Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/8174 Tested-by: Jenkins CPCI <releng@collaboraoffice.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> (cherry picked from commit 52ba487c3d84a89a027c3130bc86afdcfe57a860) Reviewed-on: https://gerrit.collaboraoffice.com/c/core/+/8261 Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com> (cherry picked from commit 63ab1f905bddbac4871a246d61aa59d09f122e5c) Reviewed-on: https://gerrit.collaboraoffice.com/c/core/+/8277 (cherry picked from commit 396747a0e319943e7d411b0d6bc8d8abcc3e4f19) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209276 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Tested-by: Jenkins
This commit is contained in:
committed by
Xisco Fauli
parent
91a42a804c
commit
aac2961770
@@ -20,12 +20,12 @@
|
||||
|
||||
#include <comphelper/hash.hxx>
|
||||
#include <comphelper/docpasswordhelper.hxx>
|
||||
#include <comphelper/random.hxx>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <comphelper/base64.hxx>
|
||||
#include <comphelper/sequence.hxx>
|
||||
|
||||
#include <filter/msfilter/mscodec.hxx>
|
||||
#include <rtl/random.h>
|
||||
#include <tools/stream.hxx>
|
||||
#include <tools/XmlWriter.hxx>
|
||||
#include <sax/fastattribs.hxx>
|
||||
@@ -318,12 +318,13 @@ namespace
|
||||
|
||||
bool generateBytes(std::vector<sal_uInt8> & rBytes, sal_Int32 nSize)
|
||||
{
|
||||
assert(0 <= nSize && o3tl::make_unsigned(nSize) <= rBytes.size());
|
||||
if (nSize <= 0)
|
||||
return false;
|
||||
|
||||
size_t nMax = std::min(rBytes.size(), size_t(nSize));
|
||||
|
||||
for (size_t i = 0; i < nMax; ++i)
|
||||
{
|
||||
rBytes[i] = sal_uInt8(comphelper::rng::uniform_uint_distribution(0, 0xFF));
|
||||
}
|
||||
rtl_random_getBytes(nullptr, rBytes.data(), nMax);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include <rtl/character.hxx>
|
||||
#include <rtl/random.h>
|
||||
#include <rtl/strbuf.hxx>
|
||||
#include <rtl/string.hxx>
|
||||
#include <sal/log.hxx>
|
||||
@@ -30,7 +31,6 @@
|
||||
#include <comphelper/base64.hxx>
|
||||
#include <comphelper/hash.hxx>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <comphelper/random.hxx>
|
||||
#include <comphelper/scopeguard.hxx>
|
||||
#include <comphelper/lok.hxx>
|
||||
#include <com/sun/star/security/XCertificate.hpp>
|
||||
@@ -1086,7 +1086,8 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
|
||||
src.reqPolicy.data = nullptr;
|
||||
src.reqPolicy.len = 0;
|
||||
|
||||
unsigned int nNonce = comphelper::rng::uniform_uint_distribution(0, SAL_MAX_UINT32);
|
||||
unsigned int nNonce;
|
||||
rtl_random_getBytes(nullptr, &nNonce, sizeof(nNonce));
|
||||
src.nonce.type = siUnsignedInteger;
|
||||
src.nonce.data = reinterpret_cast<unsigned char*>(&nNonce);
|
||||
src.nonce.len = sizeof(nNonce);
|
||||
@@ -1481,7 +1482,8 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
|
||||
CMSG_SIGNER_INFO *pDecodedSignerInfo = reinterpret_cast<CMSG_SIGNER_INFO *>(pDecodedSignerInfoBuf.get());
|
||||
|
||||
CRYPT_TIMESTAMP_PARA aTsPara;
|
||||
unsigned int nNonce = comphelper::rng::uniform_uint_distribution(0, SAL_MAX_UINT32);
|
||||
unsigned int nNonce;
|
||||
rtl_random_getBytes(nullptr, &nNonce, sizeof(nNonce));
|
||||
|
||||
aTsPara.pszTSAPolicyId = nullptr;
|
||||
aTsPara.fRequestCerts = TRUE;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <vcl/pdfwriter.hxx>
|
||||
#include <comphelper/crypto/Crypto.hxx>
|
||||
#include <comphelper/hash.hxx>
|
||||
#include <comphelper/random.hxx>
|
||||
#include <comphelper/diagnose_ex.hxx>
|
||||
#include <array>
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <pdf/pdfwriter_impl.hxx>
|
||||
#include <comphelper/crypto/Crypto.hxx>
|
||||
#include <comphelper/hash.hxx>
|
||||
#include <comphelper/random.hxx>
|
||||
#include <rtl/random.h>
|
||||
|
||||
using namespace css;
|
||||
|
||||
@@ -38,8 +38,10 @@ void generateBytes(std::vector<sal_uInt8>& rBytes, size_t nSize)
|
||||
{
|
||||
rBytes.resize(nSize);
|
||||
|
||||
for (size_t i = 0; i < rBytes.size(); ++i)
|
||||
rBytes[i] = sal_uInt8(comphelper::rng::uniform_uint_distribution(0, 0xFF));
|
||||
if (rBytes.empty())
|
||||
return;
|
||||
|
||||
rtl_random_getBytes(nullptr, rBytes.data(), rBytes.size());
|
||||
}
|
||||
|
||||
} // end anonymous
|
||||
|
||||
Reference in New Issue
Block a user