sha3 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +8 -5
- data/certs/johanns.pem +23 -22
- data/ext/sha3/config.h +26 -0
- data/ext/sha3/digest.c +6 -6
- data/ext/sha3/extconf.rb +40 -10
- data/ext/sha3/lib/common/align.h +33 -0
- data/ext/sha3/{brg_endian.h → lib/common/brg_endian.h} +8 -7
- data/ext/sha3/{KeccakHash.c → lib/high/Keccak/FIPS202/KeccakHash.c} +26 -25
- data/ext/sha3/{KeccakHash.h → lib/high/Keccak/FIPS202/KeccakHash.h} +34 -19
- data/ext/sha3/lib/high/Keccak/KeccakSponge.c +111 -0
- data/ext/sha3/lib/high/Keccak/KeccakSponge.h +76 -0
- data/ext/sha3/lib/high/Keccak/KeccakSponge.inc +316 -0
- data/ext/sha3/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros +748 -0
- data/ext/sha3/lib/low/KeccakP-1600/common/KeccakP-1600-unrolling.macros +305 -0
- data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h +44 -0
- data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference.h +23 -0
- data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference32BI.c +625 -0
- data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h +44 -0
- data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c +444 -0
- data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.h +23 -0
- data/lib/sha3/version.rb +1 -1
- data/sha3.gemspec +6 -5
- data/tests.sh +8 -7
- data.tar.gz.sig +0 -0
- metadata +50 -66
- metadata.gz.sig +0 -0
- data/ext/sha3/KeccakF-1600-interface.h +0 -40
- data/ext/sha3/KeccakSponge.c +0 -192
- data/ext/sha3/KeccakSponge.h +0 -113
- data/ext/sha3/Optimized64/KeccakF-1600-64.macros +0 -2199
- data/ext/sha3/Optimized64/KeccakF-1600-opt64-settings.h +0 -3
- data/ext/sha3/Optimized64/KeccakF-1600-opt64.c +0 -508
- data/ext/sha3/Optimized64/KeccakF-1600-unrolling.macros +0 -126
- data/ext/sha3/Optimized64/SnP-interface.h +0 -47
- data/ext/sha3/Reference/KeccakF-1600-reference.c +0 -311
- data/ext/sha3/Reference/KeccakF-reference.h +0 -26
- data/ext/sha3/Reference/SnP-FBWL-default.c +0 -96
- data/ext/sha3/Reference/SnP-FBWL-default.h +0 -26
- data/ext/sha3/Reference/SnP-interface.h +0 -42
- data/ext/sha3/Reference/displayIntermediateValues.c +0 -158
- data/ext/sha3/Reference/displayIntermediateValues.h +0 -34
- data/ext/sha3/SnP-Relaned.h +0 -249
| @@ -1,508 +0,0 @@ | |
| 1 | 
            -
            /*
         | 
| 2 | 
            -
            Implementation by the Keccak, Keyak and Ketje Teams, namely, Guido Bertoni,
         | 
| 3 | 
            -
            Joan Daemen, Michaël Peeters, Gilles Van Assche and Ronny Van Keer, hereby
         | 
| 4 | 
            -
            denoted as "the implementer".
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            For more information, feedback or questions, please refer to our websites:
         | 
| 7 | 
            -
            http://keccak.noekeon.org/
         | 
| 8 | 
            -
            http://keyak.noekeon.org/
         | 
| 9 | 
            -
            http://ketje.noekeon.org/
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            To the extent possible under law, the implementer has waived all copyright
         | 
| 12 | 
            -
            and related or neighboring rights to the source code in this file.
         | 
| 13 | 
            -
            http://creativecommons.org/publicdomain/zero/1.0/
         | 
| 14 | 
            -
            */
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            #include <string.h>
         | 
| 17 | 
            -
            #include <stdlib.h>
         | 
| 18 | 
            -
            #include "brg_endian.h"
         | 
| 19 | 
            -
            #include "KeccakF-1600-opt64-settings.h"
         | 
| 20 | 
            -
            #include "KeccakF-1600-interface.h"
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            typedef unsigned char UINT8;
         | 
| 23 | 
            -
            typedef unsigned long long int UINT64;
         | 
| 24 | 
            -
             | 
| 25 | 
            -
            #if defined(__GNUC__)
         | 
| 26 | 
            -
            #define ALIGN __attribute__ ((aligned(32)))
         | 
| 27 | 
            -
            #elif defined(_MSC_VER)
         | 
| 28 | 
            -
            #define ALIGN __declspec(align(32))
         | 
| 29 | 
            -
            #else
         | 
| 30 | 
            -
            #define ALIGN
         | 
| 31 | 
            -
            #endif
         | 
| 32 | 
            -
             | 
| 33 | 
            -
            #if defined(UseLaneComplementing)
         | 
| 34 | 
            -
            #define UseBebigokimisa
         | 
| 35 | 
            -
            #endif
         | 
| 36 | 
            -
             | 
| 37 | 
            -
            #if defined(_MSC_VER)
         | 
| 38 | 
            -
            #define ROL64(a, offset) _rotl64(a, offset)
         | 
| 39 | 
            -
            #elif defined(UseSHLD)
         | 
| 40 | 
            -
                #define ROL64(x,N) ({ \
         | 
| 41 | 
            -
                register UINT64 __out; \
         | 
| 42 | 
            -
                register UINT64 __in = x; \
         | 
| 43 | 
            -
                __asm__ ("shld %2,%0,%0" : "=r"(__out) : "0"(__in), "i"(N)); \
         | 
| 44 | 
            -
                __out; \
         | 
| 45 | 
            -
                })
         | 
| 46 | 
            -
            #else
         | 
| 47 | 
            -
            #define ROL64(a, offset) ((((UINT64)a) << offset) ^ (((UINT64)a) >> (64-offset)))
         | 
| 48 | 
            -
            #endif
         | 
| 49 | 
            -
             | 
| 50 | 
            -
            #include "KeccakF-1600-64.macros"
         | 
| 51 | 
            -
            #include "KeccakF-1600-unrolling.macros"
         | 
| 52 | 
            -
             | 
