Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

293 Zeilen
16 KiB

  1. #include <stdint.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "sha256avx.h"
  5. // Transpose 8 vectors containing 32-bit values
  6. void PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_transpose(u256 s[8]) {
  7. u256 tmp0[8];
  8. u256 tmp1[8];
  9. tmp0[0] = _mm256_unpacklo_epi32(s[0], s[1]);
  10. tmp0[1] = _mm256_unpackhi_epi32(s[0], s[1]);
  11. tmp0[2] = _mm256_unpacklo_epi32(s[2], s[3]);
  12. tmp0[3] = _mm256_unpackhi_epi32(s[2], s[3]);
  13. tmp0[4] = _mm256_unpacklo_epi32(s[4], s[5]);
  14. tmp0[5] = _mm256_unpackhi_epi32(s[4], s[5]);
  15. tmp0[6] = _mm256_unpacklo_epi32(s[6], s[7]);
  16. tmp0[7] = _mm256_unpackhi_epi32(s[6], s[7]);
  17. tmp1[0] = _mm256_unpacklo_epi64(tmp0[0], tmp0[2]);
  18. tmp1[1] = _mm256_unpackhi_epi64(tmp0[0], tmp0[2]);
  19. tmp1[2] = _mm256_unpacklo_epi64(tmp0[1], tmp0[3]);
  20. tmp1[3] = _mm256_unpackhi_epi64(tmp0[1], tmp0[3]);
  21. tmp1[4] = _mm256_unpacklo_epi64(tmp0[4], tmp0[6]);
  22. tmp1[5] = _mm256_unpackhi_epi64(tmp0[4], tmp0[6]);
  23. tmp1[6] = _mm256_unpacklo_epi64(tmp0[5], tmp0[7]);
  24. tmp1[7] = _mm256_unpackhi_epi64(tmp0[5], tmp0[7]);
  25. s[0] = _mm256_permute2x128_si256(tmp1[0], tmp1[4], 0x20);
  26. s[1] = _mm256_permute2x128_si256(tmp1[1], tmp1[5], 0x20);
  27. s[2] = _mm256_permute2x128_si256(tmp1[2], tmp1[6], 0x20);
  28. s[3] = _mm256_permute2x128_si256(tmp1[3], tmp1[7], 0x20);
  29. s[4] = _mm256_permute2x128_si256(tmp1[0], tmp1[4], 0x31);
  30. s[5] = _mm256_permute2x128_si256(tmp1[1], tmp1[5], 0x31);
  31. s[6] = _mm256_permute2x128_si256(tmp1[2], tmp1[6], 0x31);
  32. s[7] = _mm256_permute2x128_si256(tmp1[3], tmp1[7], 0x31);
  33. }
  34. void PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_sha256_clone_statex8(sha256ctxx8 *outctx, const sha256ctxx8 *inctx) {
  35. memcpy(outctx, inctx, sizeof(sha256ctxx8));
  36. }
  37. void PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_sha256_init8x(sha256ctxx8 *ctx) {
  38. ctx->s[0] = _mm256_set_epi32((int)0x6a09e667, (int)0x6a09e667, (int)0x6a09e667, (int)0x6a09e667, (int)0x6a09e667, (int)0x6a09e667, (int)0x6a09e667, (int)0x6a09e667);
  39. ctx->s[1] = _mm256_set_epi32((int)0xbb67ae85, (int)0xbb67ae85, (int)0xbb67ae85, (int)0xbb67ae85, (int)0xbb67ae85, (int)0xbb67ae85, (int)0xbb67ae85, (int)0xbb67ae85);
  40. ctx->s[2] = _mm256_set_epi32((int)0x3c6ef372, (int)0x3c6ef372, (int)0x3c6ef372, (int)0x3c6ef372, (int)0x3c6ef372, (int)0x3c6ef372, (int)0x3c6ef372, (int)0x3c6ef372);
  41. ctx->s[3] = _mm256_set_epi32((int)0xa54ff53a, (int)0xa54ff53a, (int)0xa54ff53a, (int)0xa54ff53a, (int)0xa54ff53a, (int)0xa54ff53a, (int)0xa54ff53a, (int)0xa54ff53a);
  42. ctx->s[4] = _mm256_set_epi32((int)0x510e527f, (int)0x510e527f, (int)0x510e527f, (int)0x510e527f, (int)0x510e527f, (int)0x510e527f, (int)0x510e527f, (int)0x510e527f);
  43. ctx->s[5] = _mm256_set_epi32((int)0x9b05688c, (int)0x9b05688c, (int)0x9b05688c, (int)0x9b05688c, (int)0x9b05688c, (int)0x9b05688c, (int)0x9b05688c, (int)0x9b05688c);
  44. ctx->s[6] = _mm256_set_epi32((int)0x1f83d9ab, (int)0x1f83d9ab, (int)0x1f83d9ab, (int)0x1f83d9ab, (int)0x1f83d9ab, (int)0x1f83d9ab, (int)0x1f83d9ab, (int)0x1f83d9ab);
  45. ctx->s[7] = _mm256_set_epi32((int)0x5be0cd19, (int)0x5be0cd19, (int)0x5be0cd19, (int)0x5be0cd19, (int)0x5be0cd19, (int)0x5be0cd19, (int)0x5be0cd19, (int)0x5be0cd19);
  46. ctx->datalen = 0;
  47. ctx->msglen = 0;
  48. }
  49. void PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_sha256_update8x(sha256ctxx8 *ctx,
  50. const unsigned char *d0,
  51. const unsigned char *d1,
  52. const unsigned char *d2,
  53. const unsigned char *d3,
  54. const unsigned char *d4,
  55. const unsigned char *d5,
  56. const unsigned char *d6,
  57. const unsigned char *d7,
  58. unsigned long long len) {
  59. unsigned long long i = 0;
  60. while (i < len) {
  61. unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i);
  62. memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy);
  63. memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy);
  64. memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy);
  65. memcpy(&ctx->msgblocks[64 * 3], d3 + i, bytes_to_copy);
  66. memcpy(&ctx->msgblocks[64 * 4], d4 + i, bytes_to_copy);
  67. memcpy(&ctx->msgblocks[64 * 5], d5 + i, bytes_to_copy);
  68. memcpy(&ctx->msgblocks[64 * 6], d6 + i, bytes_to_copy);
  69. memcpy(&ctx->msgblocks[64 * 7], d7 + i, bytes_to_copy);
  70. ctx->datalen += (unsigned int)bytes_to_copy;
  71. i += bytes_to_copy;
  72. if (ctx->datalen == 64) {
  73. PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_sha256_transform8x(ctx, ctx->msgblocks);
  74. ctx->msglen += 512;
  75. ctx->datalen = 0;
  76. }
  77. }
  78. }
  79. void PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_sha256_final8x(sha256ctxx8 *ctx,
  80. unsigned char *out0,
  81. unsigned char *out1,
  82. unsigned char *out2,
  83. unsigned char *out3,
  84. unsigned char *out4,
  85. unsigned char *out5,
  86. unsigned char *out6,
  87. unsigned char *out7) {
  88. unsigned int i, curlen;
  89. // Padding
  90. if (ctx->datalen < 56) {
  91. for (i = 0; i < 8; ++i) {
  92. curlen = ctx->datalen;
  93. ctx->msgblocks[64 * i + curlen++] = 0x80;
  94. while (curlen < 64) {
  95. ctx->msgblocks[64 * i + curlen++] = 0x00;
  96. }
  97. }
  98. } else {
  99. for (i = 0; i < 8; ++i) {
  100. curlen = ctx->datalen;
  101. ctx->msgblocks[64 * i + curlen++] = 0x80;
  102. while (curlen < 64) {
  103. ctx->msgblocks[64 * i + curlen++] = 0x00;
  104. }
  105. }
  106. PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_sha256_transform8x(ctx, ctx->msgblocks);
  107. memset(ctx->msgblocks, 0, 8 * 64);
  108. }
  109. // Add length of the message to each block
  110. ctx->msglen += ctx->datalen * 8;
  111. for (i = 0; i < 8; i++) {
  112. ctx->msgblocks[64 * i + 63] = (unsigned char)ctx->msglen;
  113. ctx->msgblocks[64 * i + 62] = (unsigned char)(ctx->msglen >> 8);
  114. ctx->msgblocks[64 * i + 61] = (unsigned char)(ctx->msglen >> 16);
  115. ctx->msgblocks[64 * i + 60] = (unsigned char)(ctx->msglen >> 24);
  116. ctx->msgblocks[64 * i + 59] = (unsigned char)(ctx->msglen >> 32);
  117. ctx->msgblocks[64 * i + 58] = (unsigned char)(ctx->msglen >> 40);
  118. ctx->msgblocks[64 * i + 57] = (unsigned char)(ctx->msglen >> 48);
  119. ctx->msgblocks[64 * i + 56] = (unsigned char)(ctx->msglen >> 56);
  120. }
  121. PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_sha256_transform8x(ctx, ctx->msgblocks);
  122. // Compute final hash output
  123. PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_transpose(ctx->s);
  124. // Store Hash value
  125. STORE(out0, BYTESWAP(ctx->s[0]));
  126. STORE(out1, BYTESWAP(ctx->s[1]));
  127. STORE(out2, BYTESWAP(ctx->s[2]));
  128. STORE(out3, BYTESWAP(ctx->s[3]));
  129. STORE(out4, BYTESWAP(ctx->s[4]));
  130. STORE(out5, BYTESWAP(ctx->s[5]));
  131. STORE(out6, BYTESWAP(ctx->s[6]));
  132. STORE(out7, BYTESWAP(ctx->s[7]));
  133. }
  134. void PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_sha256_transform8x(sha256ctxx8 *ctx, const unsigned char *data) {
  135. u256 s[8], w[64], T0, T1;
  136. int i;
  137. // Load words and transform data correctly
  138. for (i = 0; i < 8; i++) {
  139. w[i] = BYTESWAP(LOAD(data + 64 * i));
  140. w[i + 8] = BYTESWAP(LOAD(data + 32 + 64 * i));
  141. }
  142. PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_transpose(w);
  143. PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_transpose(w + 8);
  144. // Initial State
  145. s[0] = ctx->s[0];
  146. s[1] = ctx->s[1];
  147. s[2] = ctx->s[2];
  148. s[3] = ctx->s[3];
  149. s[4] = ctx->s[4];
  150. s[5] = ctx->s[5];
  151. s[6] = ctx->s[6];
  152. s[7] = ctx->s[7];
  153. SHA256ROUND_AVX(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], 0, w[0]);
  154. SHA256ROUND_AVX(s[7], s[0], s[1], s[2], s[3], s[4], s[5], s[6], 1, w[1]);
  155. SHA256ROUND_AVX(s[6], s[7], s[0], s[1], s[2], s[3], s[4], s[5], 2, w[2]);
  156. SHA256ROUND_AVX(s[5], s[6], s[7], s[0], s[1], s[2], s[3], s[4], 3, w[3]);
  157. SHA256ROUND_AVX(s[4], s[5], s[6], s[7], s[0], s[1], s[2], s[3], 4, w[4]);
  158. SHA256ROUND_AVX(s[3], s[4], s[5], s[6], s[7], s[0], s[1], s[2], 5, w[5]);
  159. SHA256ROUND_AVX(s[2], s[3], s[4], s[5], s[6], s[7], s[0], s[1], 6, w[6]);
  160. SHA256ROUND_AVX(s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[0], 7, w[7]);
  161. SHA256ROUND_AVX(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], 8, w[8]);
  162. SHA256ROUND_AVX(s[7], s[0], s[1], s[2], s[3], s[4], s[5], s[6], 9, w[9]);
  163. SHA256ROUND_AVX(s[6], s[7], s[0], s[1], s[2], s[3], s[4], s[5], 10, w[10]);
  164. SHA256ROUND_AVX(s[5], s[6], s[7], s[0], s[1], s[2], s[3], s[4], 11, w[11]);
  165. SHA256ROUND_AVX(s[4], s[5], s[6], s[7], s[0], s[1], s[2], s[3], 12, w[12]);
  166. SHA256ROUND_AVX(s[3], s[4], s[5], s[6], s[7], s[0], s[1], s[2], 13, w[13]);
  167. SHA256ROUND_AVX(s[2], s[3], s[4], s[5], s[6], s[7], s[0], s[1], 14, w[14]);
  168. SHA256ROUND_AVX(s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[0], 15, w[15]);
  169. w[16] = ADD4_32(WSIGMA1_AVX(w[14]), w[0], w[9], WSIGMA0_AVX(w[1]));
  170. SHA256ROUND_AVX(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], 16, w[16]);
  171. w[17] = ADD4_32(WSIGMA1_AVX(w[15]), w[1], w[10], WSIGMA0_AVX(w[2]));
  172. SHA256ROUND_AVX(s[7], s[0], s[1], s[2], s[3], s[4], s[5], s[6], 17, w[17]);
  173. w[18] = ADD4_32(WSIGMA1_AVX(w[16]), w[2], w[11], WSIGMA0_AVX(w[3]));
  174. SHA256ROUND_AVX(s[6], s[7], s[0], s[1], s[2], s[3], s[4], s[5], 18, w[18]);
  175. w[19] = ADD4_32(WSIGMA1_AVX(w[17]), w[3], w[12], WSIGMA0_AVX(w[4]));
  176. SHA256ROUND_AVX(s[5], s[6], s[7], s[0], s[1], s[2], s[3], s[4], 19, w[19]);
  177. w[20] = ADD4_32(WSIGMA1_AVX(w[18]), w[4], w[13], WSIGMA0_AVX(w[5]));
  178. SHA256ROUND_AVX(s[4], s[5], s[6], s[7], s[0], s[1], s[2], s[3], 20, w[20]);
  179. w[21] = ADD4_32(WSIGMA1_AVX(w[19]), w[5], w[14], WSIGMA0_AVX(w[6]));
  180. SHA256ROUND_AVX(s[3], s[4], s[5], s[6], s[7], s[0], s[1], s[2], 21, w[21]);
  181. w[22] = ADD4_32(WSIGMA1_AVX(w[20]), w[6], w[15], WSIGMA0_AVX(w[7]));
  182. SHA256ROUND_AVX(s[2], s[3], s[4], s[5], s[6], s[7], s[0], s[1], 22, w[22]);
  183. w[23] = ADD4_32(WSIGMA1_AVX(w[21]), w[7], w[16], WSIGMA0_AVX(w[8]));
  184. SHA256ROUND_AVX(s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[0], 23, w[23]);
  185. w[24] = ADD4_32(WSIGMA1_AVX(w[22]), w[8], w[17], WSIGMA0_AVX(w[9]));
  186. SHA256ROUND_AVX(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], 24, w[24]);
  187. w[25] = ADD4_32(WSIGMA1_AVX(w[23]), w[9], w[18], WSIGMA0_AVX(w[10]));
  188. SHA256ROUND_AVX(s[7], s[0], s[1], s[2], s[3], s[4], s[5], s[6], 25, w[25]);
  189. w[26] = ADD4_32(WSIGMA1_AVX(w[24]), w[10], w[19], WSIGMA0_AVX(w[11]));
  190. SHA256ROUND_AVX(s[6], s[7], s[0], s[1], s[2], s[3], s[4], s[5], 26, w[26]);
  191. w[27] = ADD4_32(WSIGMA1_AVX(w[25]), w[11], w[20], WSIGMA0_AVX(w[12]));
  192. SHA256ROUND_AVX(s[5], s[6], s[7], s[0], s[1], s[2], s[3], s[4], 27, w[27]);
  193. w[28] = ADD4_32(WSIGMA1_AVX(w[26]), w[12], w[21], WSIGMA0_AVX(w[13]));
  194. SHA256ROUND_AVX(s[4], s[5], s[6], s[7], s[0], s[1], s[2], s[3], 28, w[28]);
  195. w[29] = ADD4_32(WSIGMA1_AVX(w[27]), w[13], w[22], WSIGMA0_AVX(w[14]));
  196. SHA256ROUND_AVX(s[3], s[4], s[5], s[6], s[7], s[0], s[1], s[2], 29, w[29]);
  197. w[30] = ADD4_32(WSIGMA1_AVX(w[28]), w[14], w[23], WSIGMA0_AVX(w[15]));
  198. SHA256ROUND_AVX(s[2], s[3], s[4], s[5], s[6], s[7], s[0], s[1], 30, w[30]);
  199. w[31] = ADD4_32(WSIGMA1_AVX(w[29]), w[15], w[24], WSIGMA0_AVX(w[16]));
  200. SHA256ROUND_AVX(s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[0], 31, w[31]);
  201. w[32] = ADD4_32(WSIGMA1_AVX(w[30]), w[16], w[25], WSIGMA0_AVX(w[17]));
  202. SHA256ROUND_AVX(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], 32, w[32]);
  203. w[33] = ADD4_32(WSIGMA1_AVX(w[31]), w[17], w[26], WSIGMA0_AVX(w[18]));
  204. SHA256ROUND_AVX(s[7], s[0], s[1], s[2], s[3], s[4], s[5], s[6], 33, w[33]);
  205. w[34] = ADD4_32(WSIGMA1_AVX(w[32]), w[18], w[27], WSIGMA0_AVX(w[19]));
  206. SHA256ROUND_AVX(s[6], s[7], s[0], s[1], s[2], s[3], s[4], s[5], 34, w[34]);
  207. w[35] = ADD4_32(WSIGMA1_AVX(w[33]), w[19], w[28], WSIGMA0_AVX(w[20]));
  208. SHA256ROUND_AVX(s[5], s[6], s[7], s[0], s[1], s[2], s[3], s[4], 35, w[35]);
  209. w[36] = ADD4_32(WSIGMA1_AVX(w[34]), w[20], w[29], WSIGMA0_AVX(w[21]));
  210. SHA256ROUND_AVX(s[4], s[5], s[6], s[7], s[0], s[1], s[2], s[3], 36, w[36]);
  211. w[37] = ADD4_32(WSIGMA1_AVX(w[35]), w[21], w[30], WSIGMA0_AVX(w[22]));
  212. SHA256ROUND_AVX(s[3], s[4], s[5], s[6], s[7], s[0], s[1], s[2], 37, w[37]);
  213. w[38] = ADD4_32(WSIGMA1_AVX(w[36]), w[22], w[31], WSIGMA0_AVX(w[23]));
  214. SHA256ROUND_AVX(s[2], s[3], s[4], s[5], s[6], s[7], s[0], s[1], 38, w[38]);
  215. w[39] = ADD4_32(WSIGMA1_AVX(w[37]), w[23], w[32], WSIGMA0_AVX(w[24]));
  216. SHA256ROUND_AVX(s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[0], 39, w[39]);
  217. w[40] = ADD4_32(WSIGMA1_AVX(w[38]), w[24], w[33], WSIGMA0_AVX(w[25]));
  218. SHA256ROUND_AVX(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], 40, w[40]);
  219. w[41] = ADD4_32(WSIGMA1_AVX(w[39]), w[25], w[34], WSIGMA0_AVX(w[26]));
  220. SHA256ROUND_AVX(s[7], s[0], s[1], s[2], s[3], s[4], s[5], s[6], 41, w[41]);
  221. w[42] = ADD4_32(WSIGMA1_AVX(w[40]), w[26], w[35], WSIGMA0_AVX(w[27]));
  222. SHA256ROUND_AVX(s[6], s[7], s[0], s[1], s[2], s[3], s[4], s[5], 42, w[42]);
  223. w[43] = ADD4_32(WSIGMA1_AVX(w[41]), w[27], w[36], WSIGMA0_AVX(w[28]));
  224. SHA256ROUND_AVX(s[5], s[6], s[7], s[0], s[1], s[2], s[3], s[4], 43, w[43]);
  225. w[44] = ADD4_32(WSIGMA1_AVX(w[42]), w[28], w[37], WSIGMA0_AVX(w[29]));
  226. SHA256ROUND_AVX(s[4], s[5], s[6], s[7], s[0], s[1], s[2], s[3], 44, w[44]);
  227. w[45] = ADD4_32(WSIGMA1_AVX(w[43]), w[29], w[38], WSIGMA0_AVX(w[30]));
  228. SHA256ROUND_AVX(s[3], s[4], s[5], s[6], s[7], s[0], s[1], s[2], 45, w[45]);
  229. w[46] = ADD4_32(WSIGMA1_AVX(w[44]), w[30], w[39], WSIGMA0_AVX(w[31]));
  230. SHA256ROUND_AVX(s[2], s[3], s[4], s[5], s[6], s[7], s[0], s[1], 46, w[46]);
  231. w[47] = ADD4_32(WSIGMA1_AVX(w[45]), w[31], w[40], WSIGMA0_AVX(w[32]));
  232. SHA256ROUND_AVX(s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[0], 47, w[47]);
  233. w[48] = ADD4_32(WSIGMA1_AVX(w[46]), w[32], w[41], WSIGMA0_AVX(w[33]));
  234. SHA256ROUND_AVX(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], 48, w[48]);
  235. w[49] = ADD4_32(WSIGMA1_AVX(w[47]), w[33], w[42], WSIGMA0_AVX(w[34]));
  236. SHA256ROUND_AVX(s[7], s[0], s[1], s[2], s[3], s[4], s[5], s[6], 49, w[49]);
  237. w[50] = ADD4_32(WSIGMA1_AVX(w[48]), w[34], w[43], WSIGMA0_AVX(w[35]));
  238. SHA256ROUND_AVX(s[6], s[7], s[0], s[1], s[2], s[3], s[4], s[5], 50, w[50]);
  239. w[51] = ADD4_32(WSIGMA1_AVX(w[49]), w[35], w[44], WSIGMA0_AVX(w[36]));
  240. SHA256ROUND_AVX(s[5], s[6], s[7], s[0], s[1], s[2], s[3], s[4], 51, w[51]);
  241. w[52] = ADD4_32(WSIGMA1_AVX(w[50]), w[36], w[45], WSIGMA0_AVX(w[37]));
  242. SHA256ROUND_AVX(s[4], s[5], s[6], s[7], s[0], s[1], s[2], s[3], 52, w[52]);
  243. w[53] = ADD4_32(WSIGMA1_AVX(w[51]), w[37], w[46], WSIGMA0_AVX(w[38]));
  244. SHA256ROUND_AVX(s[3], s[4], s[5], s[6], s[7], s[0], s[1], s[2], 53, w[53]);
  245. w[54] = ADD4_32(WSIGMA1_AVX(w[52]), w[38], w[47], WSIGMA0_AVX(w[39]));
  246. SHA256ROUND_AVX(s[2], s[3], s[4], s[5], s[6], s[7], s[0], s[1], 54, w[54]);
  247. w[55] = ADD4_32(WSIGMA1_AVX(w[53]), w[39], w[48], WSIGMA0_AVX(w[40]));
  248. SHA256ROUND_AVX(s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[0], 55, w[55]);
  249. w[56] = ADD4_32(WSIGMA1_AVX(w[54]), w[40], w[49], WSIGMA0_AVX(w[41]));
  250. SHA256ROUND_AVX(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], 56, w[56]);
  251. w[57] = ADD4_32(WSIGMA1_AVX(w[55]), w[41], w[50], WSIGMA0_AVX(w[42]));
  252. SHA256ROUND_AVX(s[7], s[0], s[1], s[2], s[3], s[4], s[5], s[6], 57, w[57]);
  253. w[58] = ADD4_32(WSIGMA1_AVX(w[56]), w[42], w[51], WSIGMA0_AVX(w[43]));
  254. SHA256ROUND_AVX(s[6], s[7], s[0], s[1], s[2], s[3], s[4], s[5], 58, w[58]);
  255. w[59] = ADD4_32(WSIGMA1_AVX(w[57]), w[43], w[52], WSIGMA0_AVX(w[44]));
  256. SHA256ROUND_AVX(s[5], s[6], s[7], s[0], s[1], s[2], s[3], s[4], 59, w[59]);
  257. w[60] = ADD4_32(WSIGMA1_AVX(w[58]), w[44], w[53], WSIGMA0_AVX(w[45]));
  258. SHA256ROUND_AVX(s[4], s[5], s[6], s[7], s[0], s[1], s[2], s[3], 60, w[60]);
  259. w[61] = ADD4_32(WSIGMA1_AVX(w[59]), w[45], w[54], WSIGMA0_AVX(w[46]));
  260. SHA256ROUND_AVX(s[3], s[4], s[5], s[6], s[7], s[0], s[1], s[2], 61, w[61]);
  261. w[62] = ADD4_32(WSIGMA1_AVX(w[60]), w[46], w[55], WSIGMA0_AVX(w[47]));
  262. SHA256ROUND_AVX(s[2], s[3], s[4], s[5], s[6], s[7], s[0], s[1], 62, w[62]);
  263. w[63] = ADD4_32(WSIGMA1_AVX(w[61]), w[47], w[56], WSIGMA0_AVX(w[48]));
  264. SHA256ROUND_AVX(s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[0], 63, w[63]);
  265. // Feed Forward
  266. ctx->s[0] = ADD32(s[0], ctx->s[0]);
  267. ctx->s[1] = ADD32(s[1], ctx->s[1]);
  268. ctx->s[2] = ADD32(s[2], ctx->s[2]);
  269. ctx->s[3] = ADD32(s[3], ctx->s[3]);
  270. ctx->s[4] = ADD32(s[4], ctx->s[4]);
  271. ctx->s[5] = ADD32(s[5], ctx->s[5]);
  272. ctx->s[6] = ADD32(s[6], ctx->s[6]);
  273. ctx->s[7] = ADD32(s[7], ctx->s[7]);
  274. }