Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp

Issue 1853233002: Make down-conversion explicit from CFX_ByteString to CFX_ByteStringC. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix CPDF_Name::GetConstString() Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_parser.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_string.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h" 7 #include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 return TRUE; 160 return TRUE;
161 } 161 }
162 162
163 FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) { 163 FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
164 m_pEncryptDict = pEncryptDict; 164 m_pEncryptDict = pEncryptDict;
165 m_Version = pEncryptDict->GetIntegerBy("V"); 165 m_Version = pEncryptDict->GetIntegerBy("V");
166 m_Revision = pEncryptDict->GetIntegerBy("R"); 166 m_Revision = pEncryptDict->GetIntegerBy("R");
167 m_Permissions = pEncryptDict->GetIntegerBy("P", -1); 167 m_Permissions = pEncryptDict->GetIntegerBy("P", -1);
168 if (m_Version < 4) { 168 if (m_Version < 4) {
169 return _LoadCryptInfo(pEncryptDict, CFX_ByteString(), m_Cipher, m_KeyLen); 169 return _LoadCryptInfo(pEncryptDict, CFX_ByteStringC(), m_Cipher, m_KeyLen);
170 } 170 }
171 CFX_ByteString stmf_name = pEncryptDict->GetStringBy("StmF"); 171 CFX_ByteString stmf_name = pEncryptDict->GetStringBy("StmF");
172 CFX_ByteString strf_name = pEncryptDict->GetStringBy("StrF"); 172 CFX_ByteString strf_name = pEncryptDict->GetStringBy("StrF");
173 if (stmf_name != strf_name) { 173 if (stmf_name != strf_name) {
174 return FALSE; 174 return FALSE;
175 } 175 }
176 if (!_LoadCryptInfo(pEncryptDict, strf_name, m_Cipher, m_KeyLen)) { 176 if (!_LoadCryptInfo(pEncryptDict, strf_name.AsByteStringC(), m_Cipher,
177 m_KeyLen)) {
177 return FALSE; 178 return FALSE;
178 } 179 }
179 return TRUE; 180 return TRUE;
180 } 181 }
181 182
182 FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict, 183 FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
183 uint32_t type, 184 uint32_t type,
184 int& cipher, 185 int& cipher,
185 int& key_len) { 186 int& key_len) {
186 m_pEncryptDict = pEncryptDict; 187 m_pEncryptDict = pEncryptDict;
187 m_Version = pEncryptDict->GetIntegerBy("V"); 188 m_Version = pEncryptDict->GetIntegerBy("V");
188 m_Revision = pEncryptDict->GetIntegerBy("R"); 189 m_Revision = pEncryptDict->GetIntegerBy("R");
189 m_Permissions = pEncryptDict->GetIntegerBy("P", -1); 190 m_Permissions = pEncryptDict->GetIntegerBy("P", -1);
190 CFX_ByteString strf_name, stmf_name; 191 CFX_ByteString strf_name, stmf_name;
191 if (m_Version >= 4) { 192 if (m_Version >= 4) {
192 stmf_name = pEncryptDict->GetStringBy("StmF"); 193 stmf_name = pEncryptDict->GetStringBy("StmF");
193 strf_name = pEncryptDict->GetStringBy("StrF"); 194 strf_name = pEncryptDict->GetStringBy("StrF");
194 if (stmf_name != strf_name) { 195 if (stmf_name != strf_name) {
195 return FALSE; 196 return FALSE;
196 } 197 }
197 } 198 }
198 if (!_LoadCryptInfo(pEncryptDict, strf_name, cipher, key_len)) { 199 if (!_LoadCryptInfo(pEncryptDict, strf_name.AsByteStringC(), cipher,
200 key_len)) {
199 return FALSE; 201 return FALSE;
200 } 202 }
201 m_Cipher = cipher; 203 m_Cipher = cipher;
202 m_KeyLen = key_len; 204 m_KeyLen = key_len;
203 return TRUE; 205 return TRUE;
204 } 206 }
205 207
206 FX_BOOL CPDF_StandardSecurityHandler::GetCryptInfo(int& cipher, 208 FX_BOOL CPDF_StandardSecurityHandler::GetCryptInfo(int& cipher,
207 const uint8_t*& buffer, 209 const uint8_t*& buffer,
208 int& keylen) { 210 int& keylen) {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 buf[11] = 'b'; 707 buf[11] = 'b';
706 uint8_t* aes = FX_Alloc(uint8_t, 2048); 708 uint8_t* aes = FX_Alloc(uint8_t, 2048);
707 CRYPT_AESSetKey(aes, 16, key, 32, TRUE); 709 CRYPT_AESSetKey(aes, 16, key, 32, TRUE);
708 uint8_t iv[16], buf1[16]; 710 uint8_t iv[16], buf1[16];
709 FXSYS_memset(iv, 0, 16); 711 FXSYS_memset(iv, 0, 16);
710 CRYPT_AESSetIV(aes, iv); 712 CRYPT_AESSetIV(aes, iv);
711 CRYPT_AESEncrypt(aes, buf1, buf, 16); 713 CRYPT_AESEncrypt(aes, buf1, buf, 16);
712 FX_Free(aes); 714 FX_Free(aes);
713 pEncryptDict->SetAtString("Perms", CFX_ByteString(buf1, 16)); 715 pEncryptDict->SetAtString("Perms", CFX_ByteString(buf1, 16));
714 } 716 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_parser.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_string.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698