From: Mikko Rasa Date: Sat, 16 Apr 2016 12:49:56 +0000 (+0300) Subject: Avoid shuffling the data around in memory so much X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5e5fd3c47ef3d8bfd29a31311e1d933c6138ed44;p=libs%2Fcrypto.git Avoid shuffling the data around in memory so much --- diff --git a/source/sha2.cpp b/source/sha2.cpp index 3823643..c0cb1a1 100644 --- a/source/sha2.cpp +++ b/source/sha2.cpp @@ -79,8 +79,8 @@ void SHA2::process_block(const char *data) for(unsigned i=16; i>sigma[11])); - WordType s0 = (rotate_right(block[-15], sigma[6]) ^ rotate_right(block[-15], sigma[7]) ^ (block[-15]>>sigma[8])); + WordType s1 = rotate_right(block[-2], sigma[9]) ^ rotate_right(block[-2], sigma[10]) ^ (block[-2]>>sigma[11]); + WordType s0 = rotate_right(block[-15], sigma[6]) ^ rotate_right(block[-15], sigma[7]) ^ (block[-15]>>sigma[8]); *block = s1+block[-7]+s0+block[-16]; } @@ -89,20 +89,24 @@ void SHA2::process_block(const char *data) for(unsigned i=0; i