| 53 | 
            -
            const UINT64 KeccakF1600RoundConstants[24] = {
         | 
| 54 | 
            -
                0x0000000000000001ULL,
         | 
| 55 | 
            -
                0x0000000000008082ULL,
         | 
| 56 | 
            -
                0x800000000000808aULL,
         | 
| 57 | 
            -
                0x8000000080008000ULL,
         | 
| 58 | 
            -
                0x000000000000808bULL,
         | 
| 59 | 
            -
                0x0000000080000001ULL,
         | 
| 60 | 
            -
                0x8000000080008081ULL,
         | 
| 61 | 
            -
                0x8000000000008009ULL,
         | 
| 62 | 
            -
                0x000000000000008aULL,
         | 
| 63 | 
            -
                0x0000000000000088ULL,
         | 
| 64 | 
            -
                0x0000000080008009ULL,
         | 
| 65 | 
            -
                0x000000008000000aULL,
         | 
| 66 | 
            -
                0x000000008000808bULL,
         | 
| 67 | 
            -
                0x800000000000008bULL,
         | 
| 68 | 
            -
                0x8000000000008089ULL,
         | 
| 69 | 
            -
                0x8000000000008003ULL,
         | 
| 70 | 
            -
                0x8000000000008002ULL,
         | 
| 71 | 
            -
                0x8000000000000080ULL,
         | 
| 72 | 
            -
                0x000000000000800aULL,
         | 
| 73 | 
            -
                0x800000008000000aULL,
         | 
| 74 | 
            -
                0x8000000080008081ULL,
         | 
| 75 | 
            -
                0x8000000000008080ULL,
         | 
| 76 | 
            -
                0x0000000080000001ULL,
         | 
| 77 | 
            -
                0x8000000080008008ULL };
         | 
| 78 | 
            -
             | 
| 79 | 
            -
            void KeccakF1600_StateXORPermuteExtract(void *state, const unsigned char *inData, unsigned int inLaneCount, unsigned char *outData, unsigned int outLaneCount);
         | 
| 80 | 
            -
             | 
| 81 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 82 | 
            -
             | 
| 83 | 
            -
            void KeccakF1600_Initialize( void )
         | 
| 84 | 
            -
            {
         | 
| 85 | 
            -
            }
         | 
| 86 | 
            -
             | 
| 87 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 88 | 
            -
             | 
| 89 | 
            -
            void KeccakF1600_StateInitialize(void *state)
         | 
| 90 | 
            -
            {
         | 
| 91 | 
            -
                memset(state, 0, 200);
         | 
| 92 | 
            -
            #ifdef UseLaneComplementing
         | 
| 93 | 
            -
                ((UINT64*)state)[ 1] = ~(UINT64)0;
         | 
| 94 | 
            -
                ((UINT64*)state)[ 2] = ~(UINT64)0;
         | 
| 95 | 
            -
                ((UINT64*)state)[ 8] = ~(UINT64)0;
         | 
| 96 | 
            -
                ((UINT64*)state)[12] = ~(UINT64)0;
         | 
| 97 | 
            -
                ((UINT64*)state)[17] = ~(UINT64)0;
         | 
| 98 | 
            -
                ((UINT64*)state)[20] = ~(UINT64)0;
         | 
| 99 | 
            -
            #endif
         | 
| 100 | 
            -
            }
         | 
| 101 | 
            -
             | 
| 102 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 103 | 
            -
             | 
| 104 | 
            -
            void KeccakF1600_StateXORBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length)
         | 
| 105 | 
            -
            {
         | 
| 106 | 
            -
            #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
         | 
| 107 | 
            -
                if (length == 0)
         | 
| 108 | 
            -
                    return;
         | 
| 109 | 
            -
                UINT64 lane;
         | 
| 110 | 
            -
                if (length == 1)
         | 
| 111 | 
            -
                    lane = data[0];
         | 
| 112 | 
            -
                else {
         | 
| 113 | 
            -
                    lane = 0;
         | 
| 114 | 
            -
                    memcpy(&lane, data, length);
         | 
| 115 | 
            -
                }
         | 
| 116 | 
            -
                lane <<= offset*8;
         | 
| 117 | 
            -
            #else
         | 
| 118 | 
            -
                UINT64 lane = 0;
         | 
| 119 | 
            -
                unsigned int i;
         | 
| 120 | 
            -
                for(i=0; i<length; i++)
         | 
| 121 | 
            -
                    lane |= ((UINT64)data[i]) << ((i+offset)*8);
         | 
| 122 | 
            -
            #endif
         | 
| 123 | 
            -
                ((UINT64*)state)[lanePosition] ^= lane;
         | 
| 124 | 
            -
            }
         | 
| 125 | 
            -
             | 
| 126 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 127 | 
            -
             | 
| 128 | 
            -
            void KeccakF1600_StateXORLanes(void *state, const unsigned char *data, unsigned int laneCount)
         | 
