From 5e5fd3c47ef3d8bfd29a31311e1d933c6138ed44 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 16 Apr 2016 15:49:56 +0300 Subject: [PATCH 1/1] Avoid shuffling the data around in memory so much --- source/sha2.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) 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