From 0e5278816cbc82911700b6d9fc557b42e0382eb5 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Wed, 2 Aug 2017 17:19:17 -0400 Subject: Replace CFX_ByteTextBuf from cpdf_security_handler.cpp with std::vector Bug: pdfium:731 Change-Id: I63532e06aa2c135f34a6adda24ae1cfbc5922ac9 Reviewed-on: https://pdfium-review.googlesource.com/9871 Reviewed-by: Tom Sepez Commit-Queue: Henrique Nakashima --- core/fpdfapi/parser/cpdf_security_handler.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp index 4cdf545d63..03b90abf4a 100644 --- a/core/fpdfapi/parser/cpdf_security_handler.cpp +++ b/core/fpdfapi/parser/cpdf_security_handler.cpp @@ -240,13 +240,13 @@ void Revision6_Hash(const uint8_t* password, uint8_t digest[32]; CRYPT_SHA256Finish(&sha, digest); - CFX_ByteTextBuf buf; + std::vector buf; uint8_t* input = digest; uint8_t* key = input; uint8_t* iv = input + 16; - uint8_t* E = buf.GetBuffer(); - int iBufLen = buf.GetLength(); - CFX_ByteTextBuf interDigest; + uint8_t* E = nullptr; + int iBufLen = 0; + std::vector interDigest; int i = 0; int iBlockSize = 32; CRYPT_aes_context aes; @@ -257,19 +257,19 @@ void Revision6_Hash(const uint8_t* password, iRoundSize += 48; } iBufLen = iRoundSize * 64; - buf.EstimateSize(iBufLen); - E = buf.GetBuffer(); - CFX_ByteTextBuf content; + buf.resize(iBufLen); + E = buf.data(); + std::vector content; for (int j = 0; j < 64; ++j) { - content.AppendBlock(password, size); - content.AppendBlock(input, iBlockSize); + content.insert(std::end(content), password, password + size); + content.insert(std::end(content), input, input + iBlockSize); if (vector) { - content.AppendBlock(vector, 48); + content.insert(std::end(content), vector, vector + 48); } } CRYPT_AESSetKey(&aes, 16, key, 16, true); CRYPT_AESSetIV(&aes, iv); - CRYPT_AESEncrypt(&aes, E, content.GetBuffer(), iBufLen); + CRYPT_AESEncrypt(&aes, E, content.data(), iBufLen); int iHash = 0; switch (BigOrder64BitsMod3(E)) { case 0: @@ -285,8 +285,8 @@ void Revision6_Hash(const uint8_t* password, iBlockSize = 64; break; } - interDigest.EstimateSize(iBlockSize); - input = interDigest.GetBuffer(); + interDigest.resize(iBlockSize); + input = interDigest.data(); if (iHash == 0) { CRYPT_SHA256Generate(E, iBufLen, input); } else if (iHash == 1) { -- cgit v1.2.3