libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 608b77383e8a79f7e527a66851a5766548660015
parent 7887edc2b44c840bf2cbe60cb1bf02eceab80dd3
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 15 Apr 2019 23:03:04 +0300

MD5: some optimisations for little-endian

Diffstat:
Msrc/microhttpd/md5.c | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/microhttpd/md5.c b/src/microhttpd/md5.c @@ -21,6 +21,10 @@ #include "mhd_byteorder.h" #include "mhd_assert.h" +#if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN +#define PUT_64BIT_LE(cp, value) ((*(uint64_t*)(cp)) = (uint64_t)(value)) +#define PUT_32BIT_LE(cp, value) ((*(uint32_t*)(cp)) = (uint32_t)(value)) +#else #define PUT_64BIT_LE(cp, value) do { \ (cp)[7] = (uint8_t)((value) >> 56); \ (cp)[6] = (uint8_t)((value) >> 48); \ @@ -36,6 +40,7 @@ (cp)[2] = (uint8_t)((value) >> 16); \ (cp)[1] = (uint8_t)((value) >> 8); \ (cp)[0] = (uint8_t)((value)); } while (0) +#endif static uint8_t PADDING[MD5_BLOCK_SIZE] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -135,11 +140,12 @@ static void MD5Transform (uint32_t state[4], const uint8_t block[MD5_BLOCK_SIZE]) { - uint32_t a, b, c, d, in[MD5_BLOCK_SIZE / 4]; + uint32_t a, b, c, d; #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN - memcpy(in, block, sizeof(in)); + const uint32_t *in = (const uint32_t *)block; #else + uint32_t in[MD5_BLOCK_SIZE / 4]; for (a = 0; a < MD5_BLOCK_SIZE / 4; a++) { in[a] = (uint32_t)(