]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/sha1: use math/bits.RotateLeft32
authorAlexander Yastrebov <yastrebov.alex@gmail.com>
Mon, 24 Oct 2022 15:46:18 +0000 (15:46 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 6 Feb 2023 18:37:22 +0000 (18:37 +0000)
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 <filippo@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
src/crypto/sha1/sha1block.go

index 321d34351c1f5e92b42e52114af76c30b84f3f45..1c1a7c5f31c16413b949986f2793da1275669b5d 100644 (file)
@@ -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