18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Serpent Cipher 8-way parallel algorithm (x86_64/SSE2) 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2011 Jussi Kivilinna <jussi.kivilinna@mbnet.fi> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Based on crypto/serpent.c by 88c2ecf20Sopenharmony_ci * Copyright (C) 2002 Dag Arne Osvik <osvik@ii.uib.no> 98c2ecf20Sopenharmony_ci * 2003 Herbert Valerio Riedel <hvr@gnu.org> 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/linkage.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci.file "serpent-sse2-x86_64-asm_64.S" 158c2ecf20Sopenharmony_ci.text 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define CTX %rdi 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/********************************************************************** 208c2ecf20Sopenharmony_ci 8-way SSE2 serpent 218c2ecf20Sopenharmony_ci **********************************************************************/ 228c2ecf20Sopenharmony_ci#define RA1 %xmm0 238c2ecf20Sopenharmony_ci#define RB1 %xmm1 248c2ecf20Sopenharmony_ci#define RC1 %xmm2 258c2ecf20Sopenharmony_ci#define RD1 %xmm3 268c2ecf20Sopenharmony_ci#define RE1 %xmm4 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define RA2 %xmm5 298c2ecf20Sopenharmony_ci#define RB2 %xmm6 308c2ecf20Sopenharmony_ci#define RC2 %xmm7 318c2ecf20Sopenharmony_ci#define RD2 %xmm8 328c2ecf20Sopenharmony_ci#define RE2 %xmm9 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define RNOT %xmm10 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define RK0 %xmm11 378c2ecf20Sopenharmony_ci#define RK1 %xmm12 388c2ecf20Sopenharmony_ci#define RK2 %xmm13 398c2ecf20Sopenharmony_ci#define RK3 %xmm14 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define S0_1(x0, x1, x2, x3, x4) \ 428c2ecf20Sopenharmony_ci movdqa x3, x4; \ 438c2ecf20Sopenharmony_ci por x0, x3; \ 448c2ecf20Sopenharmony_ci pxor x4, x0; \ 458c2ecf20Sopenharmony_ci pxor x2, x4; \ 468c2ecf20Sopenharmony_ci pxor RNOT, x4; \ 478c2ecf20Sopenharmony_ci pxor x1, x3; \ 488c2ecf20Sopenharmony_ci pand x0, x1; \ 498c2ecf20Sopenharmony_ci pxor x4, x1; \ 508c2ecf20Sopenharmony_ci pxor x0, x2; 518c2ecf20Sopenharmony_ci#define S0_2(x0, x1, x2, x3, x4) \ 528c2ecf20Sopenharmony_ci pxor x3, x0; \ 538c2ecf20Sopenharmony_ci por x0, x4; \ 548c2ecf20Sopenharmony_ci pxor x2, x0; \ 558c2ecf20Sopenharmony_ci pand x1, x2; \ 568c2ecf20Sopenharmony_ci pxor x2, x3; \ 578c2ecf20Sopenharmony_ci pxor RNOT, x1; \ 588c2ecf20Sopenharmony_ci pxor x4, x2; \ 598c2ecf20Sopenharmony_ci pxor x2, x1; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#define S1_1(x0, x1, x2, x3, x4) \ 628c2ecf20Sopenharmony_ci movdqa x1, x4; \ 638c2ecf20Sopenharmony_ci pxor x0, x1; \ 648c2ecf20Sopenharmony_ci pxor x3, x0; \ 658c2ecf20Sopenharmony_ci pxor RNOT, x3; \ 668c2ecf20Sopenharmony_ci pand x1, x4; \ 678c2ecf20Sopenharmony_ci por x1, x0; \ 688c2ecf20Sopenharmony_ci pxor x2, x3; \ 698c2ecf20Sopenharmony_ci pxor x3, x0; \ 708c2ecf20Sopenharmony_ci pxor x3, x1; 718c2ecf20Sopenharmony_ci#define S1_2(x0, x1, x2, x3, x4) \ 728c2ecf20Sopenharmony_ci pxor x4, x3; \ 738c2ecf20Sopenharmony_ci por x4, x1; \ 748c2ecf20Sopenharmony_ci pxor x2, x4; \ 758c2ecf20Sopenharmony_ci pand x0, x2; \ 768c2ecf20Sopenharmony_ci pxor x1, x2; \ 778c2ecf20Sopenharmony_ci por x0, x1; \ 788c2ecf20Sopenharmony_ci pxor RNOT, x0; \ 798c2ecf20Sopenharmony_ci pxor x2, x0; \ 808c2ecf20Sopenharmony_ci pxor x1, x4; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define S2_1(x0, x1, x2, x3, x4) \ 838c2ecf20Sopenharmony_ci pxor RNOT, x3; \ 848c2ecf20Sopenharmony_ci pxor x0, x1; \ 858c2ecf20Sopenharmony_ci movdqa x0, x4; \ 868c2ecf20Sopenharmony_ci pand x2, x0; \ 878c2ecf20Sopenharmony_ci pxor x3, x0; \ 888c2ecf20Sopenharmony_ci por x4, x3; \ 898c2ecf20Sopenharmony_ci pxor x1, x2; \ 908c2ecf20Sopenharmony_ci pxor x1, x3; \ 918c2ecf20Sopenharmony_ci pand x0, x1; 928c2ecf20Sopenharmony_ci#define S2_2(x0, x1, x2, x3, x4) \ 938c2ecf20Sopenharmony_ci pxor x2, x0; \ 948c2ecf20Sopenharmony_ci pand x3, x2; \ 958c2ecf20Sopenharmony_ci por x1, x3; \ 968c2ecf20Sopenharmony_ci pxor RNOT, x0; \ 978c2ecf20Sopenharmony_ci pxor x0, x3; \ 988c2ecf20Sopenharmony_ci pxor x0, x4; \ 998c2ecf20Sopenharmony_ci pxor x2, x0; \ 1008c2ecf20Sopenharmony_ci por x2, x1; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define S3_1(x0, x1, x2, x3, x4) \ 1038c2ecf20Sopenharmony_ci movdqa x1, x4; \ 1048c2ecf20Sopenharmony_ci pxor x3, x1; \ 1058c2ecf20Sopenharmony_ci por x0, x3; \ 1068c2ecf20Sopenharmony_ci pand x0, x4; \ 1078c2ecf20Sopenharmony_ci pxor x2, x0; \ 1088c2ecf20Sopenharmony_ci pxor x1, x2; \ 1098c2ecf20Sopenharmony_ci pand x3, x1; \ 1108c2ecf20Sopenharmony_ci pxor x3, x2; \ 1118c2ecf20Sopenharmony_ci por x4, x0; \ 1128c2ecf20Sopenharmony_ci pxor x3, x4; 1138c2ecf20Sopenharmony_ci#define S3_2(x0, x1, x2, x3, x4) \ 1148c2ecf20Sopenharmony_ci pxor x0, x1; \ 1158c2ecf20Sopenharmony_ci pand x3, x0; \ 1168c2ecf20Sopenharmony_ci pand x4, x3; \ 1178c2ecf20Sopenharmony_ci pxor x2, x3; \ 1188c2ecf20Sopenharmony_ci por x1, x4; \ 1198c2ecf20Sopenharmony_ci pand x1, x2; \ 1208c2ecf20Sopenharmony_ci pxor x3, x4; \ 1218c2ecf20Sopenharmony_ci pxor x3, x0; \ 1228c2ecf20Sopenharmony_ci pxor x2, x3; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci#define S4_1(x0, x1, x2, x3, x4) \ 1258c2ecf20Sopenharmony_ci movdqa x3, x4; \ 1268c2ecf20Sopenharmony_ci pand x0, x3; \ 1278c2ecf20Sopenharmony_ci pxor x4, x0; \ 1288c2ecf20Sopenharmony_ci pxor x2, x3; \ 1298c2ecf20Sopenharmony_ci por x4, x2; \ 1308c2ecf20Sopenharmony_ci pxor x1, x0; \ 1318c2ecf20Sopenharmony_ci pxor x3, x4; \ 1328c2ecf20Sopenharmony_ci por x0, x2; \ 1338c2ecf20Sopenharmony_ci pxor x1, x2; 1348c2ecf20Sopenharmony_ci#define S4_2(x0, x1, x2, x3, x4) \ 1358c2ecf20Sopenharmony_ci pand x0, x1; \ 1368c2ecf20Sopenharmony_ci pxor x4, x1; \ 1378c2ecf20Sopenharmony_ci pand x2, x4; \ 1388c2ecf20Sopenharmony_ci pxor x3, x2; \ 1398c2ecf20Sopenharmony_ci pxor x0, x4; \ 1408c2ecf20Sopenharmony_ci por x1, x3; \ 1418c2ecf20Sopenharmony_ci pxor RNOT, x1; \ 1428c2ecf20Sopenharmony_ci pxor x0, x3; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci#define S5_1(x0, x1, x2, x3, x4) \ 1458c2ecf20Sopenharmony_ci movdqa x1, x4; \ 1468c2ecf20Sopenharmony_ci por x0, x1; \ 1478c2ecf20Sopenharmony_ci pxor x1, x2; \ 1488c2ecf20Sopenharmony_ci pxor RNOT, x3; \ 1498c2ecf20Sopenharmony_ci pxor x0, x4; \ 1508c2ecf20Sopenharmony_ci pxor x2, x0; \ 1518c2ecf20Sopenharmony_ci pand x4, x1; \ 1528c2ecf20Sopenharmony_ci por x3, x4; \ 1538c2ecf20Sopenharmony_ci pxor x0, x4; 1548c2ecf20Sopenharmony_ci#define S5_2(x0, x1, x2, x3, x4) \ 1558c2ecf20Sopenharmony_ci pand x3, x0; \ 1568c2ecf20Sopenharmony_ci pxor x3, x1; \ 1578c2ecf20Sopenharmony_ci pxor x2, x3; \ 1588c2ecf20Sopenharmony_ci pxor x1, x0; \ 1598c2ecf20Sopenharmony_ci pand x4, x2; \ 1608c2ecf20Sopenharmony_ci pxor x2, x1; \ 1618c2ecf20Sopenharmony_ci pand x0, x2; \ 1628c2ecf20Sopenharmony_ci pxor x2, x3; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci#define S6_1(x0, x1, x2, x3, x4) \ 1658c2ecf20Sopenharmony_ci movdqa x1, x4; \ 1668c2ecf20Sopenharmony_ci pxor x0, x3; \ 1678c2ecf20Sopenharmony_ci pxor x2, x1; \ 1688c2ecf20Sopenharmony_ci pxor x0, x2; \ 1698c2ecf20Sopenharmony_ci pand x3, x0; \ 1708c2ecf20Sopenharmony_ci por x3, x1; \ 1718c2ecf20Sopenharmony_ci pxor RNOT, x4; \ 1728c2ecf20Sopenharmony_ci pxor x1, x0; \ 1738c2ecf20Sopenharmony_ci pxor x2, x1; 1748c2ecf20Sopenharmony_ci#define S6_2(x0, x1, x2, x3, x4) \ 1758c2ecf20Sopenharmony_ci pxor x4, x3; \ 1768c2ecf20Sopenharmony_ci pxor x0, x4; \ 1778c2ecf20Sopenharmony_ci pand x0, x2; \ 1788c2ecf20Sopenharmony_ci pxor x1, x4; \ 1798c2ecf20Sopenharmony_ci pxor x3, x2; \ 1808c2ecf20Sopenharmony_ci pand x1, x3; \ 1818c2ecf20Sopenharmony_ci pxor x0, x3; \ 1828c2ecf20Sopenharmony_ci pxor x2, x1; 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci#define S7_1(x0, x1, x2, x3, x4) \ 1858c2ecf20Sopenharmony_ci pxor RNOT, x1; \ 1868c2ecf20Sopenharmony_ci movdqa x1, x4; \ 1878c2ecf20Sopenharmony_ci pxor RNOT, x0; \ 1888c2ecf20Sopenharmony_ci pand x2, x1; \ 1898c2ecf20Sopenharmony_ci pxor x3, x1; \ 1908c2ecf20Sopenharmony_ci por x4, x3; \ 1918c2ecf20Sopenharmony_ci pxor x2, x4; \ 1928c2ecf20Sopenharmony_ci pxor x3, x2; \ 1938c2ecf20Sopenharmony_ci pxor x0, x3; \ 1948c2ecf20Sopenharmony_ci por x1, x0; 1958c2ecf20Sopenharmony_ci#define S7_2(x0, x1, x2, x3, x4) \ 1968c2ecf20Sopenharmony_ci pand x0, x2; \ 1978c2ecf20Sopenharmony_ci pxor x4, x0; \ 1988c2ecf20Sopenharmony_ci pxor x3, x4; \ 1998c2ecf20Sopenharmony_ci pand x0, x3; \ 2008c2ecf20Sopenharmony_ci pxor x1, x4; \ 2018c2ecf20Sopenharmony_ci pxor x4, x2; \ 2028c2ecf20Sopenharmony_ci pxor x1, x3; \ 2038c2ecf20Sopenharmony_ci por x0, x4; \ 2048c2ecf20Sopenharmony_ci pxor x1, x4; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci#define SI0_1(x0, x1, x2, x3, x4) \ 2078c2ecf20Sopenharmony_ci movdqa x3, x4; \ 2088c2ecf20Sopenharmony_ci pxor x0, x1; \ 2098c2ecf20Sopenharmony_ci por x1, x3; \ 2108c2ecf20Sopenharmony_ci pxor x1, x4; \ 2118c2ecf20Sopenharmony_ci pxor RNOT, x0; \ 2128c2ecf20Sopenharmony_ci pxor x3, x2; \ 2138c2ecf20Sopenharmony_ci pxor x0, x3; \ 2148c2ecf20Sopenharmony_ci pand x1, x0; \ 2158c2ecf20Sopenharmony_ci pxor x2, x0; 2168c2ecf20Sopenharmony_ci#define SI0_2(x0, x1, x2, x3, x4) \ 2178c2ecf20Sopenharmony_ci pand x3, x2; \ 2188c2ecf20Sopenharmony_ci pxor x4, x3; \ 2198c2ecf20Sopenharmony_ci pxor x3, x2; \ 2208c2ecf20Sopenharmony_ci pxor x3, x1; \ 2218c2ecf20Sopenharmony_ci pand x0, x3; \ 2228c2ecf20Sopenharmony_ci pxor x0, x1; \ 2238c2ecf20Sopenharmony_ci pxor x2, x0; \ 2248c2ecf20Sopenharmony_ci pxor x3, x4; 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci#define SI1_1(x0, x1, x2, x3, x4) \ 2278c2ecf20Sopenharmony_ci pxor x3, x1; \ 2288c2ecf20Sopenharmony_ci movdqa x0, x4; \ 2298c2ecf20Sopenharmony_ci pxor x2, x0; \ 2308c2ecf20Sopenharmony_ci pxor RNOT, x2; \ 2318c2ecf20Sopenharmony_ci por x1, x4; \ 2328c2ecf20Sopenharmony_ci pxor x3, x4; \ 2338c2ecf20Sopenharmony_ci pand x1, x3; \ 2348c2ecf20Sopenharmony_ci pxor x2, x1; \ 2358c2ecf20Sopenharmony_ci pand x4, x2; 2368c2ecf20Sopenharmony_ci#define SI1_2(x0, x1, x2, x3, x4) \ 2378c2ecf20Sopenharmony_ci pxor x1, x4; \ 2388c2ecf20Sopenharmony_ci por x3, x1; \ 2398c2ecf20Sopenharmony_ci pxor x0, x3; \ 2408c2ecf20Sopenharmony_ci pxor x0, x2; \ 2418c2ecf20Sopenharmony_ci por x4, x0; \ 2428c2ecf20Sopenharmony_ci pxor x4, x2; \ 2438c2ecf20Sopenharmony_ci pxor x0, x1; \ 2448c2ecf20Sopenharmony_ci pxor x1, x4; 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci#define SI2_1(x0, x1, x2, x3, x4) \ 2478c2ecf20Sopenharmony_ci pxor x1, x2; \ 2488c2ecf20Sopenharmony_ci movdqa x3, x4; \ 2498c2ecf20Sopenharmony_ci pxor RNOT, x3; \ 2508c2ecf20Sopenharmony_ci por x2, x3; \ 2518c2ecf20Sopenharmony_ci pxor x4, x2; \ 2528c2ecf20Sopenharmony_ci pxor x0, x4; \ 2538c2ecf20Sopenharmony_ci pxor x1, x3; \ 2548c2ecf20Sopenharmony_ci por x2, x1; \ 2558c2ecf20Sopenharmony_ci pxor x0, x2; 2568c2ecf20Sopenharmony_ci#define SI2_2(x0, x1, x2, x3, x4) \ 2578c2ecf20Sopenharmony_ci pxor x4, x1; \ 2588c2ecf20Sopenharmony_ci por x3, x4; \ 2598c2ecf20Sopenharmony_ci pxor x3, x2; \ 2608c2ecf20Sopenharmony_ci pxor x2, x4; \ 2618c2ecf20Sopenharmony_ci pand x1, x2; \ 2628c2ecf20Sopenharmony_ci pxor x3, x2; \ 2638c2ecf20Sopenharmony_ci pxor x4, x3; \ 2648c2ecf20Sopenharmony_ci pxor x0, x4; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci#define SI3_1(x0, x1, x2, x3, x4) \ 2678c2ecf20Sopenharmony_ci pxor x1, x2; \ 2688c2ecf20Sopenharmony_ci movdqa x1, x4; \ 2698c2ecf20Sopenharmony_ci pand x2, x1; \ 2708c2ecf20Sopenharmony_ci pxor x0, x1; \ 2718c2ecf20Sopenharmony_ci por x4, x0; \ 2728c2ecf20Sopenharmony_ci pxor x3, x4; \ 2738c2ecf20Sopenharmony_ci pxor x3, x0; \ 2748c2ecf20Sopenharmony_ci por x1, x3; \ 2758c2ecf20Sopenharmony_ci pxor x2, x1; 2768c2ecf20Sopenharmony_ci#define SI3_2(x0, x1, x2, x3, x4) \ 2778c2ecf20Sopenharmony_ci pxor x3, x1; \ 2788c2ecf20Sopenharmony_ci pxor x2, x0; \ 2798c2ecf20Sopenharmony_ci pxor x3, x2; \ 2808c2ecf20Sopenharmony_ci pand x1, x3; \ 2818c2ecf20Sopenharmony_ci pxor x0, x1; \ 2828c2ecf20Sopenharmony_ci pand x2, x0; \ 2838c2ecf20Sopenharmony_ci pxor x3, x4; \ 2848c2ecf20Sopenharmony_ci pxor x0, x3; \ 2858c2ecf20Sopenharmony_ci pxor x1, x0; 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci#define SI4_1(x0, x1, x2, x3, x4) \ 2888c2ecf20Sopenharmony_ci pxor x3, x2; \ 2898c2ecf20Sopenharmony_ci movdqa x0, x4; \ 2908c2ecf20Sopenharmony_ci pand x1, x0; \ 2918c2ecf20Sopenharmony_ci pxor x2, x0; \ 2928c2ecf20Sopenharmony_ci por x3, x2; \ 2938c2ecf20Sopenharmony_ci pxor RNOT, x4; \ 2948c2ecf20Sopenharmony_ci pxor x0, x1; \ 2958c2ecf20Sopenharmony_ci pxor x2, x0; \ 2968c2ecf20Sopenharmony_ci pand x4, x2; 2978c2ecf20Sopenharmony_ci#define SI4_2(x0, x1, x2, x3, x4) \ 2988c2ecf20Sopenharmony_ci pxor x0, x2; \ 2998c2ecf20Sopenharmony_ci por x4, x0; \ 3008c2ecf20Sopenharmony_ci pxor x3, x0; \ 3018c2ecf20Sopenharmony_ci pand x2, x3; \ 3028c2ecf20Sopenharmony_ci pxor x3, x4; \ 3038c2ecf20Sopenharmony_ci pxor x1, x3; \ 3048c2ecf20Sopenharmony_ci pand x0, x1; \ 3058c2ecf20Sopenharmony_ci pxor x1, x4; \ 3068c2ecf20Sopenharmony_ci pxor x3, x0; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci#define SI5_1(x0, x1, x2, x3, x4) \ 3098c2ecf20Sopenharmony_ci movdqa x1, x4; \ 3108c2ecf20Sopenharmony_ci por x2, x1; \ 3118c2ecf20Sopenharmony_ci pxor x4, x2; \ 3128c2ecf20Sopenharmony_ci pxor x3, x1; \ 3138c2ecf20Sopenharmony_ci pand x4, x3; \ 3148c2ecf20Sopenharmony_ci pxor x3, x2; \ 3158c2ecf20Sopenharmony_ci por x0, x3; \ 3168c2ecf20Sopenharmony_ci pxor RNOT, x0; \ 3178c2ecf20Sopenharmony_ci pxor x2, x3; \ 3188c2ecf20Sopenharmony_ci por x0, x2; 3198c2ecf20Sopenharmony_ci#define SI5_2(x0, x1, x2, x3, x4) \ 3208c2ecf20Sopenharmony_ci pxor x1, x4; \ 3218c2ecf20Sopenharmony_ci pxor x4, x2; \ 3228c2ecf20Sopenharmony_ci pand x0, x4; \ 3238c2ecf20Sopenharmony_ci pxor x1, x0; \ 3248c2ecf20Sopenharmony_ci pxor x3, x1; \ 3258c2ecf20Sopenharmony_ci pand x2, x0; \ 3268c2ecf20Sopenharmony_ci pxor x3, x2; \ 3278c2ecf20Sopenharmony_ci pxor x2, x0; \ 3288c2ecf20Sopenharmony_ci pxor x4, x2; \ 3298c2ecf20Sopenharmony_ci pxor x3, x4; 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci#define SI6_1(x0, x1, x2, x3, x4) \ 3328c2ecf20Sopenharmony_ci pxor x2, x0; \ 3338c2ecf20Sopenharmony_ci movdqa x0, x4; \ 3348c2ecf20Sopenharmony_ci pand x3, x0; \ 3358c2ecf20Sopenharmony_ci pxor x3, x2; \ 3368c2ecf20Sopenharmony_ci pxor x2, x0; \ 3378c2ecf20Sopenharmony_ci pxor x1, x3; \ 3388c2ecf20Sopenharmony_ci por x4, x2; \ 3398c2ecf20Sopenharmony_ci pxor x3, x2; \ 3408c2ecf20Sopenharmony_ci pand x0, x3; 3418c2ecf20Sopenharmony_ci#define SI6_2(x0, x1, x2, x3, x4) \ 3428c2ecf20Sopenharmony_ci pxor RNOT, x0; \ 3438c2ecf20Sopenharmony_ci pxor x1, x3; \ 3448c2ecf20Sopenharmony_ci pand x2, x1; \ 3458c2ecf20Sopenharmony_ci pxor x0, x4; \ 3468c2ecf20Sopenharmony_ci pxor x4, x3; \ 3478c2ecf20Sopenharmony_ci pxor x2, x4; \ 3488c2ecf20Sopenharmony_ci pxor x1, x0; \ 3498c2ecf20Sopenharmony_ci pxor x0, x2; 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci#define SI7_1(x0, x1, x2, x3, x4) \ 3528c2ecf20Sopenharmony_ci movdqa x3, x4; \ 3538c2ecf20Sopenharmony_ci pand x0, x3; \ 3548c2ecf20Sopenharmony_ci pxor x2, x0; \ 3558c2ecf20Sopenharmony_ci por x4, x2; \ 3568c2ecf20Sopenharmony_ci pxor x1, x4; \ 3578c2ecf20Sopenharmony_ci pxor RNOT, x0; \ 3588c2ecf20Sopenharmony_ci por x3, x1; \ 3598c2ecf20Sopenharmony_ci pxor x0, x4; \ 3608c2ecf20Sopenharmony_ci pand x2, x0; \ 3618c2ecf20Sopenharmony_ci pxor x1, x0; 3628c2ecf20Sopenharmony_ci#define SI7_2(x0, x1, x2, x3, x4) \ 3638c2ecf20Sopenharmony_ci pand x2, x1; \ 3648c2ecf20Sopenharmony_ci pxor x2, x3; \ 3658c2ecf20Sopenharmony_ci pxor x3, x4; \ 3668c2ecf20Sopenharmony_ci pand x3, x2; \ 3678c2ecf20Sopenharmony_ci por x0, x3; \ 3688c2ecf20Sopenharmony_ci pxor x4, x1; \ 3698c2ecf20Sopenharmony_ci pxor x4, x3; \ 3708c2ecf20Sopenharmony_ci pand x0, x4; \ 3718c2ecf20Sopenharmony_ci pxor x2, x4; 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci#define get_key(i, j, t) \ 3748c2ecf20Sopenharmony_ci movd (4*(i)+(j))*4(CTX), t; \ 3758c2ecf20Sopenharmony_ci pshufd $0, t, t; 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci#define K2(x0, x1, x2, x3, x4, i) \ 3788c2ecf20Sopenharmony_ci get_key(i, 0, RK0); \ 3798c2ecf20Sopenharmony_ci get_key(i, 1, RK1); \ 3808c2ecf20Sopenharmony_ci get_key(i, 2, RK2); \ 3818c2ecf20Sopenharmony_ci get_key(i, 3, RK3); \ 3828c2ecf20Sopenharmony_ci pxor RK0, x0 ## 1; \ 3838c2ecf20Sopenharmony_ci pxor RK1, x1 ## 1; \ 3848c2ecf20Sopenharmony_ci pxor RK2, x2 ## 1; \ 3858c2ecf20Sopenharmony_ci pxor RK3, x3 ## 1; \ 3868c2ecf20Sopenharmony_ci pxor RK0, x0 ## 2; \ 3878c2ecf20Sopenharmony_ci pxor RK1, x1 ## 2; \ 3888c2ecf20Sopenharmony_ci pxor RK2, x2 ## 2; \ 3898c2ecf20Sopenharmony_ci pxor RK3, x3 ## 2; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci#define LK2(x0, x1, x2, x3, x4, i) \ 3928c2ecf20Sopenharmony_ci movdqa x0 ## 1, x4 ## 1; \ 3938c2ecf20Sopenharmony_ci pslld $13, x0 ## 1; \ 3948c2ecf20Sopenharmony_ci psrld $(32 - 13), x4 ## 1; \ 3958c2ecf20Sopenharmony_ci por x4 ## 1, x0 ## 1; \ 3968c2ecf20Sopenharmony_ci pxor x0 ## 1, x1 ## 1; \ 3978c2ecf20Sopenharmony_ci movdqa x2 ## 1, x4 ## 1; \ 3988c2ecf20Sopenharmony_ci pslld $3, x2 ## 1; \ 3998c2ecf20Sopenharmony_ci psrld $(32 - 3), x4 ## 1; \ 4008c2ecf20Sopenharmony_ci por x4 ## 1, x2 ## 1; \ 4018c2ecf20Sopenharmony_ci pxor x2 ## 1, x1 ## 1; \ 4028c2ecf20Sopenharmony_ci movdqa x0 ## 2, x4 ## 2; \ 4038c2ecf20Sopenharmony_ci pslld $13, x0 ## 2; \ 4048c2ecf20Sopenharmony_ci psrld $(32 - 13), x4 ## 2; \ 4058c2ecf20Sopenharmony_ci por x4 ## 2, x0 ## 2; \ 4068c2ecf20Sopenharmony_ci pxor x0 ## 2, x1 ## 2; \ 4078c2ecf20Sopenharmony_ci movdqa x2 ## 2, x4 ## 2; \ 4088c2ecf20Sopenharmony_ci pslld $3, x2 ## 2; \ 4098c2ecf20Sopenharmony_ci psrld $(32 - 3), x4 ## 2; \ 4108c2ecf20Sopenharmony_ci por x4 ## 2, x2 ## 2; \ 4118c2ecf20Sopenharmony_ci pxor x2 ## 2, x1 ## 2; \ 4128c2ecf20Sopenharmony_ci movdqa x1 ## 1, x4 ## 1; \ 4138c2ecf20Sopenharmony_ci pslld $1, x1 ## 1; \ 4148c2ecf20Sopenharmony_ci psrld $(32 - 1), x4 ## 1; \ 4158c2ecf20Sopenharmony_ci por x4 ## 1, x1 ## 1; \ 4168c2ecf20Sopenharmony_ci movdqa x0 ## 1, x4 ## 1; \ 4178c2ecf20Sopenharmony_ci pslld $3, x4 ## 1; \ 4188c2ecf20Sopenharmony_ci pxor x2 ## 1, x3 ## 1; \ 4198c2ecf20Sopenharmony_ci pxor x4 ## 1, x3 ## 1; \ 4208c2ecf20Sopenharmony_ci movdqa x3 ## 1, x4 ## 1; \ 4218c2ecf20Sopenharmony_ci get_key(i, 1, RK1); \ 4228c2ecf20Sopenharmony_ci movdqa x1 ## 2, x4 ## 2; \ 4238c2ecf20Sopenharmony_ci pslld $1, x1 ## 2; \ 4248c2ecf20Sopenharmony_ci psrld $(32 - 1), x4 ## 2; \ 4258c2ecf20Sopenharmony_ci por x4 ## 2, x1 ## 2; \ 4268c2ecf20Sopenharmony_ci movdqa x0 ## 2, x4 ## 2; \ 4278c2ecf20Sopenharmony_ci pslld $3, x4 ## 2; \ 4288c2ecf20Sopenharmony_ci pxor x2 ## 2, x3 ## 2; \ 4298c2ecf20Sopenharmony_ci pxor x4 ## 2, x3 ## 2; \ 4308c2ecf20Sopenharmony_ci movdqa x3 ## 2, x4 ## 2; \ 4318c2ecf20Sopenharmony_ci get_key(i, 3, RK3); \ 4328c2ecf20Sopenharmony_ci pslld $7, x3 ## 1; \ 4338c2ecf20Sopenharmony_ci psrld $(32 - 7), x4 ## 1; \ 4348c2ecf20Sopenharmony_ci por x4 ## 1, x3 ## 1; \ 4358c2ecf20Sopenharmony_ci movdqa x1 ## 1, x4 ## 1; \ 4368c2ecf20Sopenharmony_ci pslld $7, x4 ## 1; \ 4378c2ecf20Sopenharmony_ci pxor x1 ## 1, x0 ## 1; \ 4388c2ecf20Sopenharmony_ci pxor x3 ## 1, x0 ## 1; \ 4398c2ecf20Sopenharmony_ci pxor x3 ## 1, x2 ## 1; \ 4408c2ecf20Sopenharmony_ci pxor x4 ## 1, x2 ## 1; \ 4418c2ecf20Sopenharmony_ci get_key(i, 0, RK0); \ 4428c2ecf20Sopenharmony_ci pslld $7, x3 ## 2; \ 4438c2ecf20Sopenharmony_ci psrld $(32 - 7), x4 ## 2; \ 4448c2ecf20Sopenharmony_ci por x4 ## 2, x3 ## 2; \ 4458c2ecf20Sopenharmony_ci movdqa x1 ## 2, x4 ## 2; \ 4468c2ecf20Sopenharmony_ci pslld $7, x4 ## 2; \ 4478c2ecf20Sopenharmony_ci pxor x1 ## 2, x0 ## 2; \ 4488c2ecf20Sopenharmony_ci pxor x3 ## 2, x0 ## 2; \ 4498c2ecf20Sopenharmony_ci pxor x3 ## 2, x2 ## 2; \ 4508c2ecf20Sopenharmony_ci pxor x4 ## 2, x2 ## 2; \ 4518c2ecf20Sopenharmony_ci get_key(i, 2, RK2); \ 4528c2ecf20Sopenharmony_ci pxor RK1, x1 ## 1; \ 4538c2ecf20Sopenharmony_ci pxor RK3, x3 ## 1; \ 4548c2ecf20Sopenharmony_ci movdqa x0 ## 1, x4 ## 1; \ 4558c2ecf20Sopenharmony_ci pslld $5, x0 ## 1; \ 4568c2ecf20Sopenharmony_ci psrld $(32 - 5), x4 ## 1; \ 4578c2ecf20Sopenharmony_ci por x4 ## 1, x0 ## 1; \ 4588c2ecf20Sopenharmony_ci movdqa x2 ## 1, x4 ## 1; \ 4598c2ecf20Sopenharmony_ci pslld $22, x2 ## 1; \ 4608c2ecf20Sopenharmony_ci psrld $(32 - 22), x4 ## 1; \ 4618c2ecf20Sopenharmony_ci por x4 ## 1, x2 ## 1; \ 4628c2ecf20Sopenharmony_ci pxor RK0, x0 ## 1; \ 4638c2ecf20Sopenharmony_ci pxor RK2, x2 ## 1; \ 4648c2ecf20Sopenharmony_ci pxor RK1, x1 ## 2; \ 4658c2ecf20Sopenharmony_ci pxor RK3, x3 ## 2; \ 4668c2ecf20Sopenharmony_ci movdqa x0 ## 2, x4 ## 2; \ 4678c2ecf20Sopenharmony_ci pslld $5, x0 ## 2; \ 4688c2ecf20Sopenharmony_ci psrld $(32 - 5), x4 ## 2; \ 4698c2ecf20Sopenharmony_ci por x4 ## 2, x0 ## 2; \ 4708c2ecf20Sopenharmony_ci movdqa x2 ## 2, x4 ## 2; \ 4718c2ecf20Sopenharmony_ci pslld $22, x2 ## 2; \ 4728c2ecf20Sopenharmony_ci psrld $(32 - 22), x4 ## 2; \ 4738c2ecf20Sopenharmony_ci por x4 ## 2, x2 ## 2; \ 4748c2ecf20Sopenharmony_ci pxor RK0, x0 ## 2; \ 4758c2ecf20Sopenharmony_ci pxor RK2, x2 ## 2; 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci#define KL2(x0, x1, x2, x3, x4, i) \ 4788c2ecf20Sopenharmony_ci pxor RK0, x0 ## 1; \ 4798c2ecf20Sopenharmony_ci pxor RK2, x2 ## 1; \ 4808c2ecf20Sopenharmony_ci movdqa x0 ## 1, x4 ## 1; \ 4818c2ecf20Sopenharmony_ci psrld $5, x0 ## 1; \ 4828c2ecf20Sopenharmony_ci pslld $(32 - 5), x4 ## 1; \ 4838c2ecf20Sopenharmony_ci por x4 ## 1, x0 ## 1; \ 4848c2ecf20Sopenharmony_ci pxor RK3, x3 ## 1; \ 4858c2ecf20Sopenharmony_ci pxor RK1, x1 ## 1; \ 4868c2ecf20Sopenharmony_ci movdqa x2 ## 1, x4 ## 1; \ 4878c2ecf20Sopenharmony_ci psrld $22, x2 ## 1; \ 4888c2ecf20Sopenharmony_ci pslld $(32 - 22), x4 ## 1; \ 4898c2ecf20Sopenharmony_ci por x4 ## 1, x2 ## 1; \ 4908c2ecf20Sopenharmony_ci pxor x3 ## 1, x2 ## 1; \ 4918c2ecf20Sopenharmony_ci pxor RK0, x0 ## 2; \ 4928c2ecf20Sopenharmony_ci pxor RK2, x2 ## 2; \ 4938c2ecf20Sopenharmony_ci movdqa x0 ## 2, x4 ## 2; \ 4948c2ecf20Sopenharmony_ci psrld $5, x0 ## 2; \ 4958c2ecf20Sopenharmony_ci pslld $(32 - 5), x4 ## 2; \ 4968c2ecf20Sopenharmony_ci por x4 ## 2, x0 ## 2; \ 4978c2ecf20Sopenharmony_ci pxor RK3, x3 ## 2; \ 4988c2ecf20Sopenharmony_ci pxor RK1, x1 ## 2; \ 4998c2ecf20Sopenharmony_ci movdqa x2 ## 2, x4 ## 2; \ 5008c2ecf20Sopenharmony_ci psrld $22, x2 ## 2; \ 5018c2ecf20Sopenharmony_ci pslld $(32 - 22), x4 ## 2; \ 5028c2ecf20Sopenharmony_ci por x4 ## 2, x2 ## 2; \ 5038c2ecf20Sopenharmony_ci pxor x3 ## 2, x2 ## 2; \ 5048c2ecf20Sopenharmony_ci pxor x3 ## 1, x0 ## 1; \ 5058c2ecf20Sopenharmony_ci movdqa x1 ## 1, x4 ## 1; \ 5068c2ecf20Sopenharmony_ci pslld $7, x4 ## 1; \ 5078c2ecf20Sopenharmony_ci pxor x1 ## 1, x0 ## 1; \ 5088c2ecf20Sopenharmony_ci pxor x4 ## 1, x2 ## 1; \ 5098c2ecf20Sopenharmony_ci movdqa x1 ## 1, x4 ## 1; \ 5108c2ecf20Sopenharmony_ci psrld $1, x1 ## 1; \ 5118c2ecf20Sopenharmony_ci pslld $(32 - 1), x4 ## 1; \ 5128c2ecf20Sopenharmony_ci por x4 ## 1, x1 ## 1; \ 5138c2ecf20Sopenharmony_ci pxor x3 ## 2, x0 ## 2; \ 5148c2ecf20Sopenharmony_ci movdqa x1 ## 2, x4 ## 2; \ 5158c2ecf20Sopenharmony_ci pslld $7, x4 ## 2; \ 5168c2ecf20Sopenharmony_ci pxor x1 ## 2, x0 ## 2; \ 5178c2ecf20Sopenharmony_ci pxor x4 ## 2, x2 ## 2; \ 5188c2ecf20Sopenharmony_ci movdqa x1 ## 2, x4 ## 2; \ 5198c2ecf20Sopenharmony_ci psrld $1, x1 ## 2; \ 5208c2ecf20Sopenharmony_ci pslld $(32 - 1), x4 ## 2; \ 5218c2ecf20Sopenharmony_ci por x4 ## 2, x1 ## 2; \ 5228c2ecf20Sopenharmony_ci movdqa x3 ## 1, x4 ## 1; \ 5238c2ecf20Sopenharmony_ci psrld $7, x3 ## 1; \ 5248c2ecf20Sopenharmony_ci pslld $(32 - 7), x4 ## 1; \ 5258c2ecf20Sopenharmony_ci por x4 ## 1, x3 ## 1; \ 5268c2ecf20Sopenharmony_ci pxor x0 ## 1, x1 ## 1; \ 5278c2ecf20Sopenharmony_ci movdqa x0 ## 1, x4 ## 1; \ 5288c2ecf20Sopenharmony_ci pslld $3, x4 ## 1; \ 5298c2ecf20Sopenharmony_ci pxor x4 ## 1, x3 ## 1; \ 5308c2ecf20Sopenharmony_ci movdqa x0 ## 1, x4 ## 1; \ 5318c2ecf20Sopenharmony_ci movdqa x3 ## 2, x4 ## 2; \ 5328c2ecf20Sopenharmony_ci psrld $7, x3 ## 2; \ 5338c2ecf20Sopenharmony_ci pslld $(32 - 7), x4 ## 2; \ 5348c2ecf20Sopenharmony_ci por x4 ## 2, x3 ## 2; \ 5358c2ecf20Sopenharmony_ci pxor x0 ## 2, x1 ## 2; \ 5368c2ecf20Sopenharmony_ci movdqa x0 ## 2, x4 ## 2; \ 5378c2ecf20Sopenharmony_ci pslld $3, x4 ## 2; \ 5388c2ecf20Sopenharmony_ci pxor x4 ## 2, x3 ## 2; \ 5398c2ecf20Sopenharmony_ci movdqa x0 ## 2, x4 ## 2; \ 5408c2ecf20Sopenharmony_ci psrld $13, x0 ## 1; \ 5418c2ecf20Sopenharmony_ci pslld $(32 - 13), x4 ## 1; \ 5428c2ecf20Sopenharmony_ci por x4 ## 1, x0 ## 1; \ 5438c2ecf20Sopenharmony_ci pxor x2 ## 1, x1 ## 1; \ 5448c2ecf20Sopenharmony_ci pxor x2 ## 1, x3 ## 1; \ 5458c2ecf20Sopenharmony_ci movdqa x2 ## 1, x4 ## 1; \ 5468c2ecf20Sopenharmony_ci psrld $3, x2 ## 1; \ 5478c2ecf20Sopenharmony_ci pslld $(32 - 3), x4 ## 1; \ 5488c2ecf20Sopenharmony_ci por x4 ## 1, x2 ## 1; \ 5498c2ecf20Sopenharmony_ci psrld $13, x0 ## 2; \ 5508c2ecf20Sopenharmony_ci pslld $(32 - 13), x4 ## 2; \ 5518c2ecf20Sopenharmony_ci por x4 ## 2, x0 ## 2; \ 5528c2ecf20Sopenharmony_ci pxor x2 ## 2, x1 ## 2; \ 5538c2ecf20Sopenharmony_ci pxor x2 ## 2, x3 ## 2; \ 5548c2ecf20Sopenharmony_ci movdqa x2 ## 2, x4 ## 2; \ 5558c2ecf20Sopenharmony_ci psrld $3, x2 ## 2; \ 5568c2ecf20Sopenharmony_ci pslld $(32 - 3), x4 ## 2; \ 5578c2ecf20Sopenharmony_ci por x4 ## 2, x2 ## 2; 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci#define S(SBOX, x0, x1, x2, x3, x4) \ 5608c2ecf20Sopenharmony_ci SBOX ## _1(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, x4 ## 1); \ 5618c2ecf20Sopenharmony_ci SBOX ## _2(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, x4 ## 1); \ 5628c2ecf20Sopenharmony_ci SBOX ## _1(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, x4 ## 2); \ 5638c2ecf20Sopenharmony_ci SBOX ## _2(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, x4 ## 2); 5648c2ecf20Sopenharmony_ci 5658c2ecf20Sopenharmony_ci#define SP(SBOX, x0, x1, x2, x3, x4, i) \ 5668c2ecf20Sopenharmony_ci get_key(i, 0, RK0); \ 5678c2ecf20Sopenharmony_ci SBOX ## _1(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, x4 ## 1); \ 5688c2ecf20Sopenharmony_ci get_key(i, 2, RK2); \ 5698c2ecf20Sopenharmony_ci SBOX ## _1(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, x4 ## 2); \ 5708c2ecf20Sopenharmony_ci get_key(i, 3, RK3); \ 5718c2ecf20Sopenharmony_ci SBOX ## _2(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, x4 ## 1); \ 5728c2ecf20Sopenharmony_ci get_key(i, 1, RK1); \ 5738c2ecf20Sopenharmony_ci SBOX ## _2(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, x4 ## 2); \ 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci#define transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ 5768c2ecf20Sopenharmony_ci movdqa x0, t2; \ 5778c2ecf20Sopenharmony_ci punpckldq x1, x0; \ 5788c2ecf20Sopenharmony_ci punpckhdq x1, t2; \ 5798c2ecf20Sopenharmony_ci movdqa x2, t1; \ 5808c2ecf20Sopenharmony_ci punpckhdq x3, x2; \ 5818c2ecf20Sopenharmony_ci punpckldq x3, t1; \ 5828c2ecf20Sopenharmony_ci movdqa x0, x1; \ 5838c2ecf20Sopenharmony_ci punpcklqdq t1, x0; \ 5848c2ecf20Sopenharmony_ci punpckhqdq t1, x1; \ 5858c2ecf20Sopenharmony_ci movdqa t2, x3; \ 5868c2ecf20Sopenharmony_ci punpcklqdq x2, t2; \ 5878c2ecf20Sopenharmony_ci punpckhqdq x2, x3; \ 5888c2ecf20Sopenharmony_ci movdqa t2, x2; 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_ci#define read_blocks(in, x0, x1, x2, x3, t0, t1, t2) \ 5918c2ecf20Sopenharmony_ci movdqu (0*4*4)(in), x0; \ 5928c2ecf20Sopenharmony_ci movdqu (1*4*4)(in), x1; \ 5938c2ecf20Sopenharmony_ci movdqu (2*4*4)(in), x2; \ 5948c2ecf20Sopenharmony_ci movdqu (3*4*4)(in), x3; \ 5958c2ecf20Sopenharmony_ci \ 5968c2ecf20Sopenharmony_ci transpose_4x4(x0, x1, x2, x3, t0, t1, t2) 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci#define write_blocks(out, x0, x1, x2, x3, t0, t1, t2) \ 5998c2ecf20Sopenharmony_ci transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ 6008c2ecf20Sopenharmony_ci \ 6018c2ecf20Sopenharmony_ci movdqu x0, (0*4*4)(out); \ 6028c2ecf20Sopenharmony_ci movdqu x1, (1*4*4)(out); \ 6038c2ecf20Sopenharmony_ci movdqu x2, (2*4*4)(out); \ 6048c2ecf20Sopenharmony_ci movdqu x3, (3*4*4)(out); 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci#define xor_blocks(out, x0, x1, x2, x3, t0, t1, t2) \ 6078c2ecf20Sopenharmony_ci transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ 6088c2ecf20Sopenharmony_ci \ 6098c2ecf20Sopenharmony_ci movdqu (0*4*4)(out), t0; \ 6108c2ecf20Sopenharmony_ci pxor t0, x0; \ 6118c2ecf20Sopenharmony_ci movdqu x0, (0*4*4)(out); \ 6128c2ecf20Sopenharmony_ci movdqu (1*4*4)(out), t0; \ 6138c2ecf20Sopenharmony_ci pxor t0, x1; \ 6148c2ecf20Sopenharmony_ci movdqu x1, (1*4*4)(out); \ 6158c2ecf20Sopenharmony_ci movdqu (2*4*4)(out), t0; \ 6168c2ecf20Sopenharmony_ci pxor t0, x2; \ 6178c2ecf20Sopenharmony_ci movdqu x2, (2*4*4)(out); \ 6188c2ecf20Sopenharmony_ci movdqu (3*4*4)(out), t0; \ 6198c2ecf20Sopenharmony_ci pxor t0, x3; \ 6208c2ecf20Sopenharmony_ci movdqu x3, (3*4*4)(out); 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_ciSYM_FUNC_START(__serpent_enc_blk_8way) 6238c2ecf20Sopenharmony_ci /* input: 6248c2ecf20Sopenharmony_ci * %rdi: ctx, CTX 6258c2ecf20Sopenharmony_ci * %rsi: dst 6268c2ecf20Sopenharmony_ci * %rdx: src 6278c2ecf20Sopenharmony_ci * %rcx: bool, if true: xor output 6288c2ecf20Sopenharmony_ci */ 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci pcmpeqd RNOT, RNOT; 6318c2ecf20Sopenharmony_ci 6328c2ecf20Sopenharmony_ci leaq (4*4*4)(%rdx), %rax; 6338c2ecf20Sopenharmony_ci read_blocks(%rdx, RA1, RB1, RC1, RD1, RK0, RK1, RK2); 6348c2ecf20Sopenharmony_ci read_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2); 6358c2ecf20Sopenharmony_ci 6368c2ecf20Sopenharmony_ci K2(RA, RB, RC, RD, RE, 0); 6378c2ecf20Sopenharmony_ci S(S0, RA, RB, RC, RD, RE); LK2(RC, RB, RD, RA, RE, 1); 6388c2ecf20Sopenharmony_ci S(S1, RC, RB, RD, RA, RE); LK2(RE, RD, RA, RC, RB, 2); 6398c2ecf20Sopenharmony_ci S(S2, RE, RD, RA, RC, RB); LK2(RB, RD, RE, RC, RA, 3); 6408c2ecf20Sopenharmony_ci S(S3, RB, RD, RE, RC, RA); LK2(RC, RA, RD, RB, RE, 4); 6418c2ecf20Sopenharmony_ci S(S4, RC, RA, RD, RB, RE); LK2(RA, RD, RB, RE, RC, 5); 6428c2ecf20Sopenharmony_ci S(S5, RA, RD, RB, RE, RC); LK2(RC, RA, RD, RE, RB, 6); 6438c2ecf20Sopenharmony_ci S(S6, RC, RA, RD, RE, RB); LK2(RD, RB, RA, RE, RC, 7); 6448c2ecf20Sopenharmony_ci S(S7, RD, RB, RA, RE, RC); LK2(RC, RA, RE, RD, RB, 8); 6458c2ecf20Sopenharmony_ci S(S0, RC, RA, RE, RD, RB); LK2(RE, RA, RD, RC, RB, 9); 6468c2ecf20Sopenharmony_ci S(S1, RE, RA, RD, RC, RB); LK2(RB, RD, RC, RE, RA, 10); 6478c2ecf20Sopenharmony_ci S(S2, RB, RD, RC, RE, RA); LK2(RA, RD, RB, RE, RC, 11); 6488c2ecf20Sopenharmony_ci S(S3, RA, RD, RB, RE, RC); LK2(RE, RC, RD, RA, RB, 12); 6498c2ecf20Sopenharmony_ci S(S4, RE, RC, RD, RA, RB); LK2(RC, RD, RA, RB, RE, 13); 6508c2ecf20Sopenharmony_ci S(S5, RC, RD, RA, RB, RE); LK2(RE, RC, RD, RB, RA, 14); 6518c2ecf20Sopenharmony_ci S(S6, RE, RC, RD, RB, RA); LK2(RD, RA, RC, RB, RE, 15); 6528c2ecf20Sopenharmony_ci S(S7, RD, RA, RC, RB, RE); LK2(RE, RC, RB, RD, RA, 16); 6538c2ecf20Sopenharmony_ci S(S0, RE, RC, RB, RD, RA); LK2(RB, RC, RD, RE, RA, 17); 6548c2ecf20Sopenharmony_ci S(S1, RB, RC, RD, RE, RA); LK2(RA, RD, RE, RB, RC, 18); 6558c2ecf20Sopenharmony_ci S(S2, RA, RD, RE, RB, RC); LK2(RC, RD, RA, RB, RE, 19); 6568c2ecf20Sopenharmony_ci S(S3, RC, RD, RA, RB, RE); LK2(RB, RE, RD, RC, RA, 20); 6578c2ecf20Sopenharmony_ci S(S4, RB, RE, RD, RC, RA); LK2(RE, RD, RC, RA, RB, 21); 6588c2ecf20Sopenharmony_ci S(S5, RE, RD, RC, RA, RB); LK2(RB, RE, RD, RA, RC, 22); 6598c2ecf20Sopenharmony_ci S(S6, RB, RE, RD, RA, RC); LK2(RD, RC, RE, RA, RB, 23); 6608c2ecf20Sopenharmony_ci S(S7, RD, RC, RE, RA, RB); LK2(RB, RE, RA, RD, RC, 24); 6618c2ecf20Sopenharmony_ci S(S0, RB, RE, RA, RD, RC); LK2(RA, RE, RD, RB, RC, 25); 6628c2ecf20Sopenharmony_ci S(S1, RA, RE, RD, RB, RC); LK2(RC, RD, RB, RA, RE, 26); 6638c2ecf20Sopenharmony_ci S(S2, RC, RD, RB, RA, RE); LK2(RE, RD, RC, RA, RB, 27); 6648c2ecf20Sopenharmony_ci S(S3, RE, RD, RC, RA, RB); LK2(RA, RB, RD, RE, RC, 28); 6658c2ecf20Sopenharmony_ci S(S4, RA, RB, RD, RE, RC); LK2(RB, RD, RE, RC, RA, 29); 6668c2ecf20Sopenharmony_ci S(S5, RB, RD, RE, RC, RA); LK2(RA, RB, RD, RC, RE, 30); 6678c2ecf20Sopenharmony_ci S(S6, RA, RB, RD, RC, RE); LK2(RD, RE, RB, RC, RA, 31); 6688c2ecf20Sopenharmony_ci S(S7, RD, RE, RB, RC, RA); K2(RA, RB, RC, RD, RE, 32); 6698c2ecf20Sopenharmony_ci 6708c2ecf20Sopenharmony_ci leaq (4*4*4)(%rsi), %rax; 6718c2ecf20Sopenharmony_ci 6728c2ecf20Sopenharmony_ci testb %cl, %cl; 6738c2ecf20Sopenharmony_ci jnz .L__enc_xor8; 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ci write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2); 6768c2ecf20Sopenharmony_ci write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2); 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci RET; 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_ci.L__enc_xor8: 6818c2ecf20Sopenharmony_ci xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2); 6828c2ecf20Sopenharmony_ci xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2); 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_ci RET; 6858c2ecf20Sopenharmony_ciSYM_FUNC_END(__serpent_enc_blk_8way) 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_ciSYM_FUNC_START(serpent_dec_blk_8way) 6888c2ecf20Sopenharmony_ci /* input: 6898c2ecf20Sopenharmony_ci * %rdi: ctx, CTX 6908c2ecf20Sopenharmony_ci * %rsi: dst 6918c2ecf20Sopenharmony_ci * %rdx: src 6928c2ecf20Sopenharmony_ci */ 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci pcmpeqd RNOT, RNOT; 6958c2ecf20Sopenharmony_ci 6968c2ecf20Sopenharmony_ci leaq (4*4*4)(%rdx), %rax; 6978c2ecf20Sopenharmony_ci read_blocks(%rdx, RA1, RB1, RC1, RD1, RK0, RK1, RK2); 6988c2ecf20Sopenharmony_ci read_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2); 6998c2ecf20Sopenharmony_ci 7008c2ecf20Sopenharmony_ci K2(RA, RB, RC, RD, RE, 32); 7018c2ecf20Sopenharmony_ci SP(SI7, RA, RB, RC, RD, RE, 31); KL2(RB, RD, RA, RE, RC, 31); 7028c2ecf20Sopenharmony_ci SP(SI6, RB, RD, RA, RE, RC, 30); KL2(RA, RC, RE, RB, RD, 30); 7038c2ecf20Sopenharmony_ci SP(SI5, RA, RC, RE, RB, RD, 29); KL2(RC, RD, RA, RE, RB, 29); 7048c2ecf20Sopenharmony_ci SP(SI4, RC, RD, RA, RE, RB, 28); KL2(RC, RA, RB, RE, RD, 28); 7058c2ecf20Sopenharmony_ci SP(SI3, RC, RA, RB, RE, RD, 27); KL2(RB, RC, RD, RE, RA, 27); 7068c2ecf20Sopenharmony_ci SP(SI2, RB, RC, RD, RE, RA, 26); KL2(RC, RA, RE, RD, RB, 26); 7078c2ecf20Sopenharmony_ci SP(SI1, RC, RA, RE, RD, RB, 25); KL2(RB, RA, RE, RD, RC, 25); 7088c2ecf20Sopenharmony_ci SP(SI0, RB, RA, RE, RD, RC, 24); KL2(RE, RC, RA, RB, RD, 24); 7098c2ecf20Sopenharmony_ci SP(SI7, RE, RC, RA, RB, RD, 23); KL2(RC, RB, RE, RD, RA, 23); 7108c2ecf20Sopenharmony_ci SP(SI6, RC, RB, RE, RD, RA, 22); KL2(RE, RA, RD, RC, RB, 22); 7118c2ecf20Sopenharmony_ci SP(SI5, RE, RA, RD, RC, RB, 21); KL2(RA, RB, RE, RD, RC, 21); 7128c2ecf20Sopenharmony_ci SP(SI4, RA, RB, RE, RD, RC, 20); KL2(RA, RE, RC, RD, RB, 20); 7138c2ecf20Sopenharmony_ci SP(SI3, RA, RE, RC, RD, RB, 19); KL2(RC, RA, RB, RD, RE, 19); 7148c2ecf20Sopenharmony_ci SP(SI2, RC, RA, RB, RD, RE, 18); KL2(RA, RE, RD, RB, RC, 18); 7158c2ecf20Sopenharmony_ci SP(SI1, RA, RE, RD, RB, RC, 17); KL2(RC, RE, RD, RB, RA, 17); 7168c2ecf20Sopenharmony_ci SP(SI0, RC, RE, RD, RB, RA, 16); KL2(RD, RA, RE, RC, RB, 16); 7178c2ecf20Sopenharmony_ci SP(SI7, RD, RA, RE, RC, RB, 15); KL2(RA, RC, RD, RB, RE, 15); 7188c2ecf20Sopenharmony_ci SP(SI6, RA, RC, RD, RB, RE, 14); KL2(RD, RE, RB, RA, RC, 14); 7198c2ecf20Sopenharmony_ci SP(SI5, RD, RE, RB, RA, RC, 13); KL2(RE, RC, RD, RB, RA, 13); 7208c2ecf20Sopenharmony_ci SP(SI4, RE, RC, RD, RB, RA, 12); KL2(RE, RD, RA, RB, RC, 12); 7218c2ecf20Sopenharmony_ci SP(SI3, RE, RD, RA, RB, RC, 11); KL2(RA, RE, RC, RB, RD, 11); 7228c2ecf20Sopenharmony_ci SP(SI2, RA, RE, RC, RB, RD, 10); KL2(RE, RD, RB, RC, RA, 10); 7238c2ecf20Sopenharmony_ci SP(SI1, RE, RD, RB, RC, RA, 9); KL2(RA, RD, RB, RC, RE, 9); 7248c2ecf20Sopenharmony_ci SP(SI0, RA, RD, RB, RC, RE, 8); KL2(RB, RE, RD, RA, RC, 8); 7258c2ecf20Sopenharmony_ci SP(SI7, RB, RE, RD, RA, RC, 7); KL2(RE, RA, RB, RC, RD, 7); 7268c2ecf20Sopenharmony_ci SP(SI6, RE, RA, RB, RC, RD, 6); KL2(RB, RD, RC, RE, RA, 6); 7278c2ecf20Sopenharmony_ci SP(SI5, RB, RD, RC, RE, RA, 5); KL2(RD, RA, RB, RC, RE, 5); 7288c2ecf20Sopenharmony_ci SP(SI4, RD, RA, RB, RC, RE, 4); KL2(RD, RB, RE, RC, RA, 4); 7298c2ecf20Sopenharmony_ci SP(SI3, RD, RB, RE, RC, RA, 3); KL2(RE, RD, RA, RC, RB, 3); 7308c2ecf20Sopenharmony_ci SP(SI2, RE, RD, RA, RC, RB, 2); KL2(RD, RB, RC, RA, RE, 2); 7318c2ecf20Sopenharmony_ci SP(SI1, RD, RB, RC, RA, RE, 1); KL2(RE, RB, RC, RA, RD, 1); 7328c2ecf20Sopenharmony_ci S(SI0, RE, RB, RC, RA, RD); K2(RC, RD, RB, RE, RA, 0); 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_ci leaq (4*4*4)(%rsi), %rax; 7358c2ecf20Sopenharmony_ci write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2); 7368c2ecf20Sopenharmony_ci write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2); 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_ci RET; 7398c2ecf20Sopenharmony_ciSYM_FUNC_END(serpent_dec_blk_8way) 740