diff options
author | Wei Li <weili@chromium.org> | 2017-05-22 15:58:52 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-22 23:01:53 +0000 |
commit | 355954b8f09a65934b95dd6ca1299a73ae5e24b2 (patch) | |
tree | bb1e31e73d9fef7e67ab117b0e9c9093908e75e9 /core | |
parent | ed75ee25f40a475f774e1e06c5375feee70b56f5 (diff) | |
download | pdfium-355954b8f09a65934b95dd6ca1299a73ae5e24b2.tar.xz |
Fix crypto calculation regression due to typo
Use the correct values to calculate SHA512.
BUG=pdfium:727,chromium:725267
Change-Id: I63d257c1df6304019a70f53df4653d358d3db525
Reviewed-on: https://pdfium-review.googlesource.com/5770
Commit-Queue: Wei Li <weili@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fdrm/crypto/fx_crypt_sha.cpp | 16 | ||||
-rw-r--r-- | core/fdrm/crypto/fx_crypt_unittest.cpp | 17 |
2 files changed, 25 insertions, 8 deletions
diff --git a/core/fdrm/crypto/fx_crypt_sha.cpp b/core/fdrm/crypto/fx_crypt_sha.cpp index 7420a32d48..812700d9cd 100644 --- a/core/fdrm/crypto/fx_crypt_sha.cpp +++ b/core/fdrm/crypto/fx_crypt_sha.cpp @@ -587,14 +587,14 @@ void CRYPT_SHA512Start(CRYPT_sha2_context* ctx) { return; memset(ctx, 0, sizeof(CRYPT_sha2_context)); - ctx->state[0] = 0xa09e667f3bcc908ULL; - ctx->state[1] = 0xb67ae8584caa73bULL; - ctx->state[2] = 0xc6ef372fe94f82bULL; - ctx->state[3] = 0x54ff53a5f1d36f1ULL; - ctx->state[4] = 0x10e527fade682d1ULL; - ctx->state[5] = 0xb05688c2b3e6c1fULL; - ctx->state[6] = 0xf83d9abfb41bd6bULL; - ctx->state[7] = 0xbe0cd19137e2179ULL; + ctx->state[0] = 0x6a09e667f3bcc908ULL; + ctx->state[1] = 0xbb67ae8584caa73bULL; + ctx->state[2] = 0x3c6ef372fe94f82bULL; + ctx->state[3] = 0xa54ff53a5f1d36f1ULL; + ctx->state[4] = 0x510e527fade682d1ULL; + ctx->state[5] = 0x9b05688c2b3e6c1fULL; + ctx->state[6] = 0x1f83d9abfb41bd6bULL; + ctx->state[7] = 0x5be0cd19137e2179ULL; } void CRYPT_SHA512Update(CRYPT_sha2_context* ctx, diff --git a/core/fdrm/crypto/fx_crypt_unittest.cpp b/core/fdrm/crypto/fx_crypt_unittest.cpp index 9795d97cfe..3b3f72c1ad 100644 --- a/core/fdrm/crypto/fx_crypt_unittest.cpp +++ b/core/fdrm/crypto/fx_crypt_unittest.cpp @@ -484,3 +484,20 @@ TEST(FXCRYPT, CRYPT_ArcFourCrypt) { CheckArcFourContext(context, 15, 68, kPermutation); } } + +TEST(FXCRYPT, Sha512Test) { + const char* const input = + "This is a simple test. To see whether it is getting correct value."; + const uint8_t expected[64] = { + 0x86, 0xB5, 0x05, 0x63, 0xA2, 0x6F, 0xD6, 0xFA, 0xEB, 0x9B, 0xC3, + 0xBB, 0x9E, 0xB7, 0x03, 0x82, 0xB6, 0x50, 0x55, 0x6B, 0x90, 0x69, + 0xD0, 0xA7, 0x53, 0x0A, 0x34, 0xDD, 0xEA, 0x11, 0xCC, 0x91, 0x5C, + 0xC7, 0x93, 0xCA, 0xAE, 0x30, 0xD1, 0x96, 0xBE, 0xD0, 0x35, 0x21, + 0x4A, 0xC6, 0x42, 0x56, 0x0C, 0xA3, 0x00, 0x69, 0x44, 0x77, 0xCC, + 0x3E, 0xD4, 0xD6, 0x10, 0x31, 0xC6, 0xC0, 0x58, 0xCF}; + uint8_t actual[64]; + CRYPT_SHA512Generate(reinterpret_cast<const uint8_t*>(input), strlen(input), + actual); + for (size_t i = 0; i < 64; ++i) + EXPECT_EQ(expected[i], actual[i]) << " at byte " << i; +} |