Sha2Impl.hpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
22 //----------------------------------------------------------------------
23 #ifndef ICL_CORE_CRYPT_SHA2_IMPL_HPP_INCLUDED
24 #define ICL_CORE_CRYPT_SHA2_IMPL_HPP_INCLUDED
25 
26 #include <sstream>
27 #include <iomanip>
28 #include <string.h>
29 
30 namespace icl_core {
31 namespace crypt {
32 
33 #define TEMPLATEM template <typename T, T t_h0, T t_h1, T t_h2, T t_h3, T t_h4, T t_h5, T t_h6, T t_h7, size_t t_len>
34 #define CLASSM Sha2Impl<T, t_h0, t_h1, t_h2, t_h3, t_h4, t_h5, t_h6, t_h7, t_len>
35 
37 CLASSM::Sha2Impl()
38 {
39  clear();
40 }
41 
43 void CLASSM::clear()
44 {
45  m_message_size = 0;
46  m_buffer_fill = 0;
47  m_digest[0] = t_h0;
48  m_digest[1] = t_h1;
49  m_digest[2] = t_h2;
50  m_digest[3] = t_h3;
51  m_digest[4] = t_h4;
52  m_digest[5] = t_h5;
53  m_digest[6] = t_h6;
54  m_digest[7] = t_h7;
55 }
56 
58 ::icl_core::String CLASSM::getHexDigest() const
59 {
60  std::stringstream ss;
61  for (size_t i = 0; i < t_len; ++i)
62  {
63  ss << std::hex << std::setw(8) << std::setfill('0') << m_digest[i];
64  }
65  return ss.str();
66 }
67 
68 #define bswaparr(buf, T, i) ((static_cast<T>(buf[(i)*4+3]) ) | \
69  (static_cast<T>(buf[(i)*4+2]) << 8) | \
70  (static_cast<T>(buf[(i)*4+1]) << 16) | \
71  (static_cast<T>(buf[(i)*4+0]) << 24))
72 
73 #define bswaparr64(buf, T, i) ((static_cast<T>(buf[(i)*8+7]) ) | \
74  (static_cast<T>(buf[(i)*8+6]) << 8) | \
75  (static_cast<T>(buf[(i)*8+5]) << 16) | \
76  (static_cast<T>(buf[(i)*8+4]) << 24) | \
77  (static_cast<T>(buf[(i)*8+3]) << 32) | \
78  (static_cast<T>(buf[(i)*8+2]) << 40) | \
79  (static_cast<T>(buf[(i)*8+1]) << 48) | \
80  (static_cast<T>(buf[(i)*8+0]) << 56))
81 
83 #define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
84 #define Maj(x, y, z) (((x) & (y)) | ((z) & ((x) ^ (y))))
86 #define Rotr(x, n, nbits) (((x) >> (n)) | ((x) << ((nbits)-(n))))
88 #define Shr(x, n) ((x) >> (n))
90 #define wv(i) v##i
92 
93 #define Sigma0_256(x) (Rotr((x), 2, 32) ^ Rotr((x), 13, 32) ^ Rotr((x), 22, 32))
94 #define Sigma1_256(x) (Rotr((x), 6, 32) ^ Rotr((x), 11, 32) ^ Rotr((x), 25, 32))
95 #define sigma0_256(x) (Rotr((x), 7, 32) ^ Rotr((x), 18, 32) ^ Shr((x), 3))
96 #define sigma1_256(x) (Rotr((x), 17, 32) ^ Rotr((x), 19, 32) ^ Shr((x), 10))
97 
98 //----------------------------------------------------------------------
99 // Implementation specifics for 32-bit words
100 //----------------------------------------------------------------------
101 
102 static const uint32_t k256[64] = {
103  0x428a2f98ul, 0x71374491ul, 0xb5c0fbcful, 0xe9b5dba5ul, 0x3956c25bul, 0x59f111f1ul, 0x923f82a4ul, 0xab1c5ed5ul,
104  0xd807aa98ul, 0x12835b01ul, 0x243185beul, 0x550c7dc3ul, 0x72be5d74ul, 0x80deb1feul, 0x9bdc06a7ul, 0xc19bf174ul,
105  0xe49b69c1ul, 0xefbe4786ul, 0x0fc19dc6ul, 0x240ca1ccul, 0x2de92c6ful, 0x4a7484aaul, 0x5cb0a9dcul, 0x76f988daul,
106  0x983e5152ul, 0xa831c66dul, 0xb00327c8ul, 0xbf597fc7ul, 0xc6e00bf3ul, 0xd5a79147ul, 0x06ca6351ul, 0x14292967ul,
107  0x27b70a85ul, 0x2e1b2138ul, 0x4d2c6dfcul, 0x53380d13ul, 0x650a7354ul, 0x766a0abbul, 0x81c2c92eul, 0x92722c85ul,
108  0xa2bfe8a1ul, 0xa81a664bul, 0xc24b8b70ul, 0xc76c51a3ul, 0xd192e819ul, 0xd6990624ul, 0xf40e3585ul, 0x106aa070ul,
109  0x19a4c116ul, 0x1e376c08ul, 0x2748774cul, 0x34b0bcb5ul, 0x391c0cb3ul, 0x4ed8aa4aul, 0x5b9cca4ful, 0x682e6ff3ul,
110  0x748f82eeul, 0x78a5636ful, 0x84c87814ul, 0x8cc70208ul, 0x90befffaul, 0xa4506cebul, 0xbef9a3f7ul, 0xc67178f2ul
111 };
112 
113 #define round_0_15(a, b, c, d, e, f, g, h, K, W, t) \
114  T1 = wv(h) + Sigma1_256(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \
115  T2 = Sigma0_256(wv(a)) + Maj(wv(a), wv(b), wv(c)); \
116  wv(d) += T1; \
117  wv(h) = T1 + T2;
118 
119 #define round_16_63(a, b, c, d, e, f, g, h, K, W, t) \
120  W[(t)&15] += sigma1_256(W[(t+14)&15]) + W[(t+9)&15] + sigma0_256(W[(t+1)&15]); \
121  T1 = wv(h) + Sigma1_256(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \
122  T2 = Sigma0_256(wv(a)) + Maj(wv(a), wv(b), wv(c)); \
123  wv(d) += T1; \
124  wv(h) = T1 + T2;
125 
126 TEMPLATEM
127 void CLASSM::processBuffer()
128 {
129  T v0 = m_digest[0];
130  T v1 = m_digest[1];
131  T v2 = m_digest[2];
132  T v3 = m_digest[3];
133  T v4 = m_digest[4];
134  T v5 = m_digest[5];
135  T v6 = m_digest[6];
136  T v7 = m_digest[7];
137 
138  T w[16] = {
139  bswaparr(m_buffer, T, 0), bswaparr(m_buffer, T, 1),
140  bswaparr(m_buffer, T, 2), bswaparr(m_buffer, T, 3),
141  bswaparr(m_buffer, T, 4), bswaparr(m_buffer, T, 5),
142  bswaparr(m_buffer, T, 6), bswaparr(m_buffer, T, 7),
143  bswaparr(m_buffer, T, 8), bswaparr(m_buffer, T, 9),
144  bswaparr(m_buffer, T, 10), bswaparr(m_buffer, T, 11),
145  bswaparr(m_buffer, T, 12), bswaparr(m_buffer, T, 13),
146  bswaparr(m_buffer, T, 14), bswaparr(m_buffer, T, 15)
147  };
148  T T1, T2;
149 
150  round_0_15(0,1,2,3,4,5,6,7, k256, w, 0);
151  round_0_15(7,0,1,2,3,4,5,6, k256, w, 1);
152  round_0_15(6,7,0,1,2,3,4,5, k256, w, 2);
153  round_0_15(5,6,7,0,1,2,3,4, k256, w, 3);
154  round_0_15(4,5,6,7,0,1,2,3, k256, w, 4);
155  round_0_15(3,4,5,6,7,0,1,2, k256, w, 5);
156  round_0_15(2,3,4,5,6,7,0,1, k256, w, 6);
157  round_0_15(1,2,3,4,5,6,7,0, k256, w, 7);
158 
159  round_0_15(0,1,2,3,4,5,6,7, k256, w, 8);
160  round_0_15(7,0,1,2,3,4,5,6, k256, w, 9);
161  round_0_15(6,7,0,1,2,3,4,5, k256, w, 10);
162  round_0_15(5,6,7,0,1,2,3,4, k256, w, 11);
163  round_0_15(4,5,6,7,0,1,2,3, k256, w, 12);
164  round_0_15(3,4,5,6,7,0,1,2, k256, w, 13);
165  round_0_15(2,3,4,5,6,7,0,1, k256, w, 14);
166  round_0_15(1,2,3,4,5,6,7,0, k256, w, 15);
167 
168  round_16_63(0,1,2,3,4,5,6,7, k256, w, 16);
169  round_16_63(7,0,1,2,3,4,5,6, k256, w, 17);
170  round_16_63(6,7,0,1,2,3,4,5, k256, w, 18);
171  round_16_63(5,6,7,0,1,2,3,4, k256, w, 19);
172  round_16_63(4,5,6,7,0,1,2,3, k256, w, 20);
173  round_16_63(3,4,5,6,7,0,1,2, k256, w, 21);
174  round_16_63(2,3,4,5,6,7,0,1, k256, w, 22);
175  round_16_63(1,2,3,4,5,6,7,0, k256, w, 23);
176 
177  round_16_63(0,1,2,3,4,5,6,7, k256, w, 24);
178  round_16_63(7,0,1,2,3,4,5,6, k256, w, 25);
179  round_16_63(6,7,0,1,2,3,4,5, k256, w, 26);
180  round_16_63(5,6,7,0,1,2,3,4, k256, w, 27);
181  round_16_63(4,5,6,7,0,1,2,3, k256, w, 28);
182  round_16_63(3,4,5,6,7,0,1,2, k256, w, 29);
183  round_16_63(2,3,4,5,6,7,0,1, k256, w, 30);
184  round_16_63(1,2,3,4,5,6,7,0, k256, w, 31);
185 
186  round_16_63(0,1,2,3,4,5,6,7, k256, w, 32);
187  round_16_63(7,0,1,2,3,4,5,6, k256, w, 33);
188  round_16_63(6,7,0,1,2,3,4,5, k256, w, 34);
189  round_16_63(5,6,7,0,1,2,3,4, k256, w, 35);
190  round_16_63(4,5,6,7,0,1,2,3, k256, w, 36);
191  round_16_63(3,4,5,6,7,0,1,2, k256, w, 37);
192  round_16_63(2,3,4,5,6,7,0,1, k256, w, 38);
193  round_16_63(1,2,3,4,5,6,7,0, k256, w, 39);
194 
195  round_16_63(0,1,2,3,4,5,6,7, k256, w, 40);
196  round_16_63(7,0,1,2,3,4,5,6, k256, w, 41);
197  round_16_63(6,7,0,1,2,3,4,5, k256, w, 42);
198  round_16_63(5,6,7,0,1,2,3,4, k256, w, 43);
199  round_16_63(4,5,6,7,0,1,2,3, k256, w, 44);
200  round_16_63(3,4,5,6,7,0,1,2, k256, w, 45);
201  round_16_63(2,3,4,5,6,7,0,1, k256, w, 46);
202  round_16_63(1,2,3,4,5,6,7,0, k256, w, 47);
203 
204  round_16_63(0,1,2,3,4,5,6,7, k256, w, 48);
205  round_16_63(7,0,1,2,3,4,5,6, k256, w, 49);
206  round_16_63(6,7,0,1,2,3,4,5, k256, w, 50);
207  round_16_63(5,6,7,0,1,2,3,4, k256, w, 51);
208  round_16_63(4,5,6,7,0,1,2,3, k256, w, 52);
209  round_16_63(3,4,5,6,7,0,1,2, k256, w, 53);
210  round_16_63(2,3,4,5,6,7,0,1, k256, w, 54);
211  round_16_63(1,2,3,4,5,6,7,0, k256, w, 55);
212 
213  round_16_63(0,1,2,3,4,5,6,7, k256, w, 56);
214  round_16_63(7,0,1,2,3,4,5,6, k256, w, 57);
215  round_16_63(6,7,0,1,2,3,4,5, k256, w, 58);
216  round_16_63(5,6,7,0,1,2,3,4, k256, w, 59);
217  round_16_63(4,5,6,7,0,1,2,3, k256, w, 60);
218  round_16_63(3,4,5,6,7,0,1,2, k256, w, 61);
219  round_16_63(2,3,4,5,6,7,0,1, k256, w, 62);
220  round_16_63(1,2,3,4,5,6,7,0, k256, w, 63);
221 
222  m_digest[0] += v0;
223  m_digest[1] += v1;
224  m_digest[2] += v2;
225  m_digest[3] += v3;
226  m_digest[4] += v4;
227  m_digest[5] += v5;
228  m_digest[6] += v6;
229  m_digest[7] += v7;
230 }
231 
232 #undef TEMPLATEM
233 #undef CLASSM
234 
235 #undef round_0_15
236 #undef round_16_63
237 
238 //----------------------------------------------------------------------
239 // Implementation specifics for 64-bit words
240 //----------------------------------------------------------------------
241 
242 static const uint64_t k512[80] = {
243  0x428a2f98d728ae22ull, 0x7137449123ef65cdull, 0xb5c0fbcfec4d3b2full, 0xe9b5dba58189dbbcull,
244  0x3956c25bf348b538ull, 0x59f111f1b605d019ull, 0x923f82a4af194f9bull, 0xab1c5ed5da6d8118ull,
245  0xd807aa98a3030242ull, 0x12835b0145706fbeull, 0x243185be4ee4b28cull, 0x550c7dc3d5ffb4e2ull,
246  0x72be5d74f27b896full, 0x80deb1fe3b1696b1ull, 0x9bdc06a725c71235ull, 0xc19bf174cf692694ull,
247  0xe49b69c19ef14ad2ull, 0xefbe4786384f25e3ull, 0x0fc19dc68b8cd5b5ull, 0x240ca1cc77ac9c65ull,
248  0x2de92c6f592b0275ull, 0x4a7484aa6ea6e483ull, 0x5cb0a9dcbd41fbd4ull, 0x76f988da831153b5ull,
249  0x983e5152ee66dfabull, 0xa831c66d2db43210ull, 0xb00327c898fb213full, 0xbf597fc7beef0ee4ull,
250  0xc6e00bf33da88fc2ull, 0xd5a79147930aa725ull, 0x06ca6351e003826full, 0x142929670a0e6e70ull,
251  0x27b70a8546d22ffcull, 0x2e1b21385c26c926ull, 0x4d2c6dfc5ac42aedull, 0x53380d139d95b3dfull,
252  0x650a73548baf63deull, 0x766a0abb3c77b2a8ull, 0x81c2c92e47edaee6ull, 0x92722c851482353bull,
253  0xa2bfe8a14cf10364ull, 0xa81a664bbc423001ull, 0xc24b8b70d0f89791ull, 0xc76c51a30654be30ull,
254  0xd192e819d6ef5218ull, 0xd69906245565a910ull, 0xf40e35855771202aull, 0x106aa07032bbd1b8ull,
255  0x19a4c116b8d2d0c8ull, 0x1e376c085141ab53ull, 0x2748774cdf8eeb99ull, 0x34b0bcb5e19b48a8ull,
256  0x391c0cb3c5c95a63ull, 0x4ed8aa4ae3418acbull, 0x5b9cca4f7763e373ull, 0x682e6ff3d6b2b8a3ull,
257  0x748f82ee5defb2fcull, 0x78a5636f43172f60ull, 0x84c87814a1f0ab72ull, 0x8cc702081a6439ecull,
258  0x90befffa23631e28ull, 0xa4506cebde82bde9ull, 0xbef9a3f7b2c67915ull, 0xc67178f2e372532bull,
259  0xca273eceea26619cull, 0xd186b8c721c0c207ull, 0xeada7dd6cde0eb1eull, 0xf57d4f7fee6ed178ull,
260  0x06f067aa72176fbaull, 0x0a637dc5a2c898a6ull, 0x113f9804bef90daeull, 0x1b710b35131c471bull,
261  0x28db77f523047d84ull, 0x32caab7b40c72493ull, 0x3c9ebe0a15c9bebcull, 0x431d67c49c100d4cull,
262  0x4cc5d4becb3e42b6ull, 0x597f299cfc657e2aull, 0x5fcb6fab3ad6faecull, 0x6c44198c4a475817ull
263 };
264 
265 #define TEMPLATEM template <uint64_t t_h0, uint64_t t_h1, uint64_t t_h2, uint64_t t_h3, uint64_t t_h4, uint64_t t_h5, uint64_t t_h6, uint64_t t_h7, size_t t_len>
266 #define CLASSM Sha2Impl<uint64_t, t_h0, t_h1, t_h2, t_h3, t_h4, t_h5, t_h6, t_h7, t_len>
267 
268 #define Sigma0_512(x) (Rotr((x), 28, 64) ^ Rotr((x), 34, 64) ^ Rotr((x), 39, 64))
269 #define Sigma1_512(x) (Rotr((x), 14, 64) ^ Rotr((x), 18, 64) ^ Rotr((x), 41, 64))
270 #define sigma0_512(x) (Rotr((x), 1, 64) ^ Rotr((x), 8, 64) ^ Shr((x), 7))
271 #define sigma1_512(x) (Rotr((x), 19, 64) ^ Rotr((x), 61, 64) ^ Shr((x), 6))
272 
273 TEMPLATEM
274 CLASSM::Sha2Impl()
275 {
276  clear();
277 }
278 
279 TEMPLATEM
280 void CLASSM::clear()
281 {
282  m_message_size = 0;
283  m_buffer_fill = 0;
284  m_digest[0] = t_h0;
285  m_digest[1] = t_h1;
286  m_digest[2] = t_h2;
287  m_digest[3] = t_h3;
288  m_digest[4] = t_h4;
289  m_digest[5] = t_h5;
290  m_digest[6] = t_h6;
291  m_digest[7] = t_h7;
292 }
293 
294 TEMPLATEM
295 ::icl_core::String CLASSM::getHexDigest() const
296 {
297  std::stringstream ss;
298  for (size_t i = 0; i < t_len; ++i)
299  {
300  ss << std::hex << std::setw(16) << std::setfill('0') << m_digest[i];
301  }
302  return ss.str();
303 }
304 
305 #define round_0_15(a, b, c, d, e, f, g, h, K, W, t) \
306  T1 = wv(h) + Sigma1_512(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \
307  T2 = Sigma0_512(wv(a)) + Maj(wv(a), wv(b), wv(c)); \
308  wv(d) += T1; \
309  wv(h) = T1 + T2;
310 
311 #define round_16_79(a, b, c, d, e, f, g, h, K, W, t) \
312  W[(t)&15] += sigma1_512(W[(t+14)&15]) + W[(t+9)&15] + sigma0_512(W[(t+1)&15]); \
313  T1 = wv(h) + Sigma1_512(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \
314  T2 = Sigma0_512(wv(a)) + Maj(wv(a), wv(b), wv(c)); \
315  wv(d) += T1; \
316  wv(h) = T1 + T2;
317 
318 TEMPLATEM
319 void CLASSM::processBuffer()
320 {
321  uint64_t v0 = m_digest[0];
322  uint64_t v1 = m_digest[1];
323  uint64_t v2 = m_digest[2];
324  uint64_t v3 = m_digest[3];
325  uint64_t v4 = m_digest[4];
326  uint64_t v5 = m_digest[5];
327  uint64_t v6 = m_digest[6];
328  uint64_t v7 = m_digest[7];
329 
330  uint64_t w[16] = {
331  bswaparr64(m_buffer, uint64_t, 0), bswaparr64(m_buffer, uint64_t, 1),
332  bswaparr64(m_buffer, uint64_t, 2), bswaparr64(m_buffer, uint64_t, 3),
333  bswaparr64(m_buffer, uint64_t, 4), bswaparr64(m_buffer, uint64_t, 5),
334  bswaparr64(m_buffer, uint64_t, 6), bswaparr64(m_buffer, uint64_t, 7),
335  bswaparr64(m_buffer, uint64_t, 8), bswaparr64(m_buffer, uint64_t, 9),
336  bswaparr64(m_buffer, uint64_t, 10), bswaparr64(m_buffer, uint64_t, 11),
337  bswaparr64(m_buffer, uint64_t, 12), bswaparr64(m_buffer, uint64_t, 13),
338  bswaparr64(m_buffer, uint64_t, 14), bswaparr64(m_buffer, uint64_t, 15)
339  };
340  uint64_t T1, T2;
341 
342  round_0_15(0,1,2,3,4,5,6,7, k512, w, 0);
343  round_0_15(7,0,1,2,3,4,5,6, k512, w, 1);
344  round_0_15(6,7,0,1,2,3,4,5, k512, w, 2);
345  round_0_15(5,6,7,0,1,2,3,4, k512, w, 3);
346  round_0_15(4,5,6,7,0,1,2,3, k512, w, 4);
347  round_0_15(3,4,5,6,7,0,1,2, k512, w, 5);
348  round_0_15(2,3,4,5,6,7,0,1, k512, w, 6);
349  round_0_15(1,2,3,4,5,6,7,0, k512, w, 7);
350 
351  round_0_15(0,1,2,3,4,5,6,7, k512, w, 8);
352  round_0_15(7,0,1,2,3,4,5,6, k512, w, 9);
353  round_0_15(6,7,0,1,2,3,4,5, k512, w, 10);
354  round_0_15(5,6,7,0,1,2,3,4, k512, w, 11);
355  round_0_15(4,5,6,7,0,1,2,3, k512, w, 12);
356  round_0_15(3,4,5,6,7,0,1,2, k512, w, 13);
357  round_0_15(2,3,4,5,6,7,0,1, k512, w, 14);
358  round_0_15(1,2,3,4,5,6,7,0, k512, w, 15);
359 
360  round_16_79(0,1,2,3,4,5,6,7, k512, w, 16);
361  round_16_79(7,0,1,2,3,4,5,6, k512, w, 17);
362  round_16_79(6,7,0,1,2,3,4,5, k512, w, 18);
363  round_16_79(5,6,7,0,1,2,3,4, k512, w, 19);
364  round_16_79(4,5,6,7,0,1,2,3, k512, w, 20);
365  round_16_79(3,4,5,6,7,0,1,2, k512, w, 21);
366  round_16_79(2,3,4,5,6,7,0,1, k512, w, 22);
367  round_16_79(1,2,3,4,5,6,7,0, k512, w, 23);
368 
369  round_16_79(0,1,2,3,4,5,6,7, k512, w, 24);
370  round_16_79(7,0,1,2,3,4,5,6, k512, w, 25);
371  round_16_79(6,7,0,1,2,3,4,5, k512, w, 26);
372  round_16_79(5,6,7,0,1,2,3,4, k512, w, 27);
373  round_16_79(4,5,6,7,0,1,2,3, k512, w, 28);
374  round_16_79(3,4,5,6,7,0,1,2, k512, w, 29);
375  round_16_79(2,3,4,5,6,7,0,1, k512, w, 30);
376  round_16_79(1,2,3,4,5,6,7,0, k512, w, 31);
377 
378  round_16_79(0,1,2,3,4,5,6,7, k512, w, 32);
379  round_16_79(7,0,1,2,3,4,5,6, k512, w, 33);
380  round_16_79(6,7,0,1,2,3,4,5, k512, w, 34);
381  round_16_79(5,6,7,0,1,2,3,4, k512, w, 35);
382  round_16_79(4,5,6,7,0,1,2,3, k512, w, 36);
383  round_16_79(3,4,5,6,7,0,1,2, k512, w, 37);
384  round_16_79(2,3,4,5,6,7,0,1, k512, w, 38);
385  round_16_79(1,2,3,4,5,6,7,0, k512, w, 39);
386 
387  round_16_79(0,1,2,3,4,5,6,7, k512, w, 40);
388  round_16_79(7,0,1,2,3,4,5,6, k512, w, 41);
389  round_16_79(6,7,0,1,2,3,4,5, k512, w, 42);
390  round_16_79(5,6,7,0,1,2,3,4, k512, w, 43);
391  round_16_79(4,5,6,7,0,1,2,3, k512, w, 44);
392  round_16_79(3,4,5,6,7,0,1,2, k512, w, 45);
393  round_16_79(2,3,4,5,6,7,0,1, k512, w, 46);
394  round_16_79(1,2,3,4,5,6,7,0, k512, w, 47);
395 
396  round_16_79(0,1,2,3,4,5,6,7, k512, w, 48);
397  round_16_79(7,0,1,2,3,4,5,6, k512, w, 49);
398  round_16_79(6,7,0,1,2,3,4,5, k512, w, 50);
399  round_16_79(5,6,7,0,1,2,3,4, k512, w, 51);
400  round_16_79(4,5,6,7,0,1,2,3, k512, w, 52);
401  round_16_79(3,4,5,6,7,0,1,2, k512, w, 53);
402  round_16_79(2,3,4,5,6,7,0,1, k512, w, 54);
403  round_16_79(1,2,3,4,5,6,7,0, k512, w, 55);
404 
405  round_16_79(0,1,2,3,4,5,6,7, k512, w, 56);
406  round_16_79(7,0,1,2,3,4,5,6, k512, w, 57);
407  round_16_79(6,7,0,1,2,3,4,5, k512, w, 58);
408  round_16_79(5,6,7,0,1,2,3,4, k512, w, 59);
409  round_16_79(4,5,6,7,0,1,2,3, k512, w, 60);
410  round_16_79(3,4,5,6,7,0,1,2, k512, w, 61);
411  round_16_79(2,3,4,5,6,7,0,1, k512, w, 62);
412  round_16_79(1,2,3,4,5,6,7,0, k512, w, 63);
413 
414  round_16_79(0,1,2,3,4,5,6,7, k512, w, 64);
415  round_16_79(7,0,1,2,3,4,5,6, k512, w, 65);
416  round_16_79(6,7,0,1,2,3,4,5, k512, w, 66);
417  round_16_79(5,6,7,0,1,2,3,4, k512, w, 67);
418  round_16_79(4,5,6,7,0,1,2,3, k512, w, 68);
419  round_16_79(3,4,5,6,7,0,1,2, k512, w, 69);
420  round_16_79(2,3,4,5,6,7,0,1, k512, w, 70);
421  round_16_79(1,2,3,4,5,6,7,0, k512, w, 71);
422 
423  round_16_79(0,1,2,3,4,5,6,7, k512, w, 72);
424  round_16_79(7,0,1,2,3,4,5,6, k512, w, 73);
425  round_16_79(6,7,0,1,2,3,4,5, k512, w, 74);
426  round_16_79(5,6,7,0,1,2,3,4, k512, w, 75);
427  round_16_79(4,5,6,7,0,1,2,3, k512, w, 76);
428  round_16_79(3,4,5,6,7,0,1,2, k512, w, 77);
429  round_16_79(2,3,4,5,6,7,0,1, k512, w, 78);
430  round_16_79(1,2,3,4,5,6,7,0, k512, w, 79);
431 
432  m_digest[0] += v0;
433  m_digest[1] += v1;
434  m_digest[2] += v2;
435  m_digest[3] += v3;
436  m_digest[4] += v4;
437  m_digest[5] += v5;
438  m_digest[6] += v6;
439  m_digest[7] += v7;
440 }
441 
442 #undef TEMPLATEM
443 #undef CLASSM
444 
445 #undef round_0_15
446 #undef round_16_79
447 #undef bswap
448 #undef bswap64
449 #undef Ch
450 #undef Maj
451 #undef Rotr
452 #undef Shr
453 #undef wv
454 #undef Sigma0_256
455 #undef Sigma1_256
456 #undef sigma0_256
457 #undef sigma1_256
458 #undef Sigma0_512
459 #undef Sigma1_512
460 #undef sigma0_512
461 #undef sigma1_512
462 
463 }
464 }
465 
466 #endif
#define round_0_15(a, b, c, d, e, f, g, h, K, W, t)
Definition: Sha2Impl.hpp:305
unsigned int uint32_t
Definition: msvc_stdint.h:93
static const uint32_t k256[64]
Definition: Sha2Impl.hpp:102
#define round_16_63(a, b, c, d, e, f, g, h, K, W, t)
Definition: Sha2Impl.hpp:119
#define bswaparr(buf, T, i)
Definition: Sha2Impl.hpp:68
#define bswaparr64(buf, T, i)
Definition: Sha2Impl.hpp:73
unsigned __int64 uint64_t
Definition: msvc_stdint.h:103
#define round_16_79(a, b, c, d, e, f, g, h, K, W, t)
Definition: Sha2Impl.hpp:311
static const uint64_t k512[80]
Definition: Sha2Impl.hpp:242
std::string String
Definition: BaseTypes.h:43
#define TEMPLATEM
Definition: Sha2Impl.hpp:265


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58