From f44becfdb8bc0dad2d3ec7abd3aaa889d9e0bfea Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Wed, 20 Nov 2024 18:41:35 +0900 Subject: pdf: add function to pad the vector as required by PDF specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7196ad523b3084124a3b03fb2e4998d42fd91779 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176883 Reviewed-by: Miklos Vajna Tested-by: Jenkins CollaboraOffice Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178757 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- vcl/source/pdf/PDFEncryptorR6.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'vcl/source') diff --git a/vcl/source/pdf/PDFEncryptorR6.cxx b/vcl/source/pdf/PDFEncryptorR6.cxx index b3850a5929f8..b3e6f9e3059e 100644 --- a/vcl/source/pdf/PDFEncryptorR6.cxx +++ b/vcl/source/pdf/PDFEncryptorR6.cxx @@ -238,6 +238,17 @@ std::vector computeHashR6(const sal_uInt8* pPassword, size_t nPasswor return std::vector(K.begin(), K.begin() + 32); } +size_t addPaddingToVector(std::vector& rVector, size_t nBlockSize) +{ + size_t nPaddedSize = comphelper::roundUp(rVector.size(), size_t(nBlockSize)); + if (nPaddedSize > rVector.size()) + { + sal_uInt8 nPaddedValue = sal_uInt8(nPaddedSize - rVector.size()); + rVector.resize(nPaddedSize, nPaddedValue); + } + return nPaddedSize; +} + } // end vcl::pdf /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit