openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libxcrypt/4.4.6-r0/git/lib/alg-yescrypt-opt.c
static inline void salsa20(salsa20_blk_t* restrict B,
                           salsa20_blk_t* restrict Bout, uint32_t doublerounds)
{
    salsa20_blk_t X;
#define x X.w

    salsa20_simd_unshuffle(B, &X);

    do
    {
#define R(a, b) (((a) << (b)) | ((a) >> (32 - (b))))
        /* Operate on columns */
        x[4] ^= R(x[0] + x[12], 7);
        x[8] ^= R(x[4] + x[0], 9);
        x[12] ^= R(x[8] + x[4], 13);
        x[0] ^= R(x[12] + x[8], 18);

        x[9] ^= R(x[5] + x[1], 7);
        x[13] ^= R(x[9] + x[5], 9);
        x[1] ^= R(x[13] + x[9], 13);
        x[5] ^= R(x[1] + x[13], 18);

        x[14] ^= R(x[10] + x[6], 7);
        x[2] ^= R(x[14] + x[10], 9);
        x[6] ^= R(x[2] + x[14], 13);
        x[10] ^= R(x[6] + x[2], 18);

        x[3] ^= R(x[15] + x[11], 7);
        x[7] ^= R(x[3] + x[15], 9);
        x[11] ^= R(x[7] + x[3], 13);
        x[15] ^= R(x[11] + x[7], 18);

        /* Operate on rows */
        x[1] ^= R(x[0] + x[3], 7);
        x[2] ^= R(x[1] + x[0], 9);
        x[3] ^= R(x[2] + x[1], 13);
        x[0] ^= R(x[3] + x[2], 18);

        x[6] ^= R(x[5] + x[4], 7);
        x[7] ^= R(x[6] + x[5], 9);
        x[4] ^= R(x[7] + x[6], 13);
        x[5] ^= R(x[4] + x[7], 18);

        x[11] ^= R(x[10] + x[9], 7);
        x[8] ^= R(x[11] + x[10], 9);
        x[9] ^= R(x[8] + x[11], 13);
        x[10] ^= R(x[9] + x[8], 18);

        x[12] ^= R(x[15] + x[14], 7);
        x[13] ^= R(x[12] + x[15], 9);
        x[14] ^= R(x[13] + x[12], 13);
        x[15] ^= R(x[14] + x[13], 18);
#undef R
    } while (--doublerounds);
#undef x

    {
        uint32_t i;
        salsa20_simd_shuffle(&X, Bout);
        for (i = 0; i < 16; i += 4)
        {
            B->w[i] = Bout->w[i] += B->w[i];
            B->w[i + 1] = Bout->w[i + 1] += B->w[i + 1];
            B->w[i + 2] = Bout->w[i + 2] += B->w[i + 2];
            B->w[i + 3] = Bout->w[i + 3] += B->w[i + 3];
        }
    }

#if 0
	/* Too expensive */
	insecure_memzero(&X, sizeof(X));
#endif
}
/**
 * salsa20(B):
 * Apply the Salsa20 core to the provided block.
 */
