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

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

Issue 1999313002: Change CPDF_Boolean to use bool instead of FX_BOOL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@interform
Patch Set: rebase Created 4 years, 7 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
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_security_handler.h" 7 #include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 uint8_t* key, 505 uint8_t* key,
506 int32_t key_len) { 506 int32_t key_len) {
507 CFX_ByteString user_pass = GetUserPassword(password, pass_size, key_len); 507 CFX_ByteString user_pass = GetUserPassword(password, pass_size, key_len);
508 if (CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), FALSE, key, 508 if (CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), FALSE, key,
509 key_len)) { 509 key_len)) {
510 return TRUE; 510 return TRUE;
511 } 511 }
512 return CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), TRUE, 512 return CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), TRUE,
513 key, key_len); 513 key, key_len);
514 } 514 }
515 FX_BOOL CPDF_SecurityHandler::IsMetadataEncrypted() { 515
516 return m_pEncryptDict->GetBooleanBy("EncryptMetadata", TRUE); 516 bool CPDF_SecurityHandler::IsMetadataEncrypted() const {
517 return m_pEncryptDict->GetBooleanBy("EncryptMetadata", true);
517 } 518 }
518 519
519 void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, 520 void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
520 CPDF_Array* pIdArray, 521 CPDF_Array* pIdArray,
521 const uint8_t* user_pass, 522 const uint8_t* user_pass,
522 uint32_t user_size, 523 uint32_t user_size,
523 const uint8_t* owner_pass, 524 const uint8_t* owner_pass,
524 uint32_t owner_size, 525 uint32_t owner_size,
525 FX_BOOL bDefault, 526 FX_BOOL bDefault,
526 uint32_t type) { 527 uint32_t type) {
(...skipping 11 matching lines...) Expand all
538 CRYPT_SHA256Start(sha); 539 CRYPT_SHA256Start(sha);
539 CRYPT_SHA256Update(sha, (uint8_t*)&t, sizeof t); 540 CRYPT_SHA256Update(sha, (uint8_t*)&t, sizeof t);
540 CRYPT_SHA256Update(sha, m_EncryptKey, 32); 541 CRYPT_SHA256Update(sha, m_EncryptKey, 32);
541 CRYPT_SHA256Update(sha, (uint8_t*)"there", 5); 542 CRYPT_SHA256Update(sha, (uint8_t*)"there", 5);
542 CRYPT_SHA256Finish(sha, m_EncryptKey); 543 CRYPT_SHA256Finish(sha, m_EncryptKey);
543 AES256_SetPassword(pEncryptDict, user_pass, user_size, FALSE, m_EncryptKey); 544 AES256_SetPassword(pEncryptDict, user_pass, user_size, FALSE, m_EncryptKey);
544 if (bDefault) { 545 if (bDefault) {
545 AES256_SetPassword(pEncryptDict, owner_pass, owner_size, TRUE, 546 AES256_SetPassword(pEncryptDict, owner_pass, owner_size, TRUE,
546 m_EncryptKey); 547 m_EncryptKey);
547 AES256_SetPerms(pEncryptDict, m_Permissions, 548 AES256_SetPerms(pEncryptDict, m_Permissions,
548 pEncryptDict->GetBooleanBy("EncryptMetadata", TRUE), 549 pEncryptDict->GetBooleanBy("EncryptMetadata", true),
549 m_EncryptKey); 550 m_EncryptKey);
550 } 551 }
551 return; 552 return;
552 } 553 }
553 if (bDefault) { 554 if (bDefault) {
554 uint8_t passcode[32]; 555 uint8_t passcode[32];
555 uint32_t i; 556 uint32_t i;
556 for (i = 0; i < 32; i++) { 557 for (i = 0; i < 32; i++) {
557 passcode[i] = 558 passcode[i] =
558 i < owner_size ? owner_pass[i] : defpasscode[i - owner_size]; 559 i < owner_size ? owner_pass[i] : defpasscode[i - owner_size];
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 buf[11] = 'b'; 695 buf[11] = 'b';
695 uint8_t* aes = FX_Alloc(uint8_t, 2048); 696 uint8_t* aes = FX_Alloc(uint8_t, 2048);
696 CRYPT_AESSetKey(aes, 16, key, 32, TRUE); 697 CRYPT_AESSetKey(aes, 16, key, 32, TRUE);
697 uint8_t iv[16], buf1[16]; 698 uint8_t iv[16], buf1[16];
698 FXSYS_memset(iv, 0, 16); 699 FXSYS_memset(iv, 0, 16);
699 CRYPT_AESSetIV(aes, iv); 700 CRYPT_AESSetIV(aes, iv);
700 CRYPT_AESEncrypt(aes, buf1, buf, 16); 701 CRYPT_AESEncrypt(aes, buf1, buf, 16);
701 FX_Free(aes); 702 FX_Free(aes);
702 pEncryptDict->SetAtString("Perms", CFX_ByteString(buf1, 16)); 703 pEncryptDict->SetAtString("Perms", CFX_ByteString(buf1, 16));
703 } 704 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_security_handler.h ('k') | core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698