64 using namespace SHA1_F;
66#if defined(BOTAN_HAS_SHA1_X86_SHA_NI)
67 if(CPUID::has_intel_sha()) {
72#if defined(BOTAN_HAS_SHA1_ARMV8)
73 if(CPUID::has_arm_sha1()) {
78#if defined(BOTAN_HAS_SHA1_SSE2)
79 if(CPUID::has_sse2()) {
85 uint32_t A = digest[0], B = digest[1], C = digest[2], D = digest[3], E = digest[4];
86 std::array<uint32_t, 80> W;
87 auto W_in = std::span{W}.first<
block_bytes /
sizeof(uint32_t)>();
91 for(
size_t i = 0; i != blocks; ++i) {
96 for(
size_t j = 16; j != 80; j += 8) {
97 W[j + 0] =
rotl<1>(W[j - 3] ^ W[j - 8] ^ W[j - 14] ^ W[j - 16]);
98 W[j + 1] =
rotl<1>(W[j - 2] ^ W[j - 7] ^ W[j - 13] ^ W[j - 15]);
99 W[j + 2] =
rotl<1>(W[j - 1] ^ W[j - 6] ^ W[j - 12] ^ W[j - 14]);
100 W[j + 3] =
rotl<1>(W[j ] ^ W[j - 5] ^ W[j - 11] ^ W[j - 13]);
101 W[j + 4] =
rotl<1>(W[j + 1] ^ W[j - 4] ^ W[j - 10] ^ W[j - 12]);
102 W[j + 5] =
rotl<1>(W[j + 2] ^ W[j - 3] ^ W[j - 9] ^ W[j - 11]);
103 W[j + 6] =
rotl<1>(W[j + 3] ^ W[j - 2] ^ W[j - 8] ^ W[j - 10]);
104 W[j + 7] =
rotl<1>(W[j + 4] ^ W[j - 1] ^ W[j - 7] ^ W[j - 9]);
109 F1(A, B, C, D, E, W[0]);
110 F1(E, A, B, C, D, W[1]);
111 F1(D, E, A, B, C, W[2]);
112 F1(C, D, E, A, B, W[3]);
113 F1(B, C, D, E, A, W[4]);
114 F1(A, B, C, D, E, W[5]);
115 F1(E, A, B, C, D, W[6]);
116 F1(D, E, A, B, C, W[7]);
117 F1(C, D, E, A, B, W[8]);
118 F1(B, C, D, E, A, W[9]);
119 F1(A, B, C, D, E, W[10]);
120 F1(E, A, B, C, D, W[11]);
121 F1(D, E, A, B, C, W[12]);
122 F1(C, D, E, A, B, W[13]);
123 F1(B, C, D, E, A, W[14]);
124 F1(A, B, C, D, E, W[15]);
125 F1(E, A, B, C, D, W[16]);
126 F1(D, E, A, B, C, W[17]);
127 F1(C, D, E, A, B, W[18]);
128 F1(B, C, D, E, A, W[19]);
130 F2(A, B, C, D, E, W[20]);
131 F2(E, A, B, C, D, W[21]);
132 F2(D, E, A, B, C, W[22]);
133 F2(C, D, E, A, B, W[23]);
134 F2(B, C, D, E, A, W[24]);
135 F2(A, B, C, D, E, W[25]);
136 F2(E, A, B, C, D, W[26]);
137 F2(D, E, A, B, C, W[27]);
138 F2(C, D, E, A, B, W[28]);
139 F2(B, C, D, E, A, W[29]);
140 F2(A, B, C, D, E, W[30]);
141 F2(E, A, B, C, D, W[31]);
142 F2(D, E, A, B, C, W[32]);
143 F2(C, D, E, A, B, W[33]);
144 F2(B, C, D, E, A, W[34]);
145 F2(A, B, C, D, E, W[35]);
146 F2(E, A, B, C, D, W[36]);
147 F2(D, E, A, B, C, W[37]);
148 F2(C, D, E, A, B, W[38]);
149 F2(B, C, D, E, A, W[39]);
151 F3(A, B, C, D, E, W[40]);
152 F3(E, A, B, C, D, W[41]);
153 F3(D, E, A, B, C, W[42]);
154 F3(C, D, E, A, B, W[43]);
155 F3(B, C, D, E, A, W[44]);
156 F3(A, B, C, D, E, W[45]);
157 F3(E, A, B, C, D, W[46]);
158 F3(D, E, A, B, C, W[47]);
159 F3(C, D, E, A, B, W[48]);
160 F3(B, C, D, E, A, W[49]);
161 F3(A, B, C, D, E, W[50]);
162 F3(E, A, B, C, D, W[51]);
163 F3(D, E, A, B, C, W[52]);
164 F3(C, D, E, A, B, W[53]);
165 F3(B, C, D, E, A, W[54]);
166 F3(A, B, C, D, E, W[55]);
167 F3(E, A, B, C, D, W[56]);
168 F3(D, E, A, B, C, W[57]);
169 F3(C, D, E, A, B, W[58]);
170 F3(B, C, D, E, A, W[59]);
172 F4(A, B, C, D, E, W[60]);
173 F4(E, A, B, C, D, W[61]);
174 F4(D, E, A, B, C, W[62]);
175 F4(C, D, E, A, B, W[63]);
176 F4(B, C, D, E, A, W[64]);
177 F4(A, B, C, D, E, W[65]);
178 F4(E, A, B, C, D, W[66]);
179 F4(D, E, A, B, C, W[67]);
180 F4(C, D, E, A, B, W[68]);
181 F4(B, C, D, E, A, W[69]);
182 F4(A, B, C, D, E, W[70]);
183 F4(E, A, B, C, D, W[71]);
184 F4(D, E, A, B, C, W[72]);
185 F4(C, D, E, A, B, W[73]);
186 F4(B, C, D, E, A, W[74]);
187 F4(A, B, C, D, E, W[75]);
188 F4(E, A, B, C, D, W[76]);
189 F4(D, E, A, B, C, W[77]);
190 F4(C, D, E, A, B, W[78]);
191 F4(B, C, D, E, A, W[79]);
193 A = (digest[0] += A);
194 B = (digest[1] += B);
195 C = (digest[2] += C);
196 D = (digest[3] += D);
197 E = (digest[4] += E);