| 129 | 
            -
            {
         | 
| 130 | 
            -
            #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
         | 
| 131 | 
            -
                unsigned int i = 0;
         | 
| 132 | 
            -
            #ifdef NO_MISALIGNED_ACCESSES
         | 
| 133 | 
            -
                // If either pointer is misaligned, fall back to byte-wise xor.
         | 
| 134 | 
            -
                if (((((uintptr_t)state) & 7) != 0) || ((((uintptr_t)data) & 7) != 0)) {
         | 
| 135 | 
            -
                  for (i = 0; i < laneCount * 8; i++) {
         | 
| 136 | 
            -
                    ((unsigned char*)state)[i] ^= data[i];
         | 
| 137 | 
            -
                  }
         | 
| 138 | 
            -
                }
         | 
| 139 | 
            -
                else
         | 
| 140 | 
            -
            #endif
         | 
| 141 | 
            -
                {
         | 
| 142 | 
            -
                  // Otherwise...
         | 
| 143 | 
            -
                  for( ; (i+8)<=laneCount; i+=8) {
         | 
| 144 | 
            -
                      ((UINT64*)state)[i+0] ^= ((UINT64*)data)[i+0];
         | 
| 145 | 
            -
                      ((UINT64*)state)[i+1] ^= ((UINT64*)data)[i+1];
         | 
| 146 | 
            -
                      ((UINT64*)state)[i+2] ^= ((UINT64*)data)[i+2];
         | 
| 147 | 
            -
                      ((UINT64*)state)[i+3] ^= ((UINT64*)data)[i+3];
         | 
| 148 | 
            -
                      ((UINT64*)state)[i+4] ^= ((UINT64*)data)[i+4];
         | 
| 149 | 
            -
                      ((UINT64*)state)[i+5] ^= ((UINT64*)data)[i+5];
         | 
| 150 | 
            -
                      ((UINT64*)state)[i+6] ^= ((UINT64*)data)[i+6];
         | 
| 151 | 
            -
                      ((UINT64*)state)[i+7] ^= ((UINT64*)data)[i+7];
         | 
| 152 | 
            -
                  }
         | 
| 153 | 
            -
                  for( ; (i+4)<=laneCount; i+=4) {
         | 
| 154 | 
            -
                      ((UINT64*)state)[i+0] ^= ((UINT64*)data)[i+0];
         | 
| 155 | 
            -
                      ((UINT64*)state)[i+1] ^= ((UINT64*)data)[i+1];
         | 
| 156 | 
            -
                      ((UINT64*)state)[i+2] ^= ((UINT64*)data)[i+2];
         | 
| 157 | 
            -
                      ((UINT64*)state)[i+3] ^= ((UINT64*)data)[i+3];
         | 
| 158 | 
            -
                  }
         | 
| 159 | 
            -
                  for( ; (i+2)<=laneCount; i+=2) {
         | 
| 160 | 
            -
                      ((UINT64*)state)[i+0] ^= ((UINT64*)data)[i+0];
         | 
| 161 | 
            -
                      ((UINT64*)state)[i+1] ^= ((UINT64*)data)[i+1];
         | 
| 162 | 
            -
                  }
         | 
| 163 | 
            -
                  if (i<laneCount) {
         | 
| 164 | 
            -
                      ((UINT64*)state)[i+0] ^= ((UINT64*)data)[i+0];
         | 
| 165 | 
            -
                  }
         | 
| 166 | 
            -
                }
         | 
| 167 | 
            -
            #else
         | 
| 168 | 
            -
                unsigned int i;
         | 
| 169 | 
            -
                UINT8 *curData = data;
         | 
| 170 | 
            -
                for(i=0; i<laneCount; i++, curData+=8) {
         | 
| 171 | 
            -
                    UINT64 lane = (UINT64)curData[0]
         | 
| 172 | 
            -
                        | ((UINT64)curData[1] << 8)
         | 
| 173 | 
            -
                        | ((UINT64)curData[2] << 16)
         | 
| 174 | 
            -
                        | ((UINT64)curData[3] << 24)
         | 
| 175 | 
            -
                        | ((UINT64)curData[4] <<32)
         | 
| 176 | 
            -
                        | ((UINT64)curData[5] << 40)
         | 
| 177 | 
            -
                        | ((UINT64)curData[6] << 48)
         | 
| 178 | 
            -
                        | ((UINT64)curData[7] << 56);
         | 
| 179 | 
            -
                    ((UINT64*)state)[i] ^= lane;
         | 
| 180 | 
            -
                }
         | 
| 181 | 
            -
            #endif
         | 
| 182 | 
            -
            }
         | 
| 183 | 
            -
             | 
| 184 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 185 | 
            -
             | 
| 186 | 
            -
            void KeccakF1600_StateOverwriteBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length)
         | 
| 187 | 
            -
            {
         | 
| 188 | 
            -
            #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
         | 
| 189 | 
            -
            #ifdef UseLaneComplementing
         | 
| 190 | 
            -
                if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20)) {
         | 
| 191 | 
            -
                    unsigned int i;
         | 
| 192 | 
            -
                    for(i=0; i<length; i++)
         | 
| 193 | 
            -
                        ((unsigned char*)state)[lanePosition*8+offset+i] = ~data[i];
         | 
| 194 | 
            -
                }
         | 
| 195 | 
            -
                else
         | 
| 196 | 
            -
            #endif
         | 
| 197 | 
            -
                {
         | 
| 198 | 
            -
                    memcpy((unsigned char*)state+lanePosition*8+offset, data, length);
         | 
| 199 | 
            -
                }
         | 
| 200 | 
            -
            #else
         | 
| 201 | 
            -
            #error "Not yet implemented"
         | 
| 202 | 
            -
            #endif
         | 
| 203 | 
            -
            }
         | 
| 204 | 
            -
             | 
| 205 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 206 | 
            -
             | 
| 207 | 
            -
            void KeccakF1600_StateOverwriteLanes(void *state, const unsigned char *data, unsigned int laneCount)
         | 
| 208 | 
            -
            {
         | 
| 209 | 
            -
            #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
         | 
| 210 | 
            -
            #ifdef UseLaneComplementing
         | 
| 211 | 
            -
                unsigned int lanePosition;
         | 
| 212 | 
            -
             | 
| 213 | 
            -
                for(lanePosition=0; lanePosition<laneCount; lanePosition++)
         | 
| 214 | 
            -
                    if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
         | 
| 215 | 
            -
                        ((UINT64*)state)[lanePosition] = ~((const UINT64*)data)[lanePosition];
         | 
| 216 | 
            -
                    else
         | 
| 217 | 
            -
                        ((UINT64*)state)[lanePosition] = ((const UINT64*)data)[lanePosition];
         | 
| 218 | 
            -
            #else
         | 
| 219 | 
            -
                memcpy(state, data, laneCount*8);
         | 
| 220 | 
            -
            #endif
         | 
| 221 | 
            -
            #else
         | 
| 222 | 
            -
            #error "Not yet implemented"
         | 
| 223 | 
            -
            #endif
         | 
| 224 | 
            -
            }
         | 
| 225 | 
            -
             | 
| 226 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 227 | 
            -
             | 
| 228 | 
            -
            void KeccakF1600_StateOverwriteWithZeroes(void *state, unsigned int byteCount)
         | 
| 229 | 
            -
            {
         | 
| 230 | 
            -
            #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
         | 
| 231 | 
            -
            #ifdef UseLaneComplementing
         | 
| 232 | 
            -
                unsigned int lanePosition;
         | 
| 233 | 
            -
             | 
| 234 | 
            -
                for(lanePosition=0; lanePosition<byteCount/8; lanePosition++)
         | 
| 235 | 
            -
                    if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
         | 
| 236 | 
            -
                        ((UINT64*)state)[lanePosition] = ~0;
         | 
| 237 | 
            -
                    else
         | 
| 238 | 
            -
                        ((UINT64*)state)[lanePosition] = 0;
         | 
| 239 | 
            -
                if (byteCount%8 != 0) {
         | 
| 240 | 
            -
                    lanePosition = byteCount/8;
         | 
| 241 | 
            -
                    if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
         | 
| 242 | 
            -
                        memset(state+lanePosition*8, 0xFF, byteCount%8);
         | 
| 243 | 
            -
                    else
         | 
| 244 | 
            -
                        memset(state+lanePosition*8, 0, byteCount%8);
         | 
| 245 | 
            -
                }
         | 
| 246 | 
            -
            #else
         | 
| 247 | 
            -
                memset(state, 0, byteCount);
         | 
| 248 | 
            -
            #endif
         | 
| 249 | 
            -
            #else
         | 
| 250 | 
            -
            #error "Not yet implemented"
         | 
| 251 | 
            -
            #endif
         | 
| 252 | 
            -
            }
         | 
| 253 | 
            -
             | 
| 254 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 255 | 
            -
             | 
| 256 | 
            -
            void KeccakF1600_StateComplementBit(void *state, unsigned int position)
         | 
| 257 | 
            -
            {
         | 
| 258 | 
            -
                UINT64 lane = (UINT64)1 << (position%64);
         | 
| 259 | 
            -
                ((UINT64*)state)[position/64] ^= lane;
         | 
| 260 | 
            -
            }
         | 
| 261 | 
            -
             | 
| 262 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 263 | 
            -
             | 
| 264 | 
            -
            void KeccakF1600_StatePermute(void *state)
         | 
| 265 | 
            -
            {
         | 
| 266 | 
            -
                declareABCDE
         | 
| 267 | 
            -
                #ifndef FullUnrolling
         | 
| 268 | 
            -
                unsigned int i;
         | 
| 269 | 
            -
                #endif
         | 
| 270 | 
            -
                UINT64 *stateAsLanes = (UINT64*)state;
         | 
| 271 | 
            -
             | 
| 272 | 
            -
                copyFromState(A, stateAsLanes)
         | 
| 273 | 
            -
                rounds
         | 
| 274 | 
            -
                copyToState(stateAsLanes, A)
         | 
| 275 | 
            -
            }
         | 
| 276 | 
            -
             | 
| 277 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 278 | 
            -
             | 
| 279 | 
            -
            void KeccakF1600_StateExtractBytesInLane(const void *state, unsigned int lanePosition, unsigned char *data, unsigned int offset, unsigned int length)
         | 
| 280 | 
            -
            {
         | 
| 281 | 
            -
                UINT64 lane = ((UINT64*)state)[lanePosition];
         | 
| 282 | 
            -
            #ifdef UseLaneComplementing
         | 
| 283 | 
            -
                if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
         | 
| 284 | 
            -
                    lane = ~lane;
         | 
| 285 | 
            -
            #endif
         | 
| 286 | 
            -
            #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
         | 
| 287 | 
            -
                {
         | 
| 288 | 
            -
                    UINT64 lane1[1];
         | 
| 289 | 
            -
                    lane1[0] = lane;
         | 
| 290 | 
            -
                    memcpy(data, (UINT8*)lane1+offset, length);
         | 
| 291 | 
            -
                }
         | 
| 292 | 
            -
            #else
         | 
| 293 | 
            -
                unsigned int i;
         | 
| 294 | 
            -
                lane >>= offset*8;
         | 
| 295 | 
            -
                for(i=0; i<length; i++) {
         | 
| 296 | 
            -
                    data[i] = lane & 0xFF;
         | 
| 297 | 
            -
                    lane >>= 8;
         | 
| 298 | 
            -
                }
         | 
| 299 | 
            -
            #endif
         | 
| 300 | 
            -
            }
         | 
| 301 | 
            -
             | 
| 302 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 303 | 
            -
             | 
| 304 | 
            -
            #if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
         | 
| 305 | 
            -
            void fromWordToBytes(UINT8 *bytes, const UINT64 word)
         | 
| 306 | 
            -
            {
         | 
| 307 | 
            -
                unsigned int i;
         | 
| 308 | 
            -
             | 
| 309 | 
            -
                for(i=0; i<(64/8); i++)
         | 
| 310 | 
            -
                    bytes[i] = (word >> (8*i)) & 0xFF;
         | 
| 311 | 
            -
            }
         | 
| 312 | 
            -
            #endif
         | 
| 313 | 
            -
             | 
| 314 | 
            -
            void KeccakF1600_StateExtractLanes(const void *state, unsigned char *data, unsigned int laneCount)
         | 
