diff options
author | tsepez <tsepez@chromium.org> | 2016-11-21 12:08:22 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-21 12:08:22 -0800 |
commit | f5cabbfc3085a7a7a3451452c1a7ebe1f19c1223 (patch) | |
tree | 8c8c9ce87d6bed6cb209bc136845830148b69809 /core/fdrm/crypto/fx_crypt.cpp | |
parent | 43170f498b8c619620c4141b2d67ef6ab9a518ca (diff) | |
download | pdfium-f5cabbfc3085a7a7a3451452c1a7ebe1f19c1223.tar.xz |
Add unit test for fdrm's MD5
Review-Url: https://codereview.chromium.org/2517153003
Diffstat (limited to 'core/fdrm/crypto/fx_crypt.cpp')
-rw-r--r-- | core/fdrm/crypto/fx_crypt.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/core/fdrm/crypto/fx_crypt.cpp b/core/fdrm/crypto/fx_crypt.cpp index 12b955d93d..326ec8c83e 100644 --- a/core/fdrm/crypto/fx_crypt.cpp +++ b/core/fdrm/crypto/fx_crypt.cpp @@ -57,11 +57,6 @@ void CRYPT_ArcFourCryptBlock(uint8_t* pData, CRYPT_ArcFourSetup(&s, key, keylen); CRYPT_ArcFourCrypt(&s, pData, size); } -struct md5_context { - uint32_t total[2]; - uint32_t state[4]; - uint8_t buffer[64]; -}; #define GET_UINT32(n, b, i) \ { \ (n) = (uint32_t)((uint8_t*)b)[(i)] | \ @@ -76,7 +71,7 @@ struct md5_context { (((uint8_t*)b)[(i) + 2]) = (uint8_t)(((n) >> 16) & 0xFF); \ (((uint8_t*)b)[(i) + 3]) = (uint8_t)(((n) >> 24) & 0xFF); \ } -void md5_process(struct md5_context* ctx, const uint8_t data[64]) { +void md5_process(struct CRYPT_md5_context* ctx, const uint8_t data[64]) { uint32_t A, B, C, D, X[16]; GET_UINT32(X[0], data, 0); GET_UINT32(X[1], data, 4); @@ -182,7 +177,7 @@ void md5_process(struct md5_context* ctx, const uint8_t data[64]) { ctx->state[3] += D; } void CRYPT_MD5Start(void* context) { - struct md5_context* ctx = (struct md5_context*)context; + struct CRYPT_md5_context* ctx = (struct CRYPT_md5_context*)context; ctx->total[0] = 0; ctx->total[1] = 0; ctx->state[0] = 0x67452301; @@ -191,7 +186,7 @@ void CRYPT_MD5Start(void* context) { ctx->state[3] = 0x10325476; } void CRYPT_MD5Update(void* pctx, const uint8_t* input, uint32_t length) { - struct md5_context* ctx = (struct md5_context*)pctx; + struct CRYPT_md5_context* ctx = (struct CRYPT_md5_context*)pctx; uint32_t left, fill; if (!length) { return; @@ -223,7 +218,7 @@ const uint8_t md5_padding[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; void CRYPT_MD5Finish(void* pctx, uint8_t digest[16]) { - struct md5_context* ctx = (struct md5_context*)pctx; + struct CRYPT_md5_context* ctx = (struct CRYPT_md5_context*)pctx; uint32_t last, padn; uint8_t msglen[8]; PUT_UINT32(ctx->total[0], msglen, 0); @@ -240,7 +235,7 @@ void CRYPT_MD5Finish(void* pctx, uint8_t digest[16]) { void CRYPT_MD5Generate(const uint8_t* input, uint32_t length, uint8_t digest[16]) { - md5_context ctx; + CRYPT_md5_context ctx; CRYPT_MD5Start(&ctx); CRYPT_MD5Update(&ctx, input, length); CRYPT_MD5Finish(&ctx, digest); |