10 #if defined(CRYPTOPP_DISABLE_TIGER_ASM) 11 # undef CRYPTOPP_X86_ASM_AVAILABLE 12 # undef CRYPTOPP_X32_ASM_AVAILABLE 13 # undef CRYPTOPP_X64_ASM_AVAILABLE 14 # undef CRYPTOPP_SSE2_ASM_AVAILABLE 19 void Tiger::InitState(HashWordType *state)
21 state[0] = W64LIT(0x0123456789ABCDEF);
22 state[1] = W64LIT(0xFEDCBA9876543210);
23 state[2] = W64LIT(0xF096A5B4C3B2E187);
28 ThrowIfInvalidTruncatedSize(size);
30 PadLastBlock(56, 0x01);
33 m_data[7] = GetBitCountLo();
35 Transform(m_state, m_data);
37 memcpy(hash, m_state, size);
42 void Tiger::Transform (word64 *digest,
const word64 *X)
44 #if CRYPTOPP_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) 53 AS2( lea edx, [table])
58 AS2( movq mm1, [eax+1*8])
60 AS2( movq mm2, [eax+2*8])
61 AS2( movq mm7, [edx+4*2048+0*8])
62 AS2( movq mm6, [edx+4*2048+1*8])
64 AS2( and esp, 0xfffffff0)
68 #define SSE2_round(a,b,c,x,mul) \
72 AS2( movq mm3, [edx+0*2048+edi*8])\
74 AS2( movq mm4, [edx+3*2048+edi*8])\
77 AS2( pxor mm3, [edx+1*2048+edi*8])\
79 AS2( pxor mm4, [edx+2*2048+edi*8])\
80 AS3( pextrw ecx, c, 2)\
82 AS2( pxor mm3, [edx+2*2048+edi*8])\
84 AS2( pxor mm4, [edx+1*2048+edi*8])\
85 AS3( pextrw ecx, c, 3)\
87 AS2( pxor mm3, [edx+3*2048+edi*8])\
90 AS2( pxor mm4, [edx+0*2048+edi*8])\
94 #define SSE2_mul_5(b) \
99 #define SSE2_mul_7(b) \
104 #define SSE2_mul_9(b) \
113 #define SSE2_pass(A,B,C,mul,X) \
116 SSE2_round(A,B,C,X+0*8+ebx,mul)\
117 SSE2_round(B,C,A,X+1*8+ebx,mul)\
119 ASJ( je, label2_##mul, f)\
120 SSE2_round(C,A,B,X+2*8+ebx,mul)\
125 #define SSE2_key_schedule(Y,X) \
126 AS2( movq mm3, [X+7*8])\
128 AS2( movq mm4, [X+0*8])\
129 AS2( psubq mm4, mm3)\
130 AS2( movq [Y+0*8], mm4)\
131 AS2( pxor mm4, [X+1*8])\
133 AS2( movq [Y+1*8], mm4)\
134 AS2( paddq mm4, [X+2*8])\
137 AS2( movq [Y+2*8], mm4)\
139 AS2( movq mm4, [X+3*8])\
140 AS2( psubq mm4, mm3)\
141 AS2( movq [Y+3*8], mm4)\
142 AS2( pxor mm4, [X+4*8])\
144 AS2( movq [Y+4*8], mm4)\
145 AS2( paddq mm4, [X+5*8])\
148 AS2( movq [Y+5*8], mm4)\
150 AS2( movq mm4, [X+6*8])\
151 AS2( psubq mm4, mm3)\
152 AS2( movq [Y+6*8], mm4)\
153 AS2( pxor mm4, [X+7*8])\
155 AS2( movq [Y+7*8], mm4)\
156 AS2( paddq mm4, [Y+0*8])\
159 AS2( movq [Y+0*8], mm4)\
161 AS2( movq mm4, [Y+1*8])\
162 AS2( psubq mm4, mm3)\
163 AS2( movq [Y+1*8], mm4)\
164 AS2( pxor mm4, [Y+2*8])\
166 AS2( movq [Y+2*8], mm4)\
167 AS2( paddq mm4, [Y+3*8])\
170 AS2( movq [Y+3*8], mm4)\
172 AS2( movq mm4, [Y+4*8])\
173 AS2( psubq mm4, mm3)\
174 AS2( movq [Y+4*8], mm4)\
175 AS2( pxor mm4, [Y+5*8])\
176 AS2( movq [Y+5*8], mm4)\
177 AS2( paddq mm4, [Y+6*8])\
178 AS2( movq [Y+6*8], mm4)\
179 AS2( pxor mm4, [edx+4*2048+2*8])\
180 AS2( movq mm3, [Y+7*8])\
181 AS2( psubq mm3, mm4)\
182 AS2( movq [Y+7*8], mm3)
184 #
if CRYPTOPP_BOOL_X32
185 SSE2_pass(mm0, mm1, mm2, 5, esi)
186 SSE2_key_schedule(esp+8, esi)
187 SSE2_pass(mm2, mm0, mm1, 7, esp+8)
188 SSE2_key_schedule(esp+8, esp+8)
189 SSE2_pass(mm1, mm2, mm0, 9, esp+8)
191 SSE2_pass(mm0, mm1, mm2, 5, esi)
192 SSE2_key_schedule(esp+4, esi)
193 SSE2_pass(mm2, mm0, mm1, 7, esp+4)
194 SSE2_key_schedule(esp+4, esp+4)
195 SSE2_pass(mm1, mm2, mm0, 9, esp+4)
198 AS2( pxor mm0, [eax+0*8])
199 AS2( movq [eax+0*8], mm0)
201 AS2( movq [eax+1*8], mm1)
202 AS2( paddq mm2, [eax+2*8])
203 AS2( movq [eax+2*8], mm2)
212 :
"a" (digest),
"S" (X),
"d" (table)
213 :
"%ecx",
"%edi",
"memory",
"cc" 220 word64 a = digest[0];
221 word64 b = digest[1];
222 word64 c = digest[2];
226 #define t2 (table+256) 227 #define t3 (table+256*2) 228 #define t4 (table+256*3) 230 #define round(a,b,c,x,mul) \ 232 a -= t1[GETBYTE(c,0)] ^ t2[GETBYTE(c,2)] ^ t3[GETBYTE(c,4)] ^ t4[GETBYTE(c,6)]; \ 233 b += t4[GETBYTE(c,1)] ^ t3[GETBYTE(c,3)] ^ t2[GETBYTE(c,5)] ^ t1[GETBYTE(c,7)]; \ 236 #define pass(a,b,c,mul,X) {\ 240 round(a,b,c,X[i+0],mul); \ 241 round(b,c,a,X[i+1],mul); \ 244 round(c,a,b,X[i+2],mul); \ 248 #define key_schedule(Y,X) \ 249 Y[0] = X[0] - (X[7]^W64LIT(0xA5A5A5A5A5A5A5A5)); \ 250 Y[1] = X[1] ^ Y[0]; \ 251 Y[2] = X[2] + Y[1]; \ 252 Y[3] = X[3] - (Y[2] ^ ((~Y[1])<<19)); \ 253 Y[4] = X[4] ^ Y[3]; \ 254 Y[5] = X[5] + Y[4]; \ 255 Y[6] = X[6] - (Y[5] ^ ((~Y[4])>>23)); \ 256 Y[7] = X[7] ^ Y[6]; \ 258 Y[1] -= Y[0] ^ ((~Y[7])<<19); \ 261 Y[4] -= Y[3] ^ ((~Y[2])>>23); \ 264 Y[7] -= Y[6] ^ W64LIT(0x0123456789ABCDEF) 272 digest[0] = a ^ digest[0];
273 digest[1] = b - digest[1];
274 digest[2] = c + digest[2];
Utility functions for the Crypto++ library.
Library configuration file.
Classes for the Tiger message digest.
void CorrectEndianess(HashWordType *out, const HashWordType *in, size_t byteCount)
Adjusts the byte ordering of the hash.
Functions for CPU features and intrinsics.
void Restart()
Restart the hash.
bool HasSSE2()
Determines SSE2 availability.
Crypto++ library namespace.
void TruncatedFinal(byte *hash, size_t size)
Computes the hash of the current message.