MCPcopy Create free account
hub / github.com/F-Stack/f-stack / blake2s_compress

Function blake2s_compress

freebsd/contrib/libb2/blake2s.c:273–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271
272
273static inline int blake2s_compress( blake2s_state *S, const uint8_t block[BLAKE2S_BLOCKBYTES] )
274{
275 __m128i row1, row2, row3, row4;
276 __m128i buf1, buf2, buf3, buf4;
277#if defined(HAVE_SSE4_1)
278 __m128i t0, t1;
279#if !defined(HAVE_XOP)
280 __m128i t2;
281#endif
282#endif
283 __m128i ff0, ff1;
284#if defined(HAVE_SSSE3) && !defined(HAVE_XOP)
285 const __m128i r8 = _mm_set_epi8( 12, 15, 14, 13, 8, 11, 10, 9, 4, 7, 6, 5, 0, 3, 2, 1 );
286 const __m128i r16 = _mm_set_epi8( 13, 12, 15, 14, 9, 8, 11, 10, 5, 4, 7, 6, 1, 0, 3, 2 );
287#endif
288#if defined(HAVE_SSE4_1)
289 const __m128i m0 = LOADU( block + 00 );
290 const __m128i m1 = LOADU( block + 16 );
291 const __m128i m2 = LOADU( block + 32 );
292 const __m128i m3 = LOADU( block + 48 );
293#else
294 const uint32_t m0 = ( ( uint32_t * )block )[ 0];
295 const uint32_t m1 = ( ( uint32_t * )block )[ 1];
296 const uint32_t m2 = ( ( uint32_t * )block )[ 2];
297 const uint32_t m3 = ( ( uint32_t * )block )[ 3];
298 const uint32_t m4 = ( ( uint32_t * )block )[ 4];
299 const uint32_t m5 = ( ( uint32_t * )block )[ 5];
300 const uint32_t m6 = ( ( uint32_t * )block )[ 6];
301 const uint32_t m7 = ( ( uint32_t * )block )[ 7];
302 const uint32_t m8 = ( ( uint32_t * )block )[ 8];
303 const uint32_t m9 = ( ( uint32_t * )block )[ 9];
304 const uint32_t m10 = ( ( uint32_t * )block )[10];
305 const uint32_t m11 = ( ( uint32_t * )block )[11];
306 const uint32_t m12 = ( ( uint32_t * )block )[12];
307 const uint32_t m13 = ( ( uint32_t * )block )[13];
308 const uint32_t m14 = ( ( uint32_t * )block )[14];
309 const uint32_t m15 = ( ( uint32_t * )block )[15];
310#endif
311 row1 = ff0 = LOADU( &S->h[0] );
312 row2 = ff1 = LOADU( &S->h[4] );
313 row3 = _mm_setr_epi32( 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A );
314 row4 = _mm_xor_si128( _mm_setr_epi32( 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 ), LOADU( &S->t[0] ) );
315 ROUND( 0 );
316 ROUND( 1 );
317 ROUND( 2 );
318 ROUND( 3 );
319 ROUND( 4 );
320 ROUND( 5 );
321 ROUND( 6 );
322 ROUND( 7 );
323 ROUND( 8 );
324 ROUND( 9 );
325 STOREU( &S->h[0], _mm_xor_si128( ff0, _mm_xor_si128( row1, row3 ) ) );
326 STOREU( &S->h[4], _mm_xor_si128( ff1, _mm_xor_si128( row2, row4 ) ) );
327 return 0;
328}
329
330

Callers 2

blake2s_updateFunction · 0.70
blake2s_finalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected