webmcp

changeset 500:5e6dbaa3e219

Removed endianess specific functions and included header files from moonhash_sha3.c
author jbe
date Sun Aug 13 14:31:21 2017 +0200 (2017-08-13)
parents b36e366bba2b
children 01f53490f262
files libraries/moonhash/moonhash_sha3.c
line diff
     1.1 --- a/libraries/moonhash/moonhash_sha3.c	Sun Aug 13 03:22:48 2017 +0200
     1.2 +++ b/libraries/moonhash/moonhash_sha3.c	Sun Aug 13 14:31:21 2017 +0200
     1.3 @@ -1,7 +1,6 @@
     1.4  /* This file is derived from "Keccak-more-compact.c", which has been downloaded from <https://github.com/gvanas/KeccakCodePackage/blob/10856bc1922a1ee2c4d2822a88b9ef8fb5059932/Standalone/CompactFIPS202/Keccak-more-compact.c>. The original file "Keccak-more-compact.c" has, according to <https://github.com/gvanas/KeccakCodePackage/blob/10856bc1922a1ee2c4d2822a88b9ef8fb5059932/README.markdown>, been put into the public domain. */
     1.5  
     1.6  #include <stdint.h>
     1.7 -#include <sys/endian.h>
     1.8  
     1.9  #define FOR(i,n) for(i=0; i<n; ++i)
    1.10  typedef uint8_t u8;
    1.11 @@ -18,13 +17,9 @@
    1.12  
    1.13  static int LFSR86540(u8 *R) { (*R)=((*R)<<1)^(((*R)&0x80)?0x71:0); return ((*R)&2)>>1; }
    1.14  #define ROL(a,o) ((((u64)a)<<o)^(((u64)a)>>(64-o)))
    1.15 -#define load64 le64dec
    1.16 -#define store64 le64enc
    1.17 -#if _BYTE_ORDER == _LITTLE_ENDIAN
    1.18 -static void xor64(u8 *x, u64 u) { *(u64 *)x ^= u; }
    1.19 -#else
    1.20 +static u64 load64(const u8 *x) { ui i; u64 u=0; FOR(i,8) { u<<=8; u|=x[7-i]; } return u; }
    1.21 +static void store64(u8 *x, u64 u) { ui i; FOR(i,8) { x[i]=u; u>>=8; } }
    1.22  static void xor64(u8 *x, u64 u) { ui i; FOR(i,8) { x[i]^=u; u>>=8; } }
    1.23 -#endif
    1.24  #define rL(x,y) load64((u8*)s+8*(x+5*y))
    1.25  #define wL(x,y,l) store64((u8*)s+8*(x+5*y),l)
    1.26  #define XL(x,y,l) xor64((u8*)s+8*(x+5*y),l)

Impressum / About Us