Sha2Impl.hpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00022 //----------------------------------------------------------------------
00023 #ifndef ICL_CORE_CRYPT_SHA2_IMPL_HPP_INCLUDED
00024 #define ICL_CORE_CRYPT_SHA2_IMPL_HPP_INCLUDED
00025 
00026 #include <sstream>
00027 #include <iomanip>
00028 #include <string.h>
00029 
00030 namespace icl_core {
00031 namespace crypt {
00032 
00033 #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>
00034 #define CLASSM Sha2Impl<T, t_h0, t_h1, t_h2, t_h3, t_h4, t_h5, t_h6, t_h7, t_len>
00035 
00036 TEMPLATEM
00037 CLASSM::Sha2Impl()
00038 {
00039   clear();
00040 }
00041 
00042 TEMPLATEM
00043 void CLASSM::clear()
00044 {
00045   m_message_size = 0;
00046   m_buffer_fill = 0;
00047   m_digest[0] = t_h0;
00048   m_digest[1] = t_h1;
00049   m_digest[2] = t_h2;
00050   m_digest[3] = t_h3;
00051   m_digest[4] = t_h4;
00052   m_digest[5] = t_h5;
00053   m_digest[6] = t_h6;
00054   m_digest[7] = t_h7;
00055 }
00056 
00057 TEMPLATEM
00058 ::icl_core::String CLASSM::getHexDigest() const
00059 {
00060   std::stringstream ss;
00061   for (size_t i = 0; i < t_len; ++i)
00062   {
00063     ss << std::hex << std::setw(8) << std::setfill('0') << m_digest[i];
00064   }
00065   return ss.str();
00066 }
00067 
00068 #define bswaparr(buf, T, i) ((static_cast<T>(buf[(i)*4+3])      ) |     \
00069                              (static_cast<T>(buf[(i)*4+2]) <<  8) |     \
00070                              (static_cast<T>(buf[(i)*4+1]) << 16) |     \
00071                              (static_cast<T>(buf[(i)*4+0]) << 24))
00072 
00073 #define bswaparr64(buf, T, i) ((static_cast<T>(buf[(i)*8+7])      ) |   \
00074                                (static_cast<T>(buf[(i)*8+6]) <<  8) |   \
00075                                (static_cast<T>(buf[(i)*8+5]) << 16) |   \
00076                                (static_cast<T>(buf[(i)*8+4]) << 24) |   \
00077                                (static_cast<T>(buf[(i)*8+3]) << 32) |   \
00078                                (static_cast<T>(buf[(i)*8+2]) << 40) |   \
00079                                (static_cast<T>(buf[(i)*8+1]) << 48) |   \
00080                                (static_cast<T>(buf[(i)*8+0]) << 56))
00081 
00083 #define Ch(x, y, z)  ((z) ^ ((x) & ((y) ^ (z))))
00084 
00085 #define Maj(x, y, z) (((x) & (y)) | ((z) & ((x) ^ (y))))
00086 
00087 #define Rotr(x, n, nbits) (((x) >> (n)) | ((x) << ((nbits)-(n))))
00088 
00089 #define Shr(x, n) ((x) >> (n))
00090 
00091 #define wv(i) v##i
00092 
00093 #define Sigma0_256(x) (Rotr((x),  2, 32) ^ Rotr((x), 13, 32) ^ Rotr((x), 22, 32))
00094 #define Sigma1_256(x) (Rotr((x),  6, 32) ^ Rotr((x), 11, 32) ^ Rotr((x), 25, 32))
00095 #define sigma0_256(x) (Rotr((x),  7, 32) ^ Rotr((x), 18, 32) ^  Shr((x),  3))
00096 #define sigma1_256(x) (Rotr((x), 17, 32) ^ Rotr((x), 19, 32) ^  Shr((x), 10))
00097 
00098 //----------------------------------------------------------------------
00099 // Implementation specifics for 32-bit words
00100 //----------------------------------------------------------------------
00101 
00102 static const uint32_t k256[64] = {
00103   0x428a2f98ul, 0x71374491ul, 0xb5c0fbcful, 0xe9b5dba5ul, 0x3956c25bul, 0x59f111f1ul, 0x923f82a4ul, 0xab1c5ed5ul,
00104   0xd807aa98ul, 0x12835b01ul, 0x243185beul, 0x550c7dc3ul, 0x72be5d74ul, 0x80deb1feul, 0x9bdc06a7ul, 0xc19bf174ul,
00105   0xe49b69c1ul, 0xefbe4786ul, 0x0fc19dc6ul, 0x240ca1ccul, 0x2de92c6ful, 0x4a7484aaul, 0x5cb0a9dcul, 0x76f988daul,
00106   0x983e5152ul, 0xa831c66dul, 0xb00327c8ul, 0xbf597fc7ul, 0xc6e00bf3ul, 0xd5a79147ul, 0x06ca6351ul, 0x14292967ul,
00107   0x27b70a85ul, 0x2e1b2138ul, 0x4d2c6dfcul, 0x53380d13ul, 0x650a7354ul, 0x766a0abbul, 0x81c2c92eul, 0x92722c85ul,
00108   0xa2bfe8a1ul, 0xa81a664bul, 0xc24b8b70ul, 0xc76c51a3ul, 0xd192e819ul, 0xd6990624ul, 0xf40e3585ul, 0x106aa070ul,
00109   0x19a4c116ul, 0x1e376c08ul, 0x2748774cul, 0x34b0bcb5ul, 0x391c0cb3ul, 0x4ed8aa4aul, 0x5b9cca4ful, 0x682e6ff3ul,
00110   0x748f82eeul, 0x78a5636ful, 0x84c87814ul, 0x8cc70208ul, 0x90befffaul, 0xa4506cebul, 0xbef9a3f7ul, 0xc67178f2ul
00111 };
00112 
00113 #define round_0_15(a, b, c, d, e, f, g, h, K, W, t)                     \
00114   T1 = wv(h) + Sigma1_256(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \
00115   T2 = Sigma0_256(wv(a)) + Maj(wv(a), wv(b), wv(c));                    \
00116   wv(d) += T1;                                                          \
00117   wv(h) = T1 + T2;
00118 
00119 #define round_16_63(a, b, c, d, e, f, g, h, K, W, t)                    \
00120   W[(t)&15] += sigma1_256(W[(t+14)&15]) + W[(t+9)&15] + sigma0_256(W[(t+1)&15]); \
00121   T1 = wv(h) + Sigma1_256(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \
00122   T2 = Sigma0_256(wv(a)) + Maj(wv(a), wv(b), wv(c));                    \
00123   wv(d) += T1;                                                          \
00124   wv(h) = T1 + T2;
00125 
00126 TEMPLATEM
00127 void CLASSM::processBuffer()
00128 {
00129   T v0 = m_digest[0];
00130   T v1 = m_digest[1];
00131   T v2 = m_digest[2];
00132   T v3 = m_digest[3];
00133   T v4 = m_digest[4];
00134   T v5 = m_digest[5];
00135   T v6 = m_digest[6];
00136   T v7 = m_digest[7];
00137 
00138   T w[16] = {
00139     bswaparr(m_buffer, T,  0), bswaparr(m_buffer, T,  1),
00140     bswaparr(m_buffer, T,  2), bswaparr(m_buffer, T,  3),
00141     bswaparr(m_buffer, T,  4), bswaparr(m_buffer, T,  5),
00142     bswaparr(m_buffer, T,  6), bswaparr(m_buffer, T,  7),
00143     bswaparr(m_buffer, T,  8), bswaparr(m_buffer, T,  9),
00144     bswaparr(m_buffer, T, 10), bswaparr(m_buffer, T, 11),
00145     bswaparr(m_buffer, T, 12), bswaparr(m_buffer, T, 13),
00146     bswaparr(m_buffer, T, 14), bswaparr(m_buffer, T, 15)
00147   };
00148   T T1, T2;
00149 
00150   round_0_15(0,1,2,3,4,5,6,7, k256, w,  0);
00151   round_0_15(7,0,1,2,3,4,5,6, k256, w,  1);
00152   round_0_15(6,7,0,1,2,3,4,5, k256, w,  2);
00153   round_0_15(5,6,7,0,1,2,3,4, k256, w,  3);
00154   round_0_15(4,5,6,7,0,1,2,3, k256, w,  4);
00155   round_0_15(3,4,5,6,7,0,1,2, k256, w,  5);
00156   round_0_15(2,3,4,5,6,7,0,1, k256, w,  6);
00157   round_0_15(1,2,3,4,5,6,7,0, k256, w,  7);
00158 
00159   round_0_15(0,1,2,3,4,5,6,7, k256, w,  8);
00160   round_0_15(7,0,1,2,3,4,5,6, k256, w,  9);
00161   round_0_15(6,7,0,1,2,3,4,5, k256, w, 10);
00162   round_0_15(5,6,7,0,1,2,3,4, k256, w, 11);
00163   round_0_15(4,5,6,7,0,1,2,3, k256, w, 12);
00164   round_0_15(3,4,5,6,7,0,1,2, k256, w, 13);
00165   round_0_15(2,3,4,5,6,7,0,1, k256, w, 14);
00166   round_0_15(1,2,3,4,5,6,7,0, k256, w, 15);
00167 
00168   round_16_63(0,1,2,3,4,5,6,7, k256, w, 16);
00169   round_16_63(7,0,1,2,3,4,5,6, k256, w, 17);
00170   round_16_63(6,7,0,1,2,3,4,5, k256, w, 18);
00171   round_16_63(5,6,7,0,1,2,3,4, k256, w, 19);
00172   round_16_63(4,5,6,7,0,1,2,3, k256, w, 20);
00173   round_16_63(3,4,5,6,7,0,1,2, k256, w, 21);
00174   round_16_63(2,3,4,5,6,7,0,1, k256, w, 22);
00175   round_16_63(1,2,3,4,5,6,7,0, k256, w, 23);
00176 
00177   round_16_63(0,1,2,3,4,5,6,7, k256, w, 24);
00178   round_16_63(7,0,1,2,3,4,5,6, k256, w, 25);
00179   round_16_63(6,7,0,1,2,3,4,5, k256, w, 26);
00180   round_16_63(5,6,7,0,1,2,3,4, k256, w, 27);
00181   round_16_63(4,5,6,7,0,1,2,3, k256, w, 28);
00182   round_16_63(3,4,5,6,7,0,1,2, k256, w, 29);
00183   round_16_63(2,3,4,5,6,7,0,1, k256, w, 30);
00184   round_16_63(1,2,3,4,5,6,7,0, k256, w, 31);
00185 
00186   round_16_63(0,1,2,3,4,5,6,7, k256, w, 32);
00187   round_16_63(7,0,1,2,3,4,5,6, k256, w, 33);
00188   round_16_63(6,7,0,1,2,3,4,5, k256, w, 34);
00189   round_16_63(5,6,7,0,1,2,3,4, k256, w, 35);
00190   round_16_63(4,5,6,7,0,1,2,3, k256, w, 36);
00191   round_16_63(3,4,5,6,7,0,1,2, k256, w, 37);
00192   round_16_63(2,3,4,5,6,7,0,1, k256, w, 38);
00193   round_16_63(1,2,3,4,5,6,7,0, k256, w, 39);
00194 
00195   round_16_63(0,1,2,3,4,5,6,7, k256, w, 40);
00196   round_16_63(7,0,1,2,3,4,5,6, k256, w, 41);
00197   round_16_63(6,7,0,1,2,3,4,5, k256, w, 42);
00198   round_16_63(5,6,7,0,1,2,3,4, k256, w, 43);
00199   round_16_63(4,5,6,7,0,1,2,3, k256, w, 44);
00200   round_16_63(3,4,5,6,7,0,1,2, k256, w, 45);
00201   round_16_63(2,3,4,5,6,7,0,1, k256, w, 46);
00202   round_16_63(1,2,3,4,5,6,7,0, k256, w, 47);
00203 
00204   round_16_63(0,1,2,3,4,5,6,7, k256, w, 48);
00205   round_16_63(7,0,1,2,3,4,5,6, k256, w, 49);
00206   round_16_63(6,7,0,1,2,3,4,5, k256, w, 50);
00207   round_16_63(5,6,7,0,1,2,3,4, k256, w, 51);
00208   round_16_63(4,5,6,7,0,1,2,3, k256, w, 52);
00209   round_16_63(3,4,5,6,7,0,1,2, k256, w, 53);
00210   round_16_63(2,3,4,5,6,7,0,1, k256, w, 54);
00211   round_16_63(1,2,3,4,5,6,7,0, k256, w, 55);
00212 
00213   round_16_63(0,1,2,3,4,5,6,7, k256, w, 56);
00214   round_16_63(7,0,1,2,3,4,5,6, k256, w, 57);
00215   round_16_63(6,7,0,1,2,3,4,5, k256, w, 58);
00216   round_16_63(5,6,7,0,1,2,3,4, k256, w, 59);
00217   round_16_63(4,5,6,7,0,1,2,3, k256, w, 60);
00218   round_16_63(3,4,5,6,7,0,1,2, k256, w, 61);
00219   round_16_63(2,3,4,5,6,7,0,1, k256, w, 62);
00220   round_16_63(1,2,3,4,5,6,7,0, k256, w, 63);
00221 
00222   m_digest[0] += v0;
00223   m_digest[1] += v1;
00224   m_digest[2] += v2;
00225   m_digest[3] += v3;
00226   m_digest[4] += v4;
00227   m_digest[5] += v5;
00228   m_digest[6] += v6;
00229   m_digest[7] += v7;
00230 }
00231 
00232 #undef TEMPLATEM
00233 #undef CLASSM
00234 
00235 #undef round_0_15
00236 #undef round_16_63
00237 
00238 //----------------------------------------------------------------------
00239 // Implementation specifics for 64-bit words
00240 //----------------------------------------------------------------------
00241 
00242 static const uint64_t k512[80] = {
00243   0x428a2f98d728ae22ull, 0x7137449123ef65cdull, 0xb5c0fbcfec4d3b2full, 0xe9b5dba58189dbbcull,
00244   0x3956c25bf348b538ull, 0x59f111f1b605d019ull, 0x923f82a4af194f9bull, 0xab1c5ed5da6d8118ull,
00245   0xd807aa98a3030242ull, 0x12835b0145706fbeull, 0x243185be4ee4b28cull, 0x550c7dc3d5ffb4e2ull,
00246   0x72be5d74f27b896full, 0x80deb1fe3b1696b1ull, 0x9bdc06a725c71235ull, 0xc19bf174cf692694ull,
00247   0xe49b69c19ef14ad2ull, 0xefbe4786384f25e3ull, 0x0fc19dc68b8cd5b5ull, 0x240ca1cc77ac9c65ull,
00248   0x2de92c6f592b0275ull, 0x4a7484aa6ea6e483ull, 0x5cb0a9dcbd41fbd4ull, 0x76f988da831153b5ull,
00249   0x983e5152ee66dfabull, 0xa831c66d2db43210ull, 0xb00327c898fb213full, 0xbf597fc7beef0ee4ull,
00250   0xc6e00bf33da88fc2ull, 0xd5a79147930aa725ull, 0x06ca6351e003826full, 0x142929670a0e6e70ull,
00251   0x27b70a8546d22ffcull, 0x2e1b21385c26c926ull, 0x4d2c6dfc5ac42aedull, 0x53380d139d95b3dfull,
00252   0x650a73548baf63deull, 0x766a0abb3c77b2a8ull, 0x81c2c92e47edaee6ull, 0x92722c851482353bull,
00253   0xa2bfe8a14cf10364ull, 0xa81a664bbc423001ull, 0xc24b8b70d0f89791ull, 0xc76c51a30654be30ull,
00254   0xd192e819d6ef5218ull, 0xd69906245565a910ull, 0xf40e35855771202aull, 0x106aa07032bbd1b8ull,
00255   0x19a4c116b8d2d0c8ull, 0x1e376c085141ab53ull, 0x2748774cdf8eeb99ull, 0x34b0bcb5e19b48a8ull,
00256   0x391c0cb3c5c95a63ull, 0x4ed8aa4ae3418acbull, 0x5b9cca4f7763e373ull, 0x682e6ff3d6b2b8a3ull,
00257   0x748f82ee5defb2fcull, 0x78a5636f43172f60ull, 0x84c87814a1f0ab72ull, 0x8cc702081a6439ecull,
00258   0x90befffa23631e28ull, 0xa4506cebde82bde9ull, 0xbef9a3f7b2c67915ull, 0xc67178f2e372532bull,
00259   0xca273eceea26619cull, 0xd186b8c721c0c207ull, 0xeada7dd6cde0eb1eull, 0xf57d4f7fee6ed178ull,
00260   0x06f067aa72176fbaull, 0x0a637dc5a2c898a6ull, 0x113f9804bef90daeull, 0x1b710b35131c471bull,
00261   0x28db77f523047d84ull, 0x32caab7b40c72493ull, 0x3c9ebe0a15c9bebcull, 0x431d67c49c100d4cull,
00262   0x4cc5d4becb3e42b6ull, 0x597f299cfc657e2aull, 0x5fcb6fab3ad6faecull, 0x6c44198c4a475817ull
00263 };
00264 
00265 #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>
00266 #define CLASSM Sha2Impl<uint64_t, t_h0, t_h1, t_h2, t_h3, t_h4, t_h5, t_h6, t_h7, t_len>
00267 
00268 #define Sigma0_512(x) (Rotr((x), 28, 64) ^ Rotr((x), 34, 64) ^ Rotr((x), 39, 64))
00269 #define Sigma1_512(x) (Rotr((x), 14, 64) ^ Rotr((x), 18, 64) ^ Rotr((x), 41, 64))
00270 #define sigma0_512(x) (Rotr((x),  1, 64) ^ Rotr((x),  8, 64) ^  Shr((x),  7))
00271 #define sigma1_512(x) (Rotr((x), 19, 64) ^ Rotr((x), 61, 64) ^  Shr((x),  6))
00272 
00273 TEMPLATEM
00274 CLASSM::Sha2Impl()
00275 {
00276   clear();
00277 }
00278 
00279 TEMPLATEM
00280 void CLASSM::clear()
00281 {
00282   m_message_size = 0;
00283   m_buffer_fill = 0;
00284   m_digest[0] = t_h0;
00285   m_digest[1] = t_h1;
00286   m_digest[2] = t_h2;
00287   m_digest[3] = t_h3;
00288   m_digest[4] = t_h4;
00289   m_digest[5] = t_h5;
00290   m_digest[6] = t_h6;
00291   m_digest[7] = t_h7;
00292 }
00293 
00294 TEMPLATEM
00295 ::icl_core::String CLASSM::getHexDigest() const
00296 {
00297   std::stringstream ss;
00298   for (size_t i = 0; i < t_len; ++i)
00299   {
00300     ss << std::hex << std::setw(16) << std::setfill('0') << m_digest[i];
00301   }
00302   return ss.str();
00303 }
00304 
00305 #define round_0_15(a, b, c, d, e, f, g, h, K, W, t)                     \
00306   T1 = wv(h) + Sigma1_512(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \
00307   T2 = Sigma0_512(wv(a)) + Maj(wv(a), wv(b), wv(c));                    \
00308   wv(d) += T1;                                                          \
00309   wv(h) = T1 + T2;
00310 
00311 #define round_16_79(a, b, c, d, e, f, g, h, K, W, t)                    \
00312   W[(t)&15] += sigma1_512(W[(t+14)&15]) + W[(t+9)&15] + sigma0_512(W[(t+1)&15]); \
00313   T1 = wv(h) + Sigma1_512(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \
00314   T2 = Sigma0_512(wv(a)) + Maj(wv(a), wv(b), wv(c));                    \
00315   wv(d) += T1;                                                          \
00316   wv(h) = T1 + T2;
00317 
00318 TEMPLATEM
00319 void CLASSM::processBuffer()
00320 {
00321   uint64_t v0 = m_digest[0];
00322   uint64_t v1 = m_digest[1];
00323   uint64_t v2 = m_digest[2];
00324   uint64_t v3 = m_digest[3];
00325   uint64_t v4 = m_digest[4];
00326   uint64_t v5 = m_digest[5];
00327   uint64_t v6 = m_digest[6];
00328   uint64_t v7 = m_digest[7];
00329 
00330   uint64_t w[16] = {
00331     bswaparr64(m_buffer, uint64_t,  0), bswaparr64(m_buffer, uint64_t,  1),
00332     bswaparr64(m_buffer, uint64_t,  2), bswaparr64(m_buffer, uint64_t,  3),
00333     bswaparr64(m_buffer, uint64_t,  4), bswaparr64(m_buffer, uint64_t,  5),
00334     bswaparr64(m_buffer, uint64_t,  6), bswaparr64(m_buffer, uint64_t,  7),
00335     bswaparr64(m_buffer, uint64_t,  8), bswaparr64(m_buffer, uint64_t,  9),
00336     bswaparr64(m_buffer, uint64_t, 10), bswaparr64(m_buffer, uint64_t, 11),
00337     bswaparr64(m_buffer, uint64_t, 12), bswaparr64(m_buffer, uint64_t, 13),
00338     bswaparr64(m_buffer, uint64_t, 14), bswaparr64(m_buffer, uint64_t, 15)
00339   };
00340   uint64_t T1, T2;
00341 
00342   round_0_15(0,1,2,3,4,5,6,7, k512, w,  0);
00343   round_0_15(7,0,1,2,3,4,5,6, k512, w,  1);
00344   round_0_15(6,7,0,1,2,3,4,5, k512, w,  2);
00345   round_0_15(5,6,7,0,1,2,3,4, k512, w,  3);
00346   round_0_15(4,5,6,7,0,1,2,3, k512, w,  4);
00347   round_0_15(3,4,5,6,7,0,1,2, k512, w,  5);
00348   round_0_15(2,3,4,5,6,7,0,1, k512, w,  6);
00349   round_0_15(1,2,3,4,5,6,7,0, k512, w,  7);
00350 
00351   round_0_15(0,1,2,3,4,5,6,7, k512, w,  8);
00352   round_0_15(7,0,1,2,3,4,5,6, k512, w,  9);
00353   round_0_15(6,7,0,1,2,3,4,5, k512, w, 10);
00354   round_0_15(5,6,7,0,1,2,3,4, k512, w, 11);
00355   round_0_15(4,5,6,7,0,1,2,3, k512, w, 12);
00356   round_0_15(3,4,5,6,7,0,1,2, k512, w, 13);
00357   round_0_15(2,3,4,5,6,7,0,1, k512, w, 14);
00358   round_0_15(1,2,3,4,5,6,7,0, k512, w, 15);
00359 
00360   round_16_79(0,1,2,3,4,5,6,7, k512, w, 16);
00361   round_16_79(7,0,1,2,3,4,5,6, k512, w, 17);
00362   round_16_79(6,7,0,1,2,3,4,5, k512, w, 18);
00363   round_16_79(5,6,7,0,1,2,3,4, k512, w, 19);
00364   round_16_79(4,5,6,7,0,1,2,3, k512, w, 20);
00365   round_16_79(3,4,5,6,7,0,1,2, k512, w, 21);
00366   round_16_79(2,3,4,5,6,7,0,1, k512, w, 22);
00367   round_16_79(1,2,3,4,5,6,7,0, k512, w, 23);
00368 
00369   round_16_79(0,1,2,3,4,5,6,7, k512, w, 24);
00370   round_16_79(7,0,1,2,3,4,5,6, k512, w, 25);
00371   round_16_79(6,7,0,1,2,3,4,5, k512, w, 26);
00372   round_16_79(5,6,7,0,1,2,3,4, k512, w, 27);
00373   round_16_79(4,5,6,7,0,1,2,3, k512, w, 28);
00374   round_16_79(3,4,5,6,7,0,1,2, k512, w, 29);
00375   round_16_79(2,3,4,5,6,7,0,1, k512, w, 30);
00376   round_16_79(1,2,3,4,5,6,7,0, k512, w, 31);
00377 
00378   round_16_79(0,1,2,3,4,5,6,7, k512, w, 32);
00379   round_16_79(7,0,1,2,3,4,5,6, k512, w, 33);
00380   round_16_79(6,7,0,1,2,3,4,5, k512, w, 34);
00381   round_16_79(5,6,7,0,1,2,3,4, k512, w, 35);
00382   round_16_79(4,5,6,7,0,1,2,3, k512, w, 36);
00383   round_16_79(3,4,5,6,7,0,1,2, k512, w, 37);
00384   round_16_79(2,3,4,5,6,7,0,1, k512, w, 38);
00385   round_16_79(1,2,3,4,5,6,7,0, k512, w, 39);
00386 
00387   round_16_79(0,1,2,3,4,5,6,7, k512, w, 40);
00388   round_16_79(7,0,1,2,3,4,5,6, k512, w, 41);
00389   round_16_79(6,7,0,1,2,3,4,5, k512, w, 42);
00390   round_16_79(5,6,7,0,1,2,3,4, k512, w, 43);
00391   round_16_79(4,5,6,7,0,1,2,3, k512, w, 44);
00392   round_16_79(3,4,5,6,7,0,1,2, k512, w, 45);
00393   round_16_79(2,3,4,5,6,7,0,1, k512, w, 46);
00394   round_16_79(1,2,3,4,5,6,7,0, k512, w, 47);
00395 
00396   round_16_79(0,1,2,3,4,5,6,7, k512, w, 48);
00397   round_16_79(7,0,1,2,3,4,5,6, k512, w, 49);
00398   round_16_79(6,7,0,1,2,3,4,5, k512, w, 50);
00399   round_16_79(5,6,7,0,1,2,3,4, k512, w, 51);
00400   round_16_79(4,5,6,7,0,1,2,3, k512, w, 52);
00401   round_16_79(3,4,5,6,7,0,1,2, k512, w, 53);
00402   round_16_79(2,3,4,5,6,7,0,1, k512, w, 54);
00403   round_16_79(1,2,3,4,5,6,7,0, k512, w, 55);
00404 
00405   round_16_79(0,1,2,3,4,5,6,7, k512, w, 56);
00406   round_16_79(7,0,1,2,3,4,5,6, k512, w, 57);
00407   round_16_79(6,7,0,1,2,3,4,5, k512, w, 58);
00408   round_16_79(5,6,7,0,1,2,3,4, k512, w, 59);
00409   round_16_79(4,5,6,7,0,1,2,3, k512, w, 60);
00410   round_16_79(3,4,5,6,7,0,1,2, k512, w, 61);
00411   round_16_79(2,3,4,5,6,7,0,1, k512, w, 62);
00412   round_16_79(1,2,3,4,5,6,7,0, k512, w, 63);
00413 
00414   round_16_79(0,1,2,3,4,5,6,7, k512, w, 64);
00415   round_16_79(7,0,1,2,3,4,5,6, k512, w, 65);
00416   round_16_79(6,7,0,1,2,3,4,5, k512, w, 66);
00417   round_16_79(5,6,7,0,1,2,3,4, k512, w, 67);
00418   round_16_79(4,5,6,7,0,1,2,3, k512, w, 68);
00419   round_16_79(3,4,5,6,7,0,1,2, k512, w, 69);
00420   round_16_79(2,3,4,5,6,7,0,1, k512, w, 70);
00421   round_16_79(1,2,3,4,5,6,7,0, k512, w, 71);
00422 
00423   round_16_79(0,1,2,3,4,5,6,7, k512, w, 72);
00424   round_16_79(7,0,1,2,3,4,5,6, k512, w, 73);
00425   round_16_79(6,7,0,1,2,3,4,5, k512, w, 74);
00426   round_16_79(5,6,7,0,1,2,3,4, k512, w, 75);
00427   round_16_79(4,5,6,7,0,1,2,3, k512, w, 76);
00428   round_16_79(3,4,5,6,7,0,1,2, k512, w, 77);
00429   round_16_79(2,3,4,5,6,7,0,1, k512, w, 78);
00430   round_16_79(1,2,3,4,5,6,7,0, k512, w, 79);
00431 
00432   m_digest[0] += v0;
00433   m_digest[1] += v1;
00434   m_digest[2] += v2;
00435   m_digest[3] += v3;
00436   m_digest[4] += v4;
00437   m_digest[5] += v5;
00438   m_digest[6] += v6;
00439   m_digest[7] += v7;
00440 }
00441 
00442 #undef TEMPLATEM
00443 #undef CLASSM
00444 
00445 #undef round_0_15
00446 #undef round_16_79
00447 #undef bswap
00448 #undef bswap64
00449 #undef Ch
00450 #undef Maj
00451 #undef Rotr
00452 #undef Shr
00453 #undef wv
00454 #undef Sigma0_256
00455 #undef Sigma1_256
00456 #undef sigma0_256
00457 #undef sigma1_256
00458 #undef Sigma0_512
00459 #undef Sigma1_512
00460 #undef sigma0_512
00461 #undef sigma1_512
00462 
00463 }
00464 }
00465 
00466 #endif


fzi_icl_core
Author(s):
autogenerated on Thu Jun 6 2019 20:22:24