From: Roy Marples Date: Mon, 2 Jun 2014 17:10:13 +0000 (+0000) Subject: Fix compile on Linux X-Git-Tag: v6.4.0~31 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5da48f00a722287411229dfe8f21af6cb76f5a10;p=thirdparty%2Fdhcpcd.git Fix compile on Linux --- diff --git a/configure b/configure index aacf606d..03e745a9 100755 --- a/configure +++ b/configure @@ -844,7 +844,7 @@ int main(void) { EOF # We only want to link to libmd if it exists in /lib set -- $(ls /lib/libmd.so.* 2>/dev/null) - if $XCC _sha256.c -o _sha256 3>/dev/null; then + if $XCC _sha256.c -o _sha256 2>/dev/null; then SHA2=yes SHA2_RENAMED=yes elif [ -e "$1" ] && $XCC _sha256.c -lmd -o _sha256 2>/dev/null diff --git a/crypt/sha256.c b/crypt/sha256.c index 24faa38d..64e0d5dd 100755 --- a/crypt/sha256.c +++ b/crypt/sha256.c @@ -24,8 +24,7 @@ * SUCH DAMAGE. */ -#include -#include +#include #include @@ -43,6 +42,38 @@ #else /* BYTE_ORDER != BIG_ENDIAN */ +static inline void +be32enc(uint8_t *buf, uint32_t u) +{ + + buf[0] = (uint8_t)((u >> 24) & 0xff); + buf[1] = (uint8_t)((u >> 16) & 0xff); + buf[2] = (uint8_t)((u >> 8) & 0xff); + buf[3] = (uint8_t)(u & 0xff); +} + +static inline void +be64enc(uint8_t *buf, uint64_t u) +{ + + be32enc(buf, (uint32_t)(u >> 32)); + be32enc(buf + sizeof(uint32_t), (uint32_t)(u & 0xffffffffULL)); +} + +static inline uint16_t +be16dec(const uint8_t *buf) +{ + + return (uint16_t)(buf[0] << 8 | buf[1]); +} + +static inline uint32_t +be32dec(const uint8_t *buf) +{ + + return (uint32_t)(be16dec(buf) << 16 | be16dec(buf + 2)); +} + /* * Encode a length len/4 vector of (uint32_t) into a length len vector of * (unsigned char) in big-endian form. Assumes len is a multiple of 4.