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