aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2019-04-15 23:03:04 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2019-04-16 10:59:02 +0300
commit608b77383e8a79f7e527a66851a5766548660015 (patch)
treebac616d349731730d70e5d7edfec824597f76667
parent7887edc2b44c840bf2cbe60cb1bf02eceab80dd3 (diff)
downloadlibmicrohttpd-608b77383e8a79f7e527a66851a5766548660015.tar.gz
libmicrohttpd-608b77383e8a79f7e527a66851a5766548660015.zip
MD5: some optimisations for little-endian
-rw-r--r--src/microhttpd/md5.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/microhttpd/md5.c b/src/microhttpd/md5.c
index 867e0d3f..f3b09aea 100644
--- a/src/microhttpd/md5.c
+++ b/src/microhttpd/md5.c
@@ -21,6 +21,10 @@
21#include "mhd_byteorder.h" 21#include "mhd_byteorder.h"
22#include "mhd_assert.h" 22#include "mhd_assert.h"
23 23
24#if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN
25#define PUT_64BIT_LE(cp, value) ((*(uint64_t*)(cp)) = (uint64_t)(value))
26#define PUT_32BIT_LE(cp, value) ((*(uint32_t*)(cp)) = (uint32_t)(value))
27#else
24#define PUT_64BIT_LE(cp, value) do { \ 28#define PUT_64BIT_LE(cp, value) do { \
25 (cp)[7] = (uint8_t)((value) >> 56); \ 29 (cp)[7] = (uint8_t)((value) >> 56); \
26 (cp)[6] = (uint8_t)((value) >> 48); \ 30 (cp)[6] = (uint8_t)((value) >> 48); \
@@ -36,6 +40,7 @@
36 (cp)[2] = (uint8_t)((value) >> 16); \ 40 (cp)[2] = (uint8_t)((value) >> 16); \
37 (cp)[1] = (uint8_t)((value) >> 8); \ 41 (cp)[1] = (uint8_t)((value) >> 8); \
38 (cp)[0] = (uint8_t)((value)); } while (0) 42 (cp)[0] = (uint8_t)((value)); } while (0)
43#endif
39 44
40static uint8_t PADDING[MD5_BLOCK_SIZE] = { 45static uint8_t PADDING[MD5_BLOCK_SIZE] = {
41 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46 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
135MD5Transform (uint32_t state[4], 140MD5Transform (uint32_t state[4],
136 const uint8_t block[MD5_BLOCK_SIZE]) 141 const uint8_t block[MD5_BLOCK_SIZE])
137{ 142{
138 uint32_t a, b, c, d, in[MD5_BLOCK_SIZE / 4]; 143 uint32_t a, b, c, d;
139 144
140#if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN 145#if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN
141 memcpy(in, block, sizeof(in)); 146 const uint32_t *in = (const uint32_t *)block;
142#else 147#else
148 uint32_t in[MD5_BLOCK_SIZE / 4];
143 for (a = 0; a < MD5_BLOCK_SIZE / 4; a++) 149 for (a = 0; a < MD5_BLOCK_SIZE / 4; a++)
144 { 150 {
145 in[a] = (uint32_t)( 151 in[a] = (uint32_t)(