2017-05-07 01:12:53 +00:00
|
|
|
/**
|
|
|
|
* Author......: See docs/credits.txt
|
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define NEW_SIMD_CODE
|
|
|
|
|
2019-03-22 14:16:25 +00:00
|
|
|
#ifdef KERNEL_STATIC
|
2022-02-07 08:57:08 +00:00
|
|
|
#include M2S(INCLUDE_PATH/inc_vendor.h)
|
|
|
|
#include M2S(INCLUDE_PATH/inc_types.h)
|
|
|
|
#include M2S(INCLUDE_PATH/inc_platform.cl)
|
|
|
|
#include M2S(INCLUDE_PATH/inc_common.cl)
|
|
|
|
#include M2S(INCLUDE_PATH/inc_simd.cl)
|
2019-03-22 14:16:25 +00:00
|
|
|
#endif
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2019-03-08 11:50:31 +00:00
|
|
|
typedef struct chacha20
|
|
|
|
{
|
|
|
|
u32 iv[2];
|
|
|
|
u32 plain[2];
|
|
|
|
u32 position[2];
|
|
|
|
u32 offset;
|
|
|
|
|
|
|
|
} chacha20_t;
|
|
|
|
|
2017-05-07 01:18:15 +00:00
|
|
|
#define CHACHA_CONST_00 0x61707865
|
|
|
|
#define CHACHA_CONST_01 0x3320646e
|
|
|
|
#define CHACHA_CONST_02 0x79622d32
|
|
|
|
#define CHACHA_CONST_03 0x6b206574
|
|
|
|
|
2020-06-13 09:19:00 +00:00
|
|
|
#define QR(a, b, c, d) \
|
|
|
|
do { \
|
|
|
|
x[a] = x[a] + x[b]; \
|
|
|
|
x[d] = hc_rotl32 (x[d] ^ x[a], 16); \
|
|
|
|
x[c] = x[c] + x[d]; \
|
|
|
|
x[b] = hc_rotl32 (x[b] ^ x[c], 12); \
|
|
|
|
x[a] = x[a] + x[b]; \
|
|
|
|
x[d] = hc_rotl32 (x[d] ^ x[a], 8); \
|
|
|
|
x[c] = x[c] + x[d]; \
|
|
|
|
x[b] = hc_rotl32 (x[b] ^ x[c], 7); \
|
2017-05-07 01:18:15 +00:00
|
|
|
} while (0);
|
|
|
|
|
2022-02-04 18:54:00 +00:00
|
|
|
DECLSPEC void chacha20_transform (PRIVATE_AS const u32x *w0, PRIVATE_AS const u32x *w1, PRIVATE_AS const u32 *position, const u32 offset, PRIVATE_AS const u32 *iv, PRIVATE_AS const u32 *plain, PRIVATE_AS u32x *digest)
|
2017-05-07 01:12:53 +00:00
|
|
|
{
|
2017-05-15 22:34:34 +00:00
|
|
|
/**
|
|
|
|
* Key expansion
|
|
|
|
*/
|
|
|
|
|
2017-05-07 01:18:15 +00:00
|
|
|
u32x ctx[16];
|
2018-11-01 19:17:02 +00:00
|
|
|
|
2017-05-07 01:18:15 +00:00
|
|
|
ctx[ 0] = CHACHA_CONST_00;
|
|
|
|
ctx[ 1] = CHACHA_CONST_01;
|
|
|
|
ctx[ 2] = CHACHA_CONST_02;
|
|
|
|
ctx[ 3] = CHACHA_CONST_03;
|
2018-11-01 19:17:02 +00:00
|
|
|
ctx[ 4] = w0[0];
|
2017-05-07 01:18:15 +00:00
|
|
|
ctx[ 5] = w0[1];
|
|
|
|
ctx[ 6] = w0[2];
|
|
|
|
ctx[ 7] = w0[3];
|
|
|
|
ctx[ 8] = w1[0];
|
|
|
|
ctx[ 9] = w1[1];
|
|
|
|
ctx[10] = w1[2];
|
|
|
|
ctx[11] = w1[3];
|
2017-05-07 18:02:00 +00:00
|
|
|
ctx[12] = position[0];
|
|
|
|
ctx[13] = position[1];
|
2017-05-07 01:18:15 +00:00
|
|
|
ctx[14] = iv[1];
|
|
|
|
ctx[15] = iv[0];
|
|
|
|
|
2017-05-15 22:34:34 +00:00
|
|
|
/**
|
|
|
|
* Generate 64 byte keystream
|
|
|
|
*/
|
|
|
|
|
|
|
|
u32x x[32];
|
2017-05-07 01:18:15 +00:00
|
|
|
|
|
|
|
x[ 0] = ctx[ 0];
|
|
|
|
x[ 1] = ctx[ 1];
|
|
|
|
x[ 2] = ctx[ 2];
|
|
|
|
x[ 3] = ctx[ 3];
|
|
|
|
x[ 4] = ctx[ 4];
|
|
|
|
x[ 5] = ctx[ 5];
|
|
|
|
x[ 6] = ctx[ 6];
|
|
|
|
x[ 7] = ctx[ 7];
|
|
|
|
x[ 8] = ctx[ 8];
|
|
|
|
x[ 9] = ctx[ 9];
|
|
|
|
x[10] = ctx[10];
|
|
|
|
x[11] = ctx[11];
|
|
|
|
x[12] = ctx[12];
|
|
|
|
x[13] = ctx[13];
|
|
|
|
x[14] = ctx[14];
|
|
|
|
x[15] = ctx[15];
|
|
|
|
|
2017-05-16 23:59:46 +00:00
|
|
|
#pragma unroll
|
2018-11-01 19:17:02 +00:00
|
|
|
for (u8 i = 0; i < 10; i++)
|
2017-05-15 22:34:34 +00:00
|
|
|
{
|
2017-05-07 01:18:15 +00:00
|
|
|
/* Column round */
|
2020-06-13 09:19:00 +00:00
|
|
|
QR (0, 4, 8, 12);
|
|
|
|
QR (1, 5, 9, 13);
|
|
|
|
QR (2, 6, 10, 14);
|
|
|
|
QR (3, 7, 11, 15);
|
2017-05-07 01:18:15 +00:00
|
|
|
|
|
|
|
/* Diagonal round */
|
2020-06-13 09:19:00 +00:00
|
|
|
QR (0, 5, 10, 15);
|
|
|
|
QR (1, 6, 11, 12);
|
|
|
|
QR (2, 7, 8, 13);
|
|
|
|
QR (3, 4, 9, 14);
|
2017-05-07 01:18:15 +00:00
|
|
|
}
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2017-05-07 01:18:15 +00:00
|
|
|
x[ 0] += ctx[ 0];
|
|
|
|
x[ 1] += ctx[ 1];
|
|
|
|
x[ 2] += ctx[ 2];
|
|
|
|
x[ 3] += ctx[ 3];
|
|
|
|
x[ 4] += ctx[ 4];
|
|
|
|
x[ 5] += ctx[ 5];
|
|
|
|
x[ 6] += ctx[ 6];
|
|
|
|
x[ 7] += ctx[ 7];
|
|
|
|
x[ 8] += ctx[ 8];
|
|
|
|
x[ 9] += ctx[ 9];
|
|
|
|
x[10] += ctx[10];
|
|
|
|
x[11] += ctx[11];
|
|
|
|
x[12] += ctx[12];
|
|
|
|
x[13] += ctx[13];
|
|
|
|
x[14] += ctx[14];
|
|
|
|
x[15] += ctx[15];
|
|
|
|
|
2017-05-16 02:49:44 +00:00
|
|
|
if (offset > 56)
|
2017-05-15 22:34:34 +00:00
|
|
|
{
|
|
|
|
/**
|
2018-11-01 19:17:02 +00:00
|
|
|
* Generate a second 64 byte keystream
|
2017-05-15 22:34:34 +00:00
|
|
|
*/
|
2018-11-01 19:17:02 +00:00
|
|
|
|
2020-01-14 08:57:07 +00:00
|
|
|
ctx[12] += 1;
|
|
|
|
|
|
|
|
#if VECT_SIZE == 1
|
|
|
|
if (ctx[12] == 0) ctx[13] += 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if VECT_SIZE >= 2
|
|
|
|
if (ctx[12].s0 == 0) ctx[13].s0 += 1;
|
|
|
|
if (ctx[12].s1 == 0) ctx[13].s1 += 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if VECT_SIZE >= 4
|
|
|
|
if (ctx[12].s2 == 0) ctx[13].s2 += 1;
|
|
|
|
if (ctx[12].s3 == 0) ctx[13].s3 += 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if VECT_SIZE >= 8
|
|
|
|
if (ctx[12].s4 == 0) ctx[13].s4 += 1;
|
|
|
|
if (ctx[12].s5 == 0) ctx[13].s5 += 1;
|
|
|
|
if (ctx[12].s6 == 0) ctx[13].s6 += 1;
|
|
|
|
if (ctx[12].s7 == 0) ctx[13].s7 += 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if VECT_SIZE >= 16
|
|
|
|
if (ctx[12].s8 == 0) ctx[13].s8 += 1;
|
|
|
|
if (ctx[12].s9 == 0) ctx[13].s9 += 1;
|
|
|
|
if (ctx[12].sa == 0) ctx[13].sa += 1;
|
|
|
|
if (ctx[12].sb == 0) ctx[13].sb += 1;
|
|
|
|
if (ctx[12].sc == 0) ctx[13].sc += 1;
|
|
|
|
if (ctx[12].sd == 0) ctx[13].sd += 1;
|
|
|
|
if (ctx[12].se == 0) ctx[13].se += 1;
|
|
|
|
if (ctx[12].sf == 0) ctx[13].sf += 1;
|
|
|
|
#endif
|
2017-05-15 22:34:34 +00:00
|
|
|
|
|
|
|
x[16] = ctx[ 0];
|
|
|
|
x[17] = ctx[ 1];
|
|
|
|
x[18] = ctx[ 2];
|
|
|
|
x[19] = ctx[ 3];
|
|
|
|
x[20] = ctx[ 4];
|
|
|
|
x[21] = ctx[ 5];
|
|
|
|
x[22] = ctx[ 6];
|
|
|
|
x[23] = ctx[ 7];
|
|
|
|
x[24] = ctx[ 8];
|
|
|
|
x[25] = ctx[ 9];
|
|
|
|
x[26] = ctx[10];
|
|
|
|
x[27] = ctx[11];
|
|
|
|
x[28] = ctx[12];
|
|
|
|
x[29] = ctx[13];
|
|
|
|
x[30] = ctx[14];
|
|
|
|
x[31] = ctx[15];
|
|
|
|
|
2017-05-16 23:59:46 +00:00
|
|
|
#pragma unroll
|
|
|
|
for (u8 i = 0; i < 10; i++)
|
2017-05-15 22:34:34 +00:00
|
|
|
{
|
|
|
|
/* Column round */
|
2020-06-13 09:19:00 +00:00
|
|
|
QR (16, 20, 24, 28);
|
|
|
|
QR (17, 21, 25, 29);
|
|
|
|
QR (18, 22, 26, 30);
|
|
|
|
QR (19, 23, 27, 31);
|
2017-05-15 22:34:34 +00:00
|
|
|
|
|
|
|
/* Diagonal round */
|
2020-06-13 09:19:00 +00:00
|
|
|
QR (16, 21, 26, 31);
|
|
|
|
QR (17, 22, 27, 28);
|
|
|
|
QR (18, 23, 24, 29);
|
|
|
|
QR (19, 20, 25, 30);
|
2017-05-15 22:34:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
x[16] += ctx[ 0];
|
|
|
|
x[17] += ctx[ 1];
|
|
|
|
x[18] += ctx[ 2];
|
|
|
|
x[19] += ctx[ 3];
|
|
|
|
x[20] += ctx[ 4];
|
|
|
|
x[21] += ctx[ 5];
|
|
|
|
x[22] += ctx[ 6];
|
|
|
|
x[23] += ctx[ 7];
|
|
|
|
x[24] += ctx[ 8];
|
|
|
|
x[25] += ctx[ 9];
|
|
|
|
x[26] += ctx[10];
|
|
|
|
x[27] += ctx[11];
|
|
|
|
x[28] += ctx[12];
|
|
|
|
x[29] += ctx[13];
|
|
|
|
x[30] += ctx[14];
|
|
|
|
x[31] += ctx[15];
|
|
|
|
}
|
|
|
|
|
2017-05-16 02:49:44 +00:00
|
|
|
/**
|
|
|
|
* Encrypt plaintext with keystream
|
|
|
|
*/
|
|
|
|
|
2017-05-17 11:35:56 +00:00
|
|
|
const u32 index = offset / 4;
|
|
|
|
const u32 remain = offset % 4;
|
2017-05-15 22:34:34 +00:00
|
|
|
|
|
|
|
digest[0] = plain[1];
|
|
|
|
digest[1] = plain[0];
|
|
|
|
|
|
|
|
if (remain > 0)
|
|
|
|
{
|
2017-05-17 11:35:56 +00:00
|
|
|
digest[1] ^= x[index + 0] >> ( 0 + remain * 8);
|
|
|
|
digest[1] ^= x[index + 1] << (32 - remain * 8);
|
2017-05-15 22:34:34 +00:00
|
|
|
|
2017-05-17 11:35:56 +00:00
|
|
|
digest[0] ^= x[index + 1] >> ( 0 + remain * 8);
|
2018-11-01 19:17:02 +00:00
|
|
|
digest[0] ^= x[index + 2] << (32 - remain * 8);
|
2017-05-15 22:34:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
digest[1] ^= x[index + 0];
|
2018-11-01 19:17:02 +00:00
|
|
|
digest[0] ^= x[index + 1];
|
2017-05-15 22:34:34 +00:00
|
|
|
}
|
2018-11-01 19:17:02 +00:00
|
|
|
}
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2019-03-22 21:27:58 +00:00
|
|
|
KERNEL_FQ void m15400_m04 (KERN_ATTR_VECTOR_ESALT (chacha20_t))
|
2019-06-04 09:20:32 +00:00
|
|
|
{
|
|
|
|
// fixed size 32
|
|
|
|
}
|
|
|
|
|
|
|
|
KERNEL_FQ void m15400_m08 (KERN_ATTR_VECTOR_ESALT (chacha20_t))
|
|
|
|
{
|
|
|
|
// fixed size 32
|
|
|
|
}
|
|
|
|
|
|
|
|
KERNEL_FQ void m15400_m16 (KERN_ATTR_VECTOR_ESALT (chacha20_t))
|
2018-11-01 19:17:02 +00:00
|
|
|
{
|
2017-05-07 01:12:53 +00:00
|
|
|
/**
|
|
|
|
* modifier
|
|
|
|
*/
|
|
|
|
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
|
|
|
const u64 lid = get_local_id (0);
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2017-05-17 11:35:56 +00:00
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
2017-05-16 23:59:46 +00:00
|
|
|
|
|
|
|
w0[0] = pws[gid].i[0];
|
|
|
|
w0[1] = pws[gid].i[1];
|
|
|
|
w0[2] = pws[gid].i[2];
|
|
|
|
w0[3] = pws[gid].i[3];
|
|
|
|
w1[0] = pws[gid].i[4];
|
|
|
|
w1[1] = pws[gid].i[5];
|
|
|
|
w1[2] = pws[gid].i[6];
|
|
|
|
w1[3] = pws[gid].i[7];
|
|
|
|
|
2017-05-14 11:17:51 +00:00
|
|
|
/**
|
2018-11-01 19:17:02 +00:00
|
|
|
* Salt prep
|
2017-05-14 11:17:51 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-04 09:20:32 +00:00
|
|
|
u32 iv[2];
|
2018-11-01 19:17:02 +00:00
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
iv[0] = esalt_bufs[DIGESTS_OFFSET_HOST].iv[0];
|
|
|
|
iv[1] = esalt_bufs[DIGESTS_OFFSET_HOST].iv[1];
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2019-06-04 09:20:32 +00:00
|
|
|
u32 plain[2];
|
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
plain[0] = esalt_bufs[DIGESTS_OFFSET_HOST].plain[0];
|
|
|
|
plain[1] = esalt_bufs[DIGESTS_OFFSET_HOST].plain[1];
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2019-06-04 09:20:32 +00:00
|
|
|
u32 position[2];
|
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
position[0] = esalt_bufs[DIGESTS_OFFSET_HOST].position[0];
|
|
|
|
position[1] = esalt_bufs[DIGESTS_OFFSET_HOST].position[1];
|
2019-06-04 09:20:32 +00:00
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
u32 offset = esalt_bufs[DIGESTS_OFFSET_HOST].offset;
|
2019-06-04 09:20:32 +00:00
|
|
|
|
2017-05-07 01:12:53 +00:00
|
|
|
/**
|
|
|
|
* loop
|
|
|
|
*/
|
|
|
|
|
|
|
|
u32 w0l = pws[gid].i[0];
|
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
2017-05-07 01:12:53 +00:00
|
|
|
{
|
|
|
|
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
|
|
|
|
const u32x w0x = w0l | w0r;
|
|
|
|
|
2017-05-16 23:59:46 +00:00
|
|
|
u32x w0_t[4];
|
|
|
|
u32x w1_t[4];
|
|
|
|
|
|
|
|
w0_t[0] = w0x;
|
|
|
|
w0_t[1] = w0[1];
|
|
|
|
w0_t[2] = w0[2];
|
|
|
|
w0_t[3] = w0[3];
|
|
|
|
w1_t[0] = w1[0];
|
|
|
|
w1_t[1] = w1[1];
|
|
|
|
w1_t[2] = w1[2];
|
|
|
|
w1_t[3] = w1[3];
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2017-05-07 01:18:15 +00:00
|
|
|
u32x digest[4] = { 0 };
|
|
|
|
|
2017-05-16 23:59:46 +00:00
|
|
|
chacha20_transform (w0_t, w1_t, position, offset, iv, plain, digest);
|
2017-05-07 01:18:15 +00:00
|
|
|
|
|
|
|
const u32x r0 = digest[0];
|
|
|
|
const u32x r1 = digest[1];
|
|
|
|
const u32x r2 = digest[2];
|
|
|
|
const u32x r3 = digest[3];
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2020-06-13 09:19:00 +00:00
|
|
|
COMPARE_M_SIMD (r0, r1, r2, r3);
|
2017-05-07 01:12:53 +00:00
|
|
|
}
|
2018-11-01 19:17:02 +00:00
|
|
|
}
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2019-06-04 09:20:32 +00:00
|
|
|
KERNEL_FQ void m15400_s04 (KERN_ATTR_VECTOR_ESALT (chacha20_t))
|
2017-05-07 01:12:53 +00:00
|
|
|
{
|
2019-06-04 09:20:32 +00:00
|
|
|
// fixed size 32
|
2017-05-07 01:12:53 +00:00
|
|
|
}
|
|
|
|
|
2019-06-04 09:20:32 +00:00
|
|
|
KERNEL_FQ void m15400_s08 (KERN_ATTR_VECTOR_ESALT (chacha20_t))
|
2017-05-07 01:12:53 +00:00
|
|
|
{
|
2019-06-04 09:20:32 +00:00
|
|
|
// fixed size 32
|
2017-05-07 01:12:53 +00:00
|
|
|
}
|
|
|
|
|
2019-06-04 09:20:32 +00:00
|
|
|
KERNEL_FQ void m15400_s16 (KERN_ATTR_VECTOR_ESALT (chacha20_t))
|
2018-11-01 19:17:02 +00:00
|
|
|
{
|
2017-05-07 01:12:53 +00:00
|
|
|
/**
|
|
|
|
* modifier
|
|
|
|
*/
|
|
|
|
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
|
|
|
const u64 lid = get_local_id (0);
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2017-05-17 11:35:56 +00:00
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
2017-05-16 23:59:46 +00:00
|
|
|
|
|
|
|
w0[0] = pws[gid].i[0];
|
|
|
|
w0[1] = pws[gid].i[1];
|
|
|
|
w0[2] = pws[gid].i[2];
|
|
|
|
w0[3] = pws[gid].i[3];
|
|
|
|
w1[0] = pws[gid].i[4];
|
|
|
|
w1[1] = pws[gid].i[5];
|
|
|
|
w1[2] = pws[gid].i[6];
|
|
|
|
w1[3] = pws[gid].i[7];
|
|
|
|
|
2017-05-14 11:17:51 +00:00
|
|
|
/**
|
2018-11-01 19:17:02 +00:00
|
|
|
* Salt prep
|
2017-05-14 11:17:51 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-04 09:20:32 +00:00
|
|
|
u32 iv[2];
|
2017-05-15 22:34:34 +00:00
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
iv[0] = esalt_bufs[DIGESTS_OFFSET_HOST].iv[0];
|
|
|
|
iv[1] = esalt_bufs[DIGESTS_OFFSET_HOST].iv[1];
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2019-06-04 09:20:32 +00:00
|
|
|
u32 plain[2];
|
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
plain[0] = esalt_bufs[DIGESTS_OFFSET_HOST].plain[0];
|
|
|
|
plain[1] = esalt_bufs[DIGESTS_OFFSET_HOST].plain[1];
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2019-06-04 09:20:32 +00:00
|
|
|
u32 position[2];
|
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
position[0] = esalt_bufs[DIGESTS_OFFSET_HOST].position[0];
|
|
|
|
position[1] = esalt_bufs[DIGESTS_OFFSET_HOST].position[1];
|
2019-06-04 09:20:32 +00:00
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
u32 offset = esalt_bufs[DIGESTS_OFFSET_HOST].offset;
|
2019-06-04 09:20:32 +00:00
|
|
|
|
2017-05-07 01:12:53 +00:00
|
|
|
/**
|
|
|
|
* digest
|
|
|
|
*/
|
|
|
|
|
|
|
|
const u32 search[4] =
|
|
|
|
{
|
2022-01-04 17:07:18 +00:00
|
|
|
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
|
|
|
|
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1],
|
|
|
|
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2],
|
|
|
|
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3]
|
2017-05-07 01:12:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* loop
|
|
|
|
*/
|
|
|
|
|
|
|
|
u32 w0l = pws[gid].i[0];
|
|
|
|
|
2022-01-04 17:07:18 +00:00
|
|
|
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
2017-05-07 01:12:53 +00:00
|
|
|
{
|
|
|
|
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
|
|
|
|
const u32x w0x = w0l | w0r;
|
2018-11-01 19:17:02 +00:00
|
|
|
|
2017-05-16 23:59:46 +00:00
|
|
|
u32x w0_t[4];
|
|
|
|
u32x w1_t[4];
|
|
|
|
|
|
|
|
w0_t[0] = w0x;
|
|
|
|
w0_t[1] = w0[1];
|
|
|
|
w0_t[2] = w0[2];
|
|
|
|
w0_t[3] = w0[3];
|
|
|
|
w1_t[0] = w1[0];
|
|
|
|
w1_t[1] = w1[1];
|
|
|
|
w1_t[2] = w1[2];
|
|
|
|
w1_t[3] = w1[3];
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2017-05-07 01:18:15 +00:00
|
|
|
u32x digest[4] = { 0 };
|
|
|
|
|
2017-05-16 23:59:46 +00:00
|
|
|
chacha20_transform (w0_t, w1_t, position, offset, iv, plain, digest);
|
2017-05-07 01:18:15 +00:00
|
|
|
|
|
|
|
const u32x r0 = digest[0];
|
|
|
|
const u32x r1 = digest[1];
|
|
|
|
const u32x r2 = digest[2];
|
|
|
|
const u32x r3 = digest[3];
|
2017-05-07 01:12:53 +00:00
|
|
|
|
2020-06-13 09:19:00 +00:00
|
|
|
COMPARE_S_SIMD (r0, r1, r2, r3);
|
2017-05-07 01:12:53 +00:00
|
|
|
}
|
2018-11-01 19:17:02 +00:00
|
|
|
}
|