From 8eb76ff32ae54ffeb6e3631f5d3584a372e59582 Mon Sep 17 00:00:00 2001 From: Sergey Ulanov Date: Wed, 20 May 2015 11:25:37 -0700 Subject: [PATCH] Make SHA1 computation thread-safe. Previously SHA1Transform() kept a static buffer. As result SHA1 was not always computed correctly when running that code in parallel on multiple threads. That was causing spurious messages about invalid Message Integrity attribute when running some tests in chromoting. R=pthatcher@webrtc.org Review URL: https://webrtc-codereview.appspot.com/57379004 Cr-Commit-Position: refs/heads/master@{#9238} --- webrtc/base/sha1.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webrtc/base/sha1.cc b/webrtc/base/sha1.cc index 68530540de..0e4759793b 100644 --- a/webrtc/base/sha1.cc +++ b/webrtc/base/sha1.cc @@ -91,6 +91,11 @@ * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 * A million repetitions of "a" * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F + * + * ----------------- + * Modified 05/2015 + * By Sergey Ulanov + * Removed static buffer to make computation thread-safe. */ // Enabling SHA1HANDSOFF preserves the caller's data buffer. @@ -157,7 +162,7 @@ void SHA1Transform(uint32 state[5], const uint8 buffer[64]) { uint32 l[16]; }; #ifdef SHA1HANDSOFF - static uint8 workspace[64]; + uint8 workspace[64]; memcpy(workspace, buffer, 64); CHAR64LONG16* block = reinterpret_cast(workspace); #else