| 315 | 
            -
            {
         | 
| 316 | 
            -
            #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
         | 
| 317 | 
            -
                memcpy(data, state, laneCount*8);
         | 
| 318 | 
            -
            #else
         | 
| 319 | 
            -
                unsigned int i;
         | 
| 320 | 
            -
             | 
| 321 | 
            -
                for(i=0; i<laneCount; i++)
         | 
| 322 | 
            -
                    fromWordToBytes(data+(i*8), ((const UINT64*)state)[i]);
         | 
| 323 | 
            -
            #endif
         | 
| 324 | 
            -
            #ifdef UseLaneComplementing
         | 
| 325 | 
            -
                if (laneCount > 1) {
         | 
| 326 | 
            -
                    ((UINT64*)data)[ 1] = ~((UINT64*)data)[ 1];
         | 
| 327 | 
            -
                    if (laneCount > 2) {
         | 
| 328 | 
            -
                        ((UINT64*)data)[ 2] = ~((UINT64*)data)[ 2];
         | 
| 329 | 
            -
                        if (laneCount > 8) {
         | 
| 330 | 
            -
                            ((UINT64*)data)[ 8] = ~((UINT64*)data)[ 8];
         | 
| 331 | 
            -
                            if (laneCount > 12) {
         | 
| 332 | 
            -
                                ((UINT64*)data)[12] = ~((UINT64*)data)[12];
         | 
| 333 | 
            -
                                if (laneCount > 17) {
         | 
| 334 | 
            -
                                    ((UINT64*)data)[17] = ~((UINT64*)data)[17];
         | 
| 335 | 
            -
                                    if (laneCount > 20) {
         | 
| 336 | 
            -
                                        ((UINT64*)data)[20] = ~((UINT64*)data)[20];
         | 
| 337 | 
            -
                                    }
         | 
| 338 | 
            -
                                }
         | 
| 339 | 
            -
                            }
         | 
| 340 | 
            -
                        }
         | 
| 341 | 
            -
                    }
         | 
| 342 | 
            -
                }
         | 
| 343 | 
            -
            #endif
         | 
| 344 | 
            -
            }
         | 
| 345 | 
            -
             | 
| 346 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 347 | 
            -
             | 
| 348 | 
            -
            void KeccakF1600_StateExtractAndXORBytesInLane(const void *state, unsigned int lanePosition, unsigned char *data, unsigned int offset, unsigned int length)
         | 
| 349 | 
            -
            {
         | 
| 350 | 
            -
                UINT64 lane = ((UINT64*)state)[lanePosition];
         | 
| 351 | 
            -
            #ifdef UseLaneComplementing
         | 
| 352 | 
            -
                if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
         | 
| 353 | 
            -
                    lane = ~lane;
         | 
| 354 | 
            -
            #endif
         | 
| 355 | 
            -
            #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
         | 
| 356 | 
            -
                {
         | 
| 357 | 
            -
                    unsigned int i;
         | 
| 358 | 
            -
                    UINT64 lane1[1];
         | 
| 359 | 
            -
                    lane1[0] = lane;
         | 
| 360 | 
            -
                    for(i=0; i<length; i++)
         | 
| 361 | 
            -
                        data[i] ^= ((UINT8*)lane1)[offset+i];
         | 
| 362 | 
            -
                }
         | 
| 363 | 
            -
            #else
         | 
| 364 | 
            -
                unsigned int i;
         | 
| 365 | 
            -
                lane >>= offset*8;
         | 
| 366 | 
            -
                for(i=0; i<length; i++) {
         | 
| 367 | 
            -
                    data[i] ^= lane & 0xFF;
         | 
| 368 | 
            -
                    lane >>= 8;
         | 
| 369 | 
            -
                }
         | 
| 370 | 
            -
            #endif
         | 
| 371 | 
            -
            }
         | 
| 372 | 
            -
             | 
| 373 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 374 | 
            -
             | 
| 375 | 
            -
            void KeccakF1600_StateExtractAndXORLanes(const void *state, unsigned char *data, unsigned int laneCount)
         | 
| 376 | 
            -
            {
         | 
| 377 | 
            -
                unsigned int i;
         | 
| 378 | 
            -
            #if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
         | 
| 379 | 
            -
                unsigned char temp[8];
         | 
| 380 | 
            -
                unsigned int j;
         | 
| 381 | 
            -
            #endif
         | 
| 382 | 
            -
             | 
| 383 | 
            -
                for(i=0; i<laneCount; i++) {
         | 
| 384 | 
            -
            #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
         | 
| 385 | 
            -
                    ((UINT64*)data)[i] ^= ((const UINT64*)state)[i];
         | 
| 386 | 
            -
            #else
         | 
| 387 | 
            -
                    fromWordToBytes(temp, ((const UINT64*)state)[i]);
         | 
| 388 | 
            -
                    for(j=0; j<8; j++)
         | 
| 389 | 
            -
                        data[i*8+j] ^= temp[j];
         | 
| 390 | 
            -
            #endif
         | 
| 391 | 
            -
                }
         | 
| 392 | 
            -
            #ifdef UseLaneComplementing
         | 
| 393 | 
            -
                if (laneCount > 1) {
         | 
| 394 | 
            -
                    ((UINT64*)data)[ 1] = ~((UINT64*)data)[ 1];
         | 
| 395 | 
            -
                    if (laneCount > 2) {
         | 
| 396 | 
            -
                        ((UINT64*)data)[ 2] = ~((UINT64*)data)[ 2];
         | 
| 397 | 
            -
                        if (laneCount > 8) {
         | 
| 398 | 
            -
                            ((UINT64*)data)[ 8] = ~((UINT64*)data)[ 8];
         | 
| 399 | 
            -
                            if (laneCount > 12) {
         | 
| 400 | 
            -
                                ((UINT64*)data)[12] = ~((UINT64*)data)[12];
         | 
| 401 | 
            -
                                if (laneCount > 17) {
         | 
| 402 | 
            -
                                    ((UINT64*)data)[17] = ~((UINT64*)data)[17];
         | 
| 403 | 
            -
                                    if (laneCount > 20) {
         | 
| 404 | 
            -
                                        ((UINT64*)data)[20] = ~((UINT64*)data)[20];
         | 
| 405 | 
            -
                                    }
         | 
| 406 | 
            -
                                }
         | 
| 407 | 
            -
                            }
         | 
| 408 | 
            -
                        }
         | 
| 409 | 
            -
                    }
         | 
| 410 | 
            -
                }
         | 
| 411 | 
            -
            #endif
         | 
| 412 | 
            -
            }
         | 
| 413 | 
            -
             | 
| 414 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 415 | 
            -
             | 
| 416 | 
            -
            size_t KeccakF1600_FBWL_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen, unsigned char trailingBits)
         | 
