From 6facd15a7ecfbae24f2c356fa3b358288120a6f2 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 16 May 2018 17:07:02 +0000 Subject: Use pdfium::span<> in cpdf_creator. Change-Id: I959fe5dc30fcfe2176c7e5a64b07d082313a22b4 Reviewed-on: https://pdfium-review.googlesource.com/32595 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- core/fpdfapi/parser/cpdf_crypto_handler.cpp | 20 +++++++++----------- core/fpdfapi/parser/cpdf_crypto_handler.h | 7 +++---- 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'core/fpdfapi/parser') diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp index fa784668fa..f0bf1139fd 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp +++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp @@ -375,23 +375,21 @@ bool CPDF_CryptoHandler::DecryptStream(void* context, bool CPDF_CryptoHandler::DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) { return CryptFinish(context, dest_buf, false); } -uint32_t CPDF_CryptoHandler::EncryptGetSize(uint32_t objnum, - uint32_t version, - const uint8_t* src_buf, - uint32_t src_size) { - if (m_Cipher == FXCIPHER_AES) { - return src_size + 32; - } - return src_size; + +uint32_t CPDF_CryptoHandler::EncryptGetSize( + uint32_t objnum, + uint32_t version, + pdfium::span source) const { + return m_Cipher == FXCIPHER_AES ? source.size() + 32 : source.size(); } bool CPDF_CryptoHandler::EncryptContent(uint32_t objnum, uint32_t gennum, - const uint8_t* src_buf, - uint32_t src_size, + pdfium::span source, uint8_t* dest_buf, uint32_t& dest_size) { - CryptBlock(true, objnum, gennum, src_buf, src_size, dest_buf, dest_size); + CryptBlock(true, objnum, gennum, source.data(), source.size(), dest_buf, + dest_size); return true; } diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.h b/core/fpdfapi/parser/cpdf_crypto_handler.h index 1ca2130717..23dfe4aae1 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.h +++ b/core/fpdfapi/parser/cpdf_crypto_handler.h @@ -15,6 +15,7 @@ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" #include "core/fxcrt/retain_ptr.h" +#include "third_party/base/span.h" class CPDF_Dictionary; class CPDF_Object; @@ -32,12 +33,10 @@ class CPDF_CryptoHandler { uint32_t EncryptGetSize(uint32_t objnum, uint32_t version, - const uint8_t* src_buf, - uint32_t src_size); + pdfium::span source) const; bool EncryptContent(uint32_t objnum, uint32_t version, - const uint8_t* src_buf, - uint32_t src_size, + pdfium::span source, uint8_t* dest_buf, uint32_t& dest_size); -- cgit v1.2.3