82 uint32_t A = digest[0], B = digest[1], C = digest[2], D = digest[3], E = digest[4], F = digest[5], G = digest[6],
84 std::array<uint32_t, 16> W;
88 for(
size_t i = 0; i != blocks; ++i) {
93 R1(A, B, C, D, E, F, G, H, 0x79CC4519, W[ 0], W[ 0] ^ W[ 4]);
94 W[ 0] = SM3_E(W[ 0], W[ 7], W[13], W[ 3], W[10]);
95 R1(D, A, B, C, H, E, F, G, 0xF3988A32, W[ 1], W[ 1] ^ W[ 5]);
96 W[ 1] = SM3_E(W[ 1], W[ 8], W[14], W[ 4], W[11]);
97 R1(C, D, A, B, G, H, E, F, 0xE7311465, W[ 2], W[ 2] ^ W[ 6]);
98 W[ 2] = SM3_E(W[ 2], W[ 9], W[15], W[ 5], W[12]);
99 R1(B, C, D, A, F, G, H, E, 0xCE6228CB, W[ 3], W[ 3] ^ W[ 7]);
100 W[ 3] = SM3_E(W[ 3], W[10], W[ 0], W[ 6], W[13]);
101 R1(A, B, C, D, E, F, G, H, 0x9CC45197, W[ 4], W[ 4] ^ W[ 8]);
102 W[ 4] = SM3_E(W[ 4], W[11], W[ 1], W[ 7], W[14]);
103 R1(D, A, B, C, H, E, F, G, 0x3988A32F, W[ 5], W[ 5] ^ W[ 9]);
104 W[ 5] = SM3_E(W[ 5], W[12], W[ 2], W[ 8], W[15]);
105 R1(C, D, A, B, G, H, E, F, 0x7311465E, W[ 6], W[ 6] ^ W[10]);
106 W[ 6] = SM3_E(W[ 6], W[13], W[ 3], W[ 9], W[ 0]);
107 R1(B, C, D, A, F, G, H, E, 0xE6228CBC, W[ 7], W[ 7] ^ W[11]);
108 W[ 7] = SM3_E(W[ 7], W[14], W[ 4], W[10], W[ 1]);
109 R1(A, B, C, D, E, F, G, H, 0xCC451979, W[ 8], W[ 8] ^ W[12]);
110 W[ 8] = SM3_E(W[ 8], W[15], W[ 5], W[11], W[ 2]);
111 R1(D, A, B, C, H, E, F, G, 0x988A32F3, W[ 9], W[ 9] ^ W[13]);
112 W[ 9] = SM3_E(W[ 9], W[ 0], W[ 6], W[12], W[ 3]);
113 R1(C, D, A, B, G, H, E, F, 0x311465E7, W[10], W[10] ^ W[14]);
114 W[10] = SM3_E(W[10], W[ 1], W[ 7], W[13], W[ 4]);
115 R1(B, C, D, A, F, G, H, E, 0x6228CBCE, W[11], W[11] ^ W[15]);
116 W[11] = SM3_E(W[11], W[ 2], W[ 8], W[14], W[ 5]);
117 R1(A, B, C, D, E, F, G, H, 0xC451979C, W[12], W[12] ^ W[ 0]);
118 W[12] = SM3_E(W[12], W[ 3], W[ 9], W[15], W[ 6]);
119 R1(D, A, B, C, H, E, F, G, 0x88A32F39, W[13], W[13] ^ W[ 1]);
120 W[13] = SM3_E(W[13], W[ 4], W[10], W[ 0], W[ 7]);
121 R1(C, D, A, B, G, H, E, F, 0x11465E73, W[14], W[14] ^ W[ 2]);
122 W[14] = SM3_E(W[14], W[ 5], W[11], W[ 1], W[ 8]);
123 R1(B, C, D, A, F, G, H, E, 0x228CBCE6, W[15], W[15] ^ W[ 3]);
124 W[15] = SM3_E(W[15], W[ 6], W[12], W[ 2], W[ 9]);
125 R2(A, B, C, D, E, F, G, H, 0x9D8A7A87, W[ 0], W[ 0] ^ W[ 4]);
126 W[ 0] = SM3_E(W[ 0], W[ 7], W[13], W[ 3], W[10]);
127 R2(D, A, B, C, H, E, F, G, 0x3B14F50F, W[ 1], W[ 1] ^ W[ 5]);
128 W[ 1] = SM3_E(W[ 1], W[ 8], W[14], W[ 4], W[11]);
129 R2(C, D, A, B, G, H, E, F, 0x7629EA1E, W[ 2], W[ 2] ^ W[ 6]);
130 W[ 2] = SM3_E(W[ 2], W[ 9], W[15], W[ 5], W[12]);
131 R2(B, C, D, A, F, G, H, E, 0xEC53D43C, W[ 3], W[ 3] ^ W[ 7]);
132 W[ 3] = SM3_E(W[ 3], W[10], W[ 0], W[ 6], W[13]);
133 R2(A, B, C, D, E, F, G, H, 0xD8A7A879, W[ 4], W[ 4] ^ W[ 8]);
134 W[ 4] = SM3_E(W[ 4], W[11], W[ 1], W[ 7], W[14]);
135 R2(D, A, B, C, H, E, F, G, 0xB14F50F3, W[ 5], W[ 5] ^ W[ 9]);
136 W[ 5] = SM3_E(W[ 5], W[12], W[ 2], W[ 8], W[15]);
137 R2(C, D, A, B, G, H, E, F, 0x629EA1E7, W[ 6], W[ 6] ^ W[10]);
138 W[ 6] = SM3_E(W[ 6], W[13], W[ 3], W[ 9], W[ 0]);
139 R2(B, C, D, A, F, G, H, E, 0xC53D43CE, W[ 7], W[ 7] ^ W[11]);
140 W[ 7] = SM3_E(W[ 7], W[14], W[ 4], W[10], W[ 1]);
141 R2(A, B, C, D, E, F, G, H, 0x8A7A879D, W[ 8], W[ 8] ^ W[12]);
142 W[ 8] = SM3_E(W[ 8], W[15], W[ 5], W[11], W[ 2]);
143 R2(D, A, B, C, H, E, F, G, 0x14F50F3B, W[ 9], W[ 9] ^ W[13]);
144 W[ 9] = SM3_E(W[ 9], W[ 0], W[ 6], W[12], W[ 3]);
145 R2(C, D, A, B, G, H, E, F, 0x29EA1E76, W[10], W[10] ^ W[14]);
146 W[10] = SM3_E(W[10], W[ 1], W[ 7], W[13], W[ 4]);
147 R2(B, C, D, A, F, G, H, E, 0x53D43CEC, W[11], W[11] ^ W[15]);
148 W[11] = SM3_E(W[11], W[ 2], W[ 8], W[14], W[ 5]);
149 R2(A, B, C, D, E, F, G, H, 0xA7A879D8, W[12], W[12] ^ W[ 0]);
150 W[12] = SM3_E(W[12], W[ 3], W[ 9], W[15], W[ 6]);
151 R2(D, A, B, C, H, E, F, G, 0x4F50F3B1, W[13], W[13] ^ W[ 1]);
152 W[13] = SM3_E(W[13], W[ 4], W[10], W[ 0], W[ 7]);
153 R2(C, D, A, B, G, H, E, F, 0x9EA1E762, W[14], W[14] ^ W[ 2]);
154 W[14] = SM3_E(W[14], W[ 5], W[11], W[ 1], W[ 8]);
155 R2(B, C, D, A, F, G, H, E, 0x3D43CEC5, W[15], W[15] ^ W[ 3]);
156 W[15] = SM3_E(W[15], W[ 6], W[12], W[ 2], W[ 9]);
157 R2(A, B, C, D, E, F, G, H, 0x7A879D8A, W[ 0], W[ 0] ^ W[ 4]);
158 W[ 0] = SM3_E(W[ 0], W[ 7], W[13], W[ 3], W[10]);
159 R2(D, A, B, C, H, E, F, G, 0xF50F3B14, W[ 1], W[ 1] ^ W[ 5]);
160 W[ 1] = SM3_E(W[ 1], W[ 8], W[14], W[ 4], W[11]);
161 R2(C, D, A, B, G, H, E, F, 0xEA1E7629, W[ 2], W[ 2] ^ W[ 6]);
162 W[ 2] = SM3_E(W[ 2], W[ 9], W[15], W[ 5], W[12]);
163 R2(B, C, D, A, F, G, H, E, 0xD43CEC53, W[ 3], W[ 3] ^ W[ 7]);
164 W[ 3] = SM3_E(W[ 3], W[10], W[ 0], W[ 6], W[13]);
165 R2(A, B, C, D, E, F, G, H, 0xA879D8A7, W[ 4], W[ 4] ^ W[ 8]);
166 W[ 4] = SM3_E(W[ 4], W[11], W[ 1], W[ 7], W[14]);
167 R2(D, A, B, C, H, E, F, G, 0x50F3B14F, W[ 5], W[ 5] ^ W[ 9]);
168 W[ 5] = SM3_E(W[ 5], W[12], W[ 2], W[ 8], W[15]);
169 R2(C, D, A, B, G, H, E, F, 0xA1E7629E, W[ 6], W[ 6] ^ W[10]);
170 W[ 6] = SM3_E(W[ 6], W[13], W[ 3], W[ 9], W[ 0]);
171 R2(B, C, D, A, F, G, H, E, 0x43CEC53D, W[ 7], W[ 7] ^ W[11]);
172 W[ 7] = SM3_E(W[ 7], W[14], W[ 4], W[10], W[ 1]);
173 R2(A, B, C, D, E, F, G, H, 0x879D8A7A, W[ 8], W[ 8] ^ W[12]);
174 W[ 8] = SM3_E(W[ 8], W[15], W[ 5], W[11], W[ 2]);
175 R2(D, A, B, C, H, E, F, G, 0x0F3B14F5, W[ 9], W[ 9] ^ W[13]);
176 W[ 9] = SM3_E(W[ 9], W[ 0], W[ 6], W[12], W[ 3]);
177 R2(C, D, A, B, G, H, E, F, 0x1E7629EA, W[10], W[10] ^ W[14]);
178 W[10] = SM3_E(W[10], W[ 1], W[ 7], W[13], W[ 4]);
179 R2(B, C, D, A, F, G, H, E, 0x3CEC53D4, W[11], W[11] ^ W[15]);
180 W[11] = SM3_E(W[11], W[ 2], W[ 8], W[14], W[ 5]);
181 R2(A, B, C, D, E, F, G, H, 0x79D8A7A8, W[12], W[12] ^ W[ 0]);
182 W[12] = SM3_E(W[12], W[ 3], W[ 9], W[15], W[ 6]);
183 R2(D, A, B, C, H, E, F, G, 0xF3B14F50, W[13], W[13] ^ W[ 1]);
184 W[13] = SM3_E(W[13], W[ 4], W[10], W[ 0], W[ 7]);
185 R2(C, D, A, B, G, H, E, F, 0xE7629EA1, W[14], W[14] ^ W[ 2]);
186 W[14] = SM3_E(W[14], W[ 5], W[11], W[ 1], W[ 8]);
187 R2(B, C, D, A, F, G, H, E, 0xCEC53D43, W[15], W[15] ^ W[ 3]);
188 W[15] = SM3_E(W[15], W[ 6], W[12], W[ 2], W[ 9]);
189 R2(A, B, C, D, E, F, G, H, 0x9D8A7A87, W[ 0], W[ 0] ^ W[ 4]);
190 W[ 0] = SM3_E(W[ 0], W[ 7], W[13], W[ 3], W[10]);
191 R2(D, A, B, C, H, E, F, G, 0x3B14F50F, W[ 1], W[ 1] ^ W[ 5]);
192 W[ 1] = SM3_E(W[ 1], W[ 8], W[14], W[ 4], W[11]);
193 R2(C, D, A, B, G, H, E, F, 0x7629EA1E, W[ 2], W[ 2] ^ W[ 6]);
194 W[ 2] = SM3_E(W[ 2], W[ 9], W[15], W[ 5], W[12]);
195 R2(B, C, D, A, F, G, H, E, 0xEC53D43C, W[ 3], W[ 3] ^ W[ 7]);
196 W[ 3] = SM3_E(W[ 3], W[10], W[ 0], W[ 6], W[13]);
197 R2(A, B, C, D, E, F, G, H, 0xD8A7A879, W[ 4], W[ 4] ^ W[ 8]);
198 R2(D, A, B, C, H, E, F, G, 0xB14F50F3, W[ 5], W[ 5] ^ W[ 9]);
199 R2(C, D, A, B, G, H, E, F, 0x629EA1E7, W[ 6], W[ 6] ^ W[10]);
200 R2(B, C, D, A, F, G, H, E, 0xC53D43CE, W[ 7], W[ 7] ^ W[11]);
201 R2(A, B, C, D, E, F, G, H, 0x8A7A879D, W[ 8], W[ 8] ^ W[12]);
202 R2(D, A, B, C, H, E, F, G, 0x14F50F3B, W[ 9], W[ 9] ^ W[13]);
203 R2(C, D, A, B, G, H, E, F, 0x29EA1E76, W[10], W[10] ^ W[14]);
204 R2(B, C, D, A, F, G, H, E, 0x53D43CEC, W[11], W[11] ^ W[15]);
205 R2(A, B, C, D, E, F, G, H, 0xA7A879D8, W[12], W[12] ^ W[ 0]);
206 R2(D, A, B, C, H, E, F, G, 0x4F50F3B1, W[13], W[13] ^ W[ 1]);
207 R2(C, D, A, B, G, H, E, F, 0x9EA1E762, W[14], W[14] ^ W[ 2]);
208 R2(B, C, D, A, F, G, H, E, 0x3D43CEC5, W[15], W[15] ^ W[ 3]);
212 A = (digest[0] ^= A);
213 B = (digest[1] ^= B);
214 C = (digest[2] ^= C);
215 D = (digest[3] ^= D);
216 E = (digest[4] ^= E);
217 F = (digest[5] ^= F);
218 G = (digest[6] ^= G);
219 H = (digest[7] ^= H);