| 417 | 
            -
            {
         | 
| 418 | 
            -
                size_t originalDataByteLen = dataByteLen;
         | 
| 419 | 
            -
                declareABCDE
         | 
| 420 | 
            -
                #ifndef FullUnrolling
         | 
| 421 | 
            -
                unsigned int i;
         | 
| 422 | 
            -
                #endif
         | 
| 423 | 
            -
                UINT64 *stateAsLanes = (UINT64*)state;
         | 
| 424 | 
            -
                UINT64 *inDataAsLanes = (UINT64*)data;
         | 
| 425 | 
            -
             | 
| 426 | 
            -
                copyFromState(A, stateAsLanes)
         | 
| 427 | 
            -
                while(dataByteLen >= laneCount*8) {
         | 
| 428 | 
            -
                    XORinputAndTrailingBits(A, inDataAsLanes, laneCount, ((UINT64)trailingBits))
         | 
| 429 | 
            -
                    rounds
         | 
| 430 | 
            -
                    inDataAsLanes += laneCount;
         | 
| 431 | 
            -
                    dataByteLen -= laneCount*8;
         | 
| 432 | 
            -
                }
         | 
| 433 | 
            -
                copyToState(stateAsLanes, A)
         | 
| 434 | 
            -
                return originalDataByteLen - dataByteLen;
         | 
| 435 | 
            -
            }
         | 
| 436 | 
            -
             | 
| 437 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 438 | 
            -
             | 
| 439 | 
            -
            size_t KeccakF1600_FBWL_Squeeze(void *state, unsigned int laneCount, unsigned char *data, size_t dataByteLen)
         | 
| 440 | 
            -
            {
         | 
| 441 | 
            -
                size_t originalDataByteLen = dataByteLen;
         | 
| 442 | 
            -
                declareABCDE
         | 
| 443 | 
            -
                #ifndef FullUnrolling
         | 
| 444 | 
            -
                unsigned int i;
         | 
| 445 | 
            -
                #endif
         | 
| 446 | 
            -
                UINT64 *stateAsLanes = (UINT64*)state;
         | 
| 447 | 
            -
                UINT64 *outDataAsLanes = (UINT64*)data;
         | 
| 448 | 
            -
             | 
| 449 | 
            -
                copyFromState(A, stateAsLanes)
         | 
| 450 | 
            -
                while(dataByteLen >= laneCount*8) {
         | 
| 451 | 
            -
                    rounds
         | 
| 452 | 
            -
                    output(A, outDataAsLanes, laneCount)
         | 
| 453 | 
            -
                    outDataAsLanes += laneCount;
         | 
| 454 | 
            -
                    dataByteLen -= laneCount*8;
         | 
| 455 | 
            -
                }
         | 
| 456 | 
            -
                copyToState(stateAsLanes, A)
         | 
| 457 | 
            -
                return originalDataByteLen - dataByteLen;
         | 
| 458 | 
            -
            }
         | 
| 459 | 
            -
             | 
| 460 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 461 | 
            -
             | 
| 462 | 
            -
            size_t KeccakF1600_FBWL_Wrap(void *state, unsigned int laneCount, const unsigned char *dataIn, unsigned char *dataOut, size_t dataByteLen, unsigned char trailingBits)
         | 
| 463 | 
            -
            {
         | 
| 464 | 
            -
                size_t originalDataByteLen = dataByteLen;
         | 
| 465 | 
            -
                declareABCDE
         | 
| 466 | 
            -
                #ifndef FullUnrolling
         | 
| 467 | 
            -
                unsigned int i;
         | 
| 468 | 
            -
                #endif
         | 
| 469 | 
            -
                UINT64 *stateAsLanes = (UINT64*)state;
         | 
| 470 | 
            -
                UINT64 *inDataAsLanes = (UINT64*)dataIn;
         | 
| 471 | 
            -
                UINT64 *outDataAsLanes = (UINT64*)dataOut;
         | 
| 472 | 
            -
             | 
| 473 | 
            -
                copyFromState(A, stateAsLanes)
         | 
| 474 | 
            -
                while(dataByteLen >= laneCount*8) {
         | 
| 475 | 
            -
                    wrap(A, inDataAsLanes, outDataAsLanes, laneCount, ((UINT64)trailingBits))
         | 
| 476 | 
            -
                    rounds
         | 
| 477 | 
            -
                    inDataAsLanes += laneCount;
         | 
| 478 | 
            -
                    outDataAsLanes += laneCount;
         | 
| 479 | 
            -
                    dataByteLen -= laneCount*8;
         | 
| 480 | 
            -
                }
         | 
| 481 | 
            -
                copyToState(stateAsLanes, A)
         | 
| 482 | 
            -
                return originalDataByteLen - dataByteLen;
         | 
| 483 | 
            -
            }
         | 
| 484 | 
            -
             | 
| 485 | 
            -
            /* ---------------------------------------------------------------- */
         | 
| 486 | 
            -
             | 
| 487 | 
            -
            size_t KeccakF1600_FBWL_Unwrap(void *state, unsigned int laneCount, const unsigned char *dataIn, unsigned char *dataOut, size_t dataByteLen, unsigned char trailingBits)
         | 
| 488 | 
            -
            {
         | 
| 489 | 
            -
                size_t originalDataByteLen = dataByteLen;
         | 
| 490 | 
            -
                declareABCDE
         | 
| 491 | 
            -
                #ifndef FullUnrolling
         | 
| 492 | 
            -
                unsigned int i;
         | 
| 493 | 
            -
                #endif
         | 
| 494 | 
            -
                UINT64 *stateAsLanes = (UINT64*)state;
         | 
| 495 | 
            -
                UINT64 *inDataAsLanes = (UINT64*)dataIn;
         | 
| 496 | 
            -
                UINT64 *outDataAsLanes = (UINT64*)dataOut;
         | 
| 497 | 
            -
             | 
| 498 | 
            -
                copyFromState(A, stateAsLanes)
         | 
| 499 | 
            -
                while(dataByteLen >= laneCount*8) {
         | 
| 500 | 
            -
                    unwrap(A, inDataAsLanes, outDataAsLanes, laneCount, ((UINT64)trailingBits))
         | 
| 501 | 
            -
                    rounds
         | 
| 502 | 
            -
                    inDataAsLanes += laneCount;
         | 
| 503 | 
            -
                    outDataAsLanes += laneCount;
         | 
| 504 | 
            -
                    dataByteLen -= laneCount*8;
         | 
| 505 | 
            -
                }
         | 
| 506 | 
            -
                copyToState(stateAsLanes, A)
         | 
| 507 | 
            -
                return originalDataByteLen - dataByteLen;
         | 
| 508 | 
            -
            }
         | 