Apply the Salsa20 core to the provided block.
Apply the Salsa20 core to the provided block .
static inline void salsa20(salsa20_blk_t* restrict B,
                           salsa20_blk_t* restrict Bout, uint32_t doublerounds)
{
    salsa20_blk_t X;
#define x X.w
    salsa20_simd_unshuffle(B, &X);
    do
    {
#define R(a, b) (((a) << (b)) | ((a) >> (32 - (b))))
        x[4] ^= R(x[0] + x[12], 7);
        x[8] ^= R(x[4] + x[0], 9);
        x[12] ^= R(x[8] + x[4], 13);
        x[0] ^= R(x[12] + x[8], 18);
        x[9] ^= R(x[5] + x[1], 7);
        x[13] ^= R(x[9] + x[5], 9);
        x[1] ^= R(x[13] + x[9], 13);
        x[5] ^= R(x[1] + x[13], 18);
        x[14] ^= R(x[10] + x[6], 7);
        x[2] ^= R(x[14] + x[10], 9);
        x[6] ^= R(x[2] + x[14], 13);
        x[10] ^= R(x[6] + x[2], 18);
        x[3] ^= R(x[15] + x[11], 7);
        x[7] ^= R(x[3] + x[15], 9);
        x[11] ^= R(x[7] + x[3], 13);
        x[15] ^= R(x[11] + x[7], 18);
        x[1] ^= R(x[0] + x[3], 7);
        x[2] ^= R(x[1] + x[0], 9);
        x[3] ^= R(x[2] + x[1], 13);
        x[0] ^= R(x[3] + x[2], 18);
        x[6] ^= R(x[5] + x[4], 7);
        x[7] ^= R(x[6] + x[5], 9);
        x[4] ^= R(x[7] + x[6], 13);
        x[5] ^= R(x[4] + x[7], 18);
        x[11] ^= R(x[10] + x[9], 7);
        x[8] ^= R(x[11] + x[10], 9);
        x[9] ^= R(x[8] + x[11], 13);
        x[10] ^= R(x[9] + x[8], 18);
        x[12] ^= R(x[15] + x[14], 7);
        x[13] ^= R(x[12] + x[15], 9);
        x[14] ^= R(x[13] + x[12], 13);
        x[15] ^= R(x[14] + x[13], 18);
#undef R
    } while (--doublerounds);
#undef x
    {
        uint32_t i;
        salsa20_simd_shuffle(&X, Bout);
        for (i = 0; i < 16; i += 4)
        {
            B->w[i] = Bout->w[i] += B->w[i];
            B->w[i + 1] = Bout->w[i + 1] += B->w[i + 1];
            B->w[i + 2] = Bout->w[i + 2] += B->w[i + 2];
            B->w[i + 3] = Bout->w[i + 3] += B->w[i + 3];
        }
    }
#if 0
	insecure_memzero(&X, sizeof(X));
#endif
}
static inline void salsa20 ( salsa20_blk_t * restrict B , salsa20_blk_t * restrict Bout , uint32_t doublerounds ) { salsa20_blk_t X ; #define x  X.w salsa20_simd_unshuffle ( B , & X ) ; do { #define R ( a , b )  (((a) << (b)) | ((a) >> (32 - (b)))) x [ 4 ] ^= R ( x [ 0 ] + x [ 12 ] , 7 ) ; x [ 8 ] ^= R ( x [ 4 ] + x [ 0 ] , 9 ) ; x [ 12 ] ^= R ( x [ 8 ] + x [ 4 ] , 13 ) ; x [ 0 ] ^= R ( x [ 12 ] + x [ 8 ] , 18 ) ; x [ 9 ] ^= R ( x [ 5 ] + x [ 1 ] , 7 ) ; x [ 13 ] ^= R ( x [ 9 ] + x [ 5 ] , 9 ) ; x [ 1 ] ^= R ( x [ 13 ] + x [ 9 ] , 13 ) ; x [ 5 ] ^= R ( x [ 1 ] + x [ 13 ] , 18 ) ; x [ 14 ] ^= R ( x [ 10 ] + x [ 6 ] , 7 ) ; x [ 2 ] ^= R ( x [ 14 ] + x [ 10 ] , 9 ) ; x [ 6 ] ^= R ( x [ 2 ] + x [ 14 ] , 13 ) ; x [ 10 ] ^= R ( x [ 6 ] + x [ 2 ] , 18 ) ; x [ 3 ] ^= R ( x [ 15 ] + x [ 11 ] , 7 ) ; x [ 7 ] ^= R ( x [ 3 ] + x [ 15 ] , 9 ) ; x [ 11 ] ^= R ( x [ 7 ] + x [ 3 ] , 13 ) ; x [ 15 ] ^= R ( x [ 11 ] + x [ 7 ] , 18 ) ; x [ 1 ] ^= R ( x [ 0 ] + x [ 3 ] , 7 ) ; x [ 2 ] ^= R ( x [ 1 ] + x [ 0 ] , 9 ) ; x [ 3 ] ^= R ( x [ 2 ] + x [ 1 ] , 13 ) ; x [ 0 ] ^= R ( x [ 3 ] + x [ 2 ] , 18 ) ; x [ 6 ] ^= R ( x [ 5 ] + x [ 4 ] , 7 ) ; x [ 7 ] ^= R ( x [ 6 ] + x [ 5 ] , 9 ) ; x [ 4 ] ^= R ( x [ 7 ] + x [ 6 ] , 13 ) ; x [ 5 ] ^= R ( x [ 4 ] + x [ 7 ] , 18 ) ; x [ 11 ] ^= R ( x [ 10 ] + x [ 9 ] , 7 ) ; x [ 8 ] ^= R ( x [ 11 ] + x [ 10 ] , 9 ) ; x [ 9 ] ^= R ( x [ 8 ] + x [ 11 ] , 13 ) ; x [ 10 ] ^= R ( x [ 9 ] + x [ 8 ] , 18 ) ; x [ 12 ] ^= R ( x [ 15 ] + x [ 14 ] , 7 ) ; x [ 13 ] ^= R ( x [ 12 ] + x [ 15 ] , 9 ) ; x [ 14 ] ^= R ( x [ 13 ] + x [ 12 ] , 13 ) ; x [ 15 ] ^= R ( x [ 14 ] + x [ 13 ] , 18 ) ; #undef  R } while ( -- doublerounds ) ; #undef  x { uint32_t i ; salsa20_simd_shuffle ( & X , Bout ) ; for ( i = 0 ; i < 16 ; i += 4 ) { B -> w [ i ] = Bout -> w [ i ] += B -> w [ i ] ; B -> w [ i + 1 ] = Bout -> w [ i + 1 ] += B -> w [ i + 1 ] ; B -> w [ i + 2 ] = Bout -> w [ i + 2 ] += B -> w [ i + 2 ] ; B -> w [ i + 3 ] = Bout -> w [ i + 3 ] += B -> w [ i + 3 ] ; } } #if 0 insecure_memzero ( & X , sizeof ( X ) ) ; #endif }
salsa20(B):
 Apply the Salsa20 core to the provided block.
salsa20 ( B ) : Apply the Salsa20 core to the provided block .
/* Operate on columns */ /* Operate on rows */ /* Too expensive */