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

Side by Side Diff: core/src/fdrm/crypto/fx_crypt_sha.cpp

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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/include/fxcrt/fx_basic.h ('k') | core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.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/include/fdrm/fx_crypt.h" 7 #include "core/include/fdrm/fx_crypt.h"
8 8
9 #ifdef __cplusplus 9 #ifdef __cplusplus
10 extern "C" { 10 extern "C" {
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 ret |= (str[i] - 'a' + 10) & 0xFF; 383 ret |= (str[i] - 'a' + 10) & 0xFF;
384 } else if (str[i] >= 'A' && str[i] <= 'F') { 384 } else if (str[i] >= 'A' && str[i] <= 'F') {
385 ret |= (str[i] - 'A' + 10) & 0xFF; 385 ret |= (str[i] - 'A' + 10) & 0xFF;
386 } else { 386 } else {
387 FXSYS_assert(FALSE); 387 FXSYS_assert(FALSE);
388 } 388 }
389 } 389 }
390 return ret; 390 return ret;
391 } 391 }
392 void CRYPT_SHA384Start(void* context) { 392 void CRYPT_SHA384Start(void* context) {
393 if (context == NULL) { 393 if (!context) {
394 return; 394 return;
395 } 395 }
396 sha384_context* ctx = (sha384_context*)context; 396 sha384_context* ctx = (sha384_context*)context;
397 FXSYS_memset(ctx, 0, sizeof(sha384_context)); 397 FXSYS_memset(ctx, 0, sizeof(sha384_context));
398 ctx->state[0] = FX_ato64i("cbbb9d5dc1059ed8"); 398 ctx->state[0] = FX_ato64i("cbbb9d5dc1059ed8");
399 ctx->state[1] = FX_ato64i("629a292a367cd507"); 399 ctx->state[1] = FX_ato64i("629a292a367cd507");
400 ctx->state[2] = FX_ato64i("9159015a3070dd17"); 400 ctx->state[2] = FX_ato64i("9159015a3070dd17");
401 ctx->state[3] = FX_ato64i("152fecd8f70e5939"); 401 ctx->state[3] = FX_ato64i("152fecd8f70e5939");
402 ctx->state[4] = FX_ato64i("67332667ffc00b31"); 402 ctx->state[4] = FX_ato64i("67332667ffc00b31");
403 ctx->state[5] = FX_ato64i("8eb44a8768581511"); 403 ctx->state[5] = FX_ato64i("8eb44a8768581511");
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 597 }
598 void CRYPT_SHA384Generate(const uint8_t* data, 598 void CRYPT_SHA384Generate(const uint8_t* data,
599 FX_DWORD size, 599 FX_DWORD size,
600 uint8_t digest[64]) { 600 uint8_t digest[64]) {
601 sha384_context context; 601 sha384_context context;
602 CRYPT_SHA384Start(&context); 602 CRYPT_SHA384Start(&context);
603 CRYPT_SHA384Update(&context, data, size); 603 CRYPT_SHA384Update(&context, data, size);
604 CRYPT_SHA384Finish(&context, digest); 604 CRYPT_SHA384Finish(&context, digest);
605 } 605 }
606 void CRYPT_SHA512Start(void* context) { 606 void CRYPT_SHA512Start(void* context) {
607 if (context == NULL) { 607 if (!context) {
608 return; 608 return;
609 } 609 }
610 sha384_context* ctx = (sha384_context*)context; 610 sha384_context* ctx = (sha384_context*)context;
611 FXSYS_memset(ctx, 0, sizeof(sha384_context)); 611 FXSYS_memset(ctx, 0, sizeof(sha384_context));
612 ctx->state[0] = FX_ato64i("6a09e667f3bcc908"); 612 ctx->state[0] = FX_ato64i("6a09e667f3bcc908");
613 ctx->state[1] = FX_ato64i("bb67ae8584caa73b"); 613 ctx->state[1] = FX_ato64i("bb67ae8584caa73b");
614 ctx->state[2] = FX_ato64i("3c6ef372fe94f82b"); 614 ctx->state[2] = FX_ato64i("3c6ef372fe94f82b");
615 ctx->state[3] = FX_ato64i("a54ff53a5f1d36f1"); 615 ctx->state[3] = FX_ato64i("a54ff53a5f1d36f1");
616 ctx->state[4] = FX_ato64i("510e527fade682d1"); 616 ctx->state[4] = FX_ato64i("510e527fade682d1");
617 ctx->state[5] = FX_ato64i("9b05688c2b3e6c1f"); 617 ctx->state[5] = FX_ato64i("9b05688c2b3e6c1f");
(...skipping 30 matching lines...) Expand all
648 FX_DWORD size, 648 FX_DWORD size,
649 uint8_t digest[64]) { 649 uint8_t digest[64]) {
650 sha384_context context; 650 sha384_context context;
651 CRYPT_SHA512Start(&context); 651 CRYPT_SHA512Start(&context);
652 CRYPT_SHA512Update(&context, data, size); 652 CRYPT_SHA512Update(&context, data, size);
653 CRYPT_SHA512Finish(&context, digest); 653 CRYPT_SHA512Finish(&context, digest);
654 } 654 }
655 #ifdef __cplusplus 655 #ifdef __cplusplus
656 }; 656 };
657 #endif 657 #endif
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_basic.h ('k') | core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698