| @@ -1,126 +0,0 @@ | |
| 1 | 
            -
            /*
         | 
| 2 | 
            -
            Implementation by the Keccak, Keyak and Ketje Teams, namely, Guido Bertoni,
         | 
| 3 | 
            -
            Joan Daemen, Michaël Peeters, Gilles Van Assche and Ronny Van Keer, hereby
         | 
| 4 | 
            -
            denoted as "the implementer".
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            For more information, feedback or questions, please refer to our websites:
         | 
| 7 | 
            -
            http://keccak.noekeon.org/
         | 
| 8 | 
            -
            http://keyak.noekeon.org/
         | 
| 9 | 
            -
            http://ketje.noekeon.org/
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            To the extent possible under law, the implementer has waived all copyright
         | 
| 12 | 
            -
            and related or neighboring rights to the source code in this file.
         | 
| 13 | 
            -
            http://creativecommons.org/publicdomain/zero/1.0/
         | 
| 14 | 
            -
            */
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            #if (defined(FullUnrolling))
         | 
| 17 | 
            -
            #define rounds \
         | 
| 18 | 
            -
                prepareTheta \
         | 
| 19 | 
            -
                thetaRhoPiChiIotaPrepareTheta( 0, A, E) \
         | 
| 20 | 
            -
                thetaRhoPiChiIotaPrepareTheta( 1, E, A) \
         | 
| 21 | 
            -
                thetaRhoPiChiIotaPrepareTheta( 2, A, E) \
         | 
| 22 | 
            -
                thetaRhoPiChiIotaPrepareTheta( 3, E, A) \
         | 
| 23 | 
            -
                thetaRhoPiChiIotaPrepareTheta( 4, A, E) \
         | 
| 24 | 
            -
                thetaRhoPiChiIotaPrepareTheta( 5, E, A) \
         | 
| 25 | 
            -
                thetaRhoPiChiIotaPrepareTheta( 6, A, E) \
         | 
| 26 | 
            -
                thetaRhoPiChiIotaPrepareTheta( 7, E, A) \
         | 
| 27 | 
            -
                thetaRhoPiChiIotaPrepareTheta( 8, A, E) \
         | 
| 28 | 
            -
                thetaRhoPiChiIotaPrepareTheta( 9, E, A) \
         | 
| 29 | 
            -
                thetaRhoPiChiIotaPrepareTheta(10, A, E) \
         | 
| 30 | 
            -
                thetaRhoPiChiIotaPrepareTheta(11, E, A) \
         | 
| 31 | 
            -
                thetaRhoPiChiIotaPrepareTheta(12, A, E) \
         | 
| 32 | 
            -
                thetaRhoPiChiIotaPrepareTheta(13, E, A) \
         | 
| 33 | 
            -
                thetaRhoPiChiIotaPrepareTheta(14, A, E) \
         | 
| 34 | 
            -
                thetaRhoPiChiIotaPrepareTheta(15, E, A) \
         | 
| 35 | 
            -
                thetaRhoPiChiIotaPrepareTheta(16, A, E) \
         | 
| 36 | 
            -
                thetaRhoPiChiIotaPrepareTheta(17, E, A) \
         | 
| 37 | 
            -
                thetaRhoPiChiIotaPrepareTheta(18, A, E) \
         | 
| 38 | 
            -
                thetaRhoPiChiIotaPrepareTheta(19, E, A) \
         | 
| 39 | 
            -
                thetaRhoPiChiIotaPrepareTheta(20, A, E) \
         | 
| 40 | 
            -
                thetaRhoPiChiIotaPrepareTheta(21, E, A) \
         | 
| 41 | 
            -
                thetaRhoPiChiIotaPrepareTheta(22, A, E) \
         | 
| 42 | 
            -
                thetaRhoPiChiIota(23, E, A) \
         | 
| 43 | 
            -
             | 
| 44 | 
            -
            #elif (Unrolling == 12)
         | 
| 45 | 
            -
            #define rounds \
         | 
| 46 | 
            -
                prepareTheta \
         | 
| 47 | 
            -
                for(i=0; i<24; i+=12) { \
         | 
| 48 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i   , A, E) \
         | 
| 49 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+ 1, E, A) \
         | 
| 50 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+ 2, A, E) \
         | 
| 51 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+ 3, E, A) \
         | 
| 52 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+ 4, A, E) \
         | 
| 53 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+ 5, E, A) \
         | 
| 54 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+ 6, A, E) \
         | 
| 55 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+ 7, E, A) \
         | 
| 56 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+ 8, A, E) \
         | 
| 57 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+ 9, E, A) \
         | 
| 58 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+10, A, E) \
         | 
| 59 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+11, E, A) \
         | 
| 60 | 
            -
                } \
         | 
| 61 | 
            -
             | 
| 62 | 
            -
            #elif (Unrolling == 8)
         | 
| 63 | 
            -
            #define rounds \
         | 
| 64 | 
            -
                prepareTheta \
         | 
| 65 | 
            -
                for(i=0; i<24; i+=8) { \
         | 
| 66 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i  , A, E) \
         | 
| 67 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
         | 
| 68 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
         | 
| 69 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+3, E, A) \
         | 
| 70 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+4, A, E) \
         | 
| 71 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+5, E, A) \
         | 
| 72 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+6, A, E) \
         | 
| 73 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+7, E, A) \
         | 
| 74 | 
            -
                } \
         | 
| 75 | 
            -
             | 
| 76 | 
            -
            #elif (Unrolling == 6)
         | 
| 77 | 
            -
            #define rounds \
         | 
| 78 | 
            -
                prepareTheta \
         | 
| 79 | 
            -
                for(i=0; i<24; i+=6) { \
         | 
| 80 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i  , A, E) \
         | 
| 81 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
         | 
| 82 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
         | 
| 83 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+3, E, A) \
         | 
| 84 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+4, A, E) \
         | 
| 85 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+5, E, A) \
         | 
| 86 | 
            -
                } \
         | 
| 87 | 
            -
             | 
| 88 | 
            -
            #elif (Unrolling == 4)
         | 
| 89 | 
            -
            #define rounds \
         | 
| 90 | 
            -
                prepareTheta \
         | 
| 91 | 
            -
                for(i=0; i<24; i+=4) { \
         | 
| 92 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i  , A, E) \
         | 
| 93 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
         | 
| 94 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
         | 
| 95 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+3, E, A) \
         | 
| 96 | 
            -
                } \
         | 
| 97 | 
            -
             | 
| 98 | 
            -
            #elif (Unrolling == 3)
         | 
| 99 | 
            -
            #define rounds \
         | 
| 100 | 
            -
                prepareTheta \
         | 
| 101 | 
            -
                for(i=0; i<24; i+=3) { \
         | 
| 102 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i  , A, E) \
         | 
| 103 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
         | 
| 104 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
         | 
| 105 | 
            -
                    copyStateVariables(A, E) \
         | 
| 106 | 
            -
                } \
         | 
| 107 | 
            -
             | 
| 108 | 
            -
            #elif (Unrolling == 2)
         | 
| 109 | 
            -
            #define rounds \
         | 
| 110 | 
            -
                prepareTheta \
         | 
| 111 | 
            -
                for(i=0; i<24; i+=2) { \
         | 
| 112 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i  , A, E) \
         | 
| 113 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
         | 
| 114 | 
            -
                } \
         | 
| 115 | 
            -
             | 
| 116 | 
            -
            #elif (Unrolling == 1)
         | 
| 117 | 
            -
            #define rounds \
         | 
| 118 | 
            -
                prepareTheta \
         | 
| 119 | 
            -
                for(i=0; i<24; i++) { \
         | 
| 120 | 
            -
                    thetaRhoPiChiIotaPrepareTheta(i  , A, E) \
         | 
| 121 | 
            -
                    copyStateVariables(A, E) \
         | 
| 122 | 
            -
                } \
         | 
| 123 | 
            -
             | 
| 124 | 
            -
            #else
         | 
| 125 | 
            -
            #error "Unrolling is not correctly specified!"
         | 
| 126 | 
            -
            #endif
         | 
| @@ -1,47 +0,0 @@ | |
| 1 | 
            -
            /*
         | 
| 2 | 
            -
            Implementation by the Keccak, Keyak and Ketje Teams, namely, Guido Bertoni,
         | 
| 3 | 
            -
            Joan Daemen, Michaël Peeters, Gilles Van Assche and Ronny Van Keer, hereby
         | 
| 4 | 
            -
            denoted as "the implementer".
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            For more information, feedback or questions, please refer to our websites:
         | 
| 7 | 
            -
            http://keccak.noekeon.org/
         | 
| 8 | 
            -
            http://keyak.noekeon.org/
         | 
| 9 | 
            -
            http://ketje.noekeon.org/
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            To the extent possible under law, the implementer has waived all copyright
         | 
| 12 | 
            -
            and related or neighboring rights to the source code in this file.
         | 
| 13 | 
            -
            http://creativecommons.org/publicdomain/zero/1.0/
         | 
| 14 | 
            -
            */
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            #ifndef _SnP_Interface_h_
         | 
| 17 | 
            -
            #define _SnP_Interface_h_
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            #include "KeccakF-1600-interface.h"
         | 
| 20 | 
            -
             | 
| 21 | 
            -
            #define SnP_width                           KeccakF_width
         | 
| 22 | 
            -
            #define SnP_stateSizeInBytes                KeccakF_stateSizeInBytes
         | 
| 23 | 
            -
            #define SnP_laneLengthInBytes               KeccakF_laneInBytes
         | 
| 24 | 
            -
            #define SnP_laneCount                       25
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            #define SnP_StaticInitialize                KeccakF1600_Initialize
         | 
| 27 | 
            -
            #define SnP_Initialize                      KeccakF1600_StateInitialize
         | 
| 28 | 
            -
            #define SnP_XORBytesInLane                  KeccakF1600_StateXORBytesInLane
         | 
| 29 | 
            -
            #define SnP_XORLanes                        KeccakF1600_StateXORLanes
         | 
| 30 | 
            -
            #define SnP_OverwriteBytesInLane            KeccakF1600_StateOverwriteBytesInLane
         | 
| 31 | 
            -
            #define SnP_OverwriteLanes                  KeccakF1600_StateOverwriteLanes
         | 
| 32 | 
            -
            #define SnP_OverwriteWithZeroes             KeccakF1600_StateOverwriteWithZeroes
         | 
| 33 | 
            -
            #define SnP_ComplementBit                   KeccakF1600_StateComplementBit
         | 
| 34 | 
            -
            #define SnP_Permute                         KeccakF1600_StatePermute
         | 
| 35 | 
            -
            #define SnP_ExtractBytesInLane              KeccakF1600_StateExtractBytesInLane
         | 
| 36 | 
            -
            #define SnP_ExtractLanes                    KeccakF1600_StateExtractLanes
         | 
| 37 | 
            -
            #define SnP_ExtractAndXORBytesInLane        KeccakF1600_StateExtractAndXORBytesInLane
         | 
| 38 | 
            -
            #define SnP_ExtractAndXORLanes              KeccakF1600_StateExtractAndXORLanes
         | 
| 39 | 
            -
             | 
| 40 | 
            -
            #include "SnP-Relaned.h"
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            #define SnP_FBWL_Absorb                     KeccakF1600_FBWL_Absorb
         | 
| 43 | 
            -
            #define SnP_FBWL_Squeeze                    KeccakF1600_FBWL_Squeeze
         | 
| 44 | 
            -
            #define SnP_FBWL_Wrap                       KeccakF1600_FBWL_Wrap
         | 
| 45 | 
            -
            #define SnP_FBWL_Unwrap                     KeccakF1600_FBWL_Unwrap
         | 
| 46 | 
            -
             | 
| 47 | 
            -
            #endif
         |