portable.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. static void
  2. gimli_core(uint32_t state[gimli_BLOCKBYTES / 4])
  3. {
  4. unsigned int round;
  5. unsigned int column;
  6. uint32_t x;
  7. uint32_t y;
  8. uint32_t z;
  9. for (round = 24; round > 0; round--) {
  10. for (column = 0; column < 4; column++) {
  11. x = ROTL32(state[column], 24);
  12. y = ROTL32(state[4 + column], 9);
  13. z = state[8 + column];
  14. state[8 + column] = x ^ (z << 1) ^ ((y & z) << 2);
  15. state[4 + column] = y ^ x ^ ((x | z) << 1);
  16. state[column] = z ^ y ^ ((x & y) << 3);
  17. }
  18. switch (round & 3) {
  19. case 0:
  20. x = state[0];
  21. state[0] = state[1];
  22. state[1] = x;
  23. x = state[2];
  24. state[2] = state[3];
  25. state[3] = x;
  26. state[0] ^= ((uint32_t) 0x9e377900 | round);
  27. break;
  28. case 2:
  29. x = state[0];
  30. state[0] = state[2];
  31. state[2] = x;
  32. x = state[1];
  33. state[1] = state[3];
  34. state[3] = x;
  35. }
  36. }
  37. }