From 677038f86625447de738831b4be9bca23929787a Mon Sep 17 00:00:00 2001 From: Alexander Yastrebov Date: Mon, 24 Oct 2022 15:46:18 +0000 Subject: [PATCH] crypto/sha1: use math/bits.RotateLeft32 Updates #31456 Change-Id: I68e0abfb6771c9b1d1bfcbb642db9eb5540f9cab GitHub-Last-Rev: 17ea697c5c0bbfdfb1ad91c2c60e22f6efc78b43 GitHub-Pull-Request: golang/go#49051 Reviewed-on: https://go-review.googlesource.com/c/go/+/356516 Auto-Submit: Filippo Valsorda Reviewed-by: Heschi Kreinick Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot Run-TryBot: Filippo Valsorda Reviewed-by: Filippo Valsorda --- src/crypto/sha1/sha1block.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crypto/sha1/sha1block.go b/src/crypto/sha1/sha1block.go index 321d34351c..1c1a7c5f31 100644 --- a/src/crypto/sha1/sha1block.go +++ b/src/crypto/sha1/sha1block.go @@ -42,7 +42,7 @@ func blockGeneric(dig *digest, p []byte) { } for ; i < 20; i++ { tmp := w[(i-3)&0xf] ^ w[(i-8)&0xf] ^ w[(i-14)&0xf] ^ w[(i)&0xf] - w[i&0xf] = tmp<<1 | tmp>>(32-1) + w[i&0xf] = bits.RotateLeft32(tmp, 1) f := b&c | (^b)&d t := bits.RotateLeft32(a, 5) + f + e + w[i&0xf] + _K0 @@ -50,21 +50,21 @@ func blockGeneric(dig *digest, p []byte) { } for ; i < 40; i++ { tmp := w[(i-3)&0xf] ^ w[(i-8)&0xf] ^ w[(i-14)&0xf] ^ w[(i)&0xf] - w[i&0xf] = tmp<<1 | tmp>>(32-1) + w[i&0xf] = bits.RotateLeft32(tmp, 1) f := b ^ c ^ d t := bits.RotateLeft32(a, 5) + f + e + w[i&0xf] + _K1 a, b, c, d, e = t, a, bits.RotateLeft32(b, 30), c, d } for ; i < 60; i++ { tmp := w[(i-3)&0xf] ^ w[(i-8)&0xf] ^ w[(i-14)&0xf] ^ w[(i)&0xf] - w[i&0xf] = tmp<<1 | tmp>>(32-1) + w[i&0xf] = bits.RotateLeft32(tmp, 1) f := ((b | c) & d) | (b & c) t := bits.RotateLeft32(a, 5) + f + e + w[i&0xf] + _K2 a, b, c, d, e = t, a, bits.RotateLeft32(b, 30), c, d } for ; i < 80; i++ { tmp := w[(i-3)&0xf] ^ w[(i-8)&0xf] ^ w[(i-14)&0xf] ^ w[(i)&0xf] - w[i&0xf] = tmp<<1 | tmp>>(32-1) + w[i&0xf] = bits.RotateLeft32(tmp, 1) f := b ^ c ^ d t := bits.RotateLeft32(a, 5) + f + e + w[i&0xf] + _K3 a, b, c, d, e = t, a, bits.RotateLeft32(b, 30), c, d -- 2.50.0