@@ -265,7 +265,22 @@ static int s_sha256_compress(hash_state * md, const unsigned char *buf)
265265 @param inlen The length of the data (octets)
266266 @return CRYPT_OK if successful
267267*/
268- HASH_PROCESS (sha256_x86_process ,s_sha256_x86_compress , sha256 , 64 )
268+ static HASH_PROCESS (s_sha256_x86_process ,s_sha256_x86_compress , sha256 , 64 )
269+
270+ static LTC_INLINE void s_sha256_x86_fixup_state (hash_state * md )
271+ {
272+ ulong32 * state = LTC_ALIGN_BUF (md -> sha256 .state_buf , 16 );
273+ if (state != md -> sha256 .state ) {
274+ XMEMMOVE (state , md -> sha256 .state , 8 * sizeof (ulong32 ));
275+ md -> sha256 .state = state ;
276+ }
277+ }
278+
279+ int sha256_x86_process (hash_state * md , const unsigned char * in , unsigned long inlen )
280+ {
281+ s_sha256_x86_fixup_state (md );
282+ return s_sha256_x86_process (md , in , inlen );
283+ }
269284
270285/**
271286 Terminate the hash to get the digest
@@ -284,6 +299,7 @@ int sha256_x86_done(hash_state * md, unsigned char *out)
284299 return CRYPT_INVALID_ARG ;
285300 }
286301
302+ s_sha256_x86_fixup_state (md );
287303
288304 /* increase the length of the message */
289305 md -> sha256 .length += md -> sha256 .curlen * 8 ;
0 commit comments