OLD | NEW |
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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 CRYPT_SHA256Start(&ctx); | 362 CRYPT_SHA256Start(&ctx); |
363 CRYPT_SHA256Update(&ctx, data, size); | 363 CRYPT_SHA256Update(&ctx, data, size); |
364 CRYPT_SHA256Finish(&ctx, digest); | 364 CRYPT_SHA256Finish(&ctx, digest); |
365 } | 365 } |
366 typedef struct { | 366 typedef struct { |
367 uint64_t total[2]; | 367 uint64_t total[2]; |
368 uint64_t state[8]; | 368 uint64_t state[8]; |
369 uint8_t buffer[128]; | 369 uint8_t buffer[128]; |
370 } sha384_context; | 370 } sha384_context; |
371 uint64_t FX_ato64i(const FX_CHAR* str) { | 371 uint64_t FX_ato64i(const FX_CHAR* str) { |
372 FXSYS_assert(str != NULL); | 372 FXSYS_assert(str); |
373 uint64_t ret = 0; | 373 uint64_t ret = 0; |
374 int len = (int)FXSYS_strlen(str); | 374 int len = (int)FXSYS_strlen(str); |
375 len = len > 16 ? 16 : len; | 375 len = len > 16 ? 16 : len; |
376 for (int i = 0; i < len; ++i) { | 376 for (int i = 0; i < len; ++i) { |
377 if (i) { | 377 if (i) { |
378 ret <<= 4; | 378 ret <<= 4; |
379 } | 379 } |
380 if (str[i] >= '0' && str[i] <= '9') { | 380 if (str[i] >= '0' && str[i] <= '9') { |
381 ret |= (str[i] - '0') & 0xFF; | 381 ret |= (str[i] - '0') & 0xFF; |
382 } else if (str[i] >= 'a' && str[i] <= 'f') { | 382 } else if (str[i] >= 'a' && str[i] <= 'f') { |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |