blake2b-compress-avx2.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #define BLAKE2_USE_SSSE3
  2. #define BLAKE2_USE_SSE41
  3. #define BLAKE2_USE_AVX2
  4. #include <stdint.h>
  5. #include <string.h>
  6. #include "blake2.h"
  7. #include "private/common.h"
  8. #include "private/sse2_64_32.h"
  9. #if defined(HAVE_AVX2INTRIN_H) && defined(HAVE_EMMINTRIN_H) && \
  10. defined(HAVE_TMMINTRIN_H) && defined(HAVE_SMMINTRIN_H)
  11. # ifdef __GNUC__
  12. # pragma GCC target("sse2")
  13. # pragma GCC target("ssse3")
  14. # pragma GCC target("sse4.1")
  15. # pragma GCC target("avx2")
  16. # endif
  17. # include <emmintrin.h>
  18. # include <immintrin.h>
  19. # include <smmintrin.h>
  20. # include <tmmintrin.h>
  21. # include "blake2b-compress-avx2.h"
  22. CRYPTO_ALIGN(64)
  23. static const uint64_t blake2b_IV[8] = {
  24. 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL,
  25. 0xa54ff53a5f1d36f1ULL, 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
  26. 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
  27. };
  28. int
  29. blake2b_compress_avx2(blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES])
  30. {
  31. __m256i a = LOADU(&S->h[0]);
  32. __m256i b = LOADU(&S->h[4]);
  33. BLAKE2B_COMPRESS_V1(a, b, block, S->t[0], S->t[1], S->f[0], S->f[1]);
  34. STOREU(&S->h[0], a);
  35. STOREU(&S->h[4], b);
  36. return 0;
  37. }
  38. #endif