aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authornlwkobe30 <nlwkobe30@gmail.com>2024-08-30 19:05:07 +0000
committerGopher Robot <gobot@golang.org>2024-09-03 20:55:15 +0000
commit7cd0a4be5cdbb84142ec330daba6087eece48341 (patch)
tree498439f59e7cf228c9427c540bccdc7c2930fe7c /src/crypto
parentb8e533a7cdc60d84a0c52bfaf3dcb5bf148ac3a8 (diff)
downloadgo-7cd0a4be5cdbb84142ec330daba6087eece48341.tar.xz
all: omit unnecessary 0 in slice expression
All changes are related to the code, except for the comments in src/regexp/syntax/parse.go and src/slices/slices.go. Change-Id: I73c5d3c54099749b62210aa7f3182c5eb84bb6a6 GitHub-Last-Rev: 794aa9b0539811d00e1cd42be1e8d9fe9afe0281 GitHub-Pull-Request: golang/go#69170 Reviewed-on: https://go-review.googlesource.com/c/go/+/609678 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/cipher/ctr_aes_test.go4
-rw-r--r--src/crypto/internal/cryptotest/aead.go8
-rw-r--r--src/crypto/internal/cryptotest/hash.go4
-rw-r--r--src/crypto/md5/md5_test.go2
-rw-r--r--src/crypto/sha1/sha1_test.go4
-rw-r--r--src/crypto/sha256/sha256_test.go4
-rw-r--r--src/crypto/subtle/constant_time_test.go8
7 files changed, 17 insertions, 17 deletions
diff --git a/src/crypto/cipher/ctr_aes_test.go b/src/crypto/cipher/ctr_aes_test.go
index d019ae0d02..c82a8757ab 100644
--- a/src/crypto/cipher/ctr_aes_test.go
+++ b/src/crypto/cipher/ctr_aes_test.go
@@ -80,7 +80,7 @@ func TestCTR_AES(t *testing.T) {
ctr := cipher.NewCTR(c, tt.iv)
encrypted := make([]byte, len(in))
ctr.XORKeyStream(encrypted, in)
- if out := tt.out[0:len(in)]; !bytes.Equal(out, encrypted) {
+ if out := tt.out[:len(in)]; !bytes.Equal(out, encrypted) {
t.Errorf("%s/%d: CTR\ninpt %x\nhave %x\nwant %x", test, len(in), in, encrypted, out)
}
}
@@ -90,7 +90,7 @@ func TestCTR_AES(t *testing.T) {
ctr := cipher.NewCTR(c, tt.iv)
plain := make([]byte, len(in))
ctr.XORKeyStream(plain, in)
- if out := tt.in[0:len(in)]; !bytes.Equal(out, plain) {
+ if out := tt.in[:len(in)]; !bytes.Equal(out, plain) {
t.Errorf("%s/%d: CTRReader\nhave %x\nwant %x", test, len(out), plain, out)
}
}
diff --git a/src/crypto/internal/cryptotest/aead.go b/src/crypto/internal/cryptotest/aead.go
index e17cdf8cb8..a6107e5419 100644
--- a/src/crypto/internal/cryptotest/aead.go
+++ b/src/crypto/internal/cryptotest/aead.go
@@ -204,8 +204,8 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
out := sealMsg(t, aead, prefix, nonce, plaintext, addData)
// Check that Seal didn't alter the prefix
- if !bytes.Equal(out[0:len(prefix)], prefix) {
- t.Errorf("Seal alters dst instead of appending; got %s, want %s", truncateHex(out[0:len(prefix)]), truncateHex(prefix))
+ if !bytes.Equal(out[:len(prefix)], prefix) {
+ t.Errorf("Seal alters dst instead of appending; got %s, want %s", truncateHex(out[:len(prefix)]), truncateHex(prefix))
}
ciphertext := out[len(prefix):]
@@ -237,8 +237,8 @@ func TestAEAD(t *testing.T, mAEAD MakeAEAD) {
out := openWithoutError(t, aead, prefix, nonce, ciphertext, addData)
// Check that Open didn't alter the prefix
- if !bytes.Equal(out[0:len(prefix)], prefix) {
- t.Errorf("Open alters dst instead of appending; got %s, want %s", truncateHex(out[0:len(prefix)]), truncateHex(prefix))
+ if !bytes.Equal(out[:len(prefix)], prefix) {
+ t.Errorf("Open alters dst instead of appending; got %s, want %s", truncateHex(out[:len(prefix)]), truncateHex(prefix))
}
after := out[len(prefix):]
diff --git a/src/crypto/internal/cryptotest/hash.go b/src/crypto/internal/cryptotest/hash.go
index a950dcb282..f03623dfa2 100644
--- a/src/crypto/internal/cryptotest/hash.go
+++ b/src/crypto/internal/cryptotest/hash.go
@@ -39,8 +39,8 @@ func TestHash(t *testing.T, mh MakeHash) {
sum := getSum(t, h, prefix) // Append new digest to prefix
// Check that Sum didn't alter the prefix
- if !bytes.Equal(sum[0:len(prefix)], prefix) {
- t.Errorf("Sum alters passed buffer instead of appending; got %x, want %x", sum[0:len(prefix)], prefix)
+ if !bytes.Equal(sum[:len(prefix)], prefix) {
+ t.Errorf("Sum alters passed buffer instead of appending; got %x, want %x", sum[:len(prefix)], prefix)
}
// Check that the appended sum wasn't affected by the prefix
diff --git a/src/crypto/md5/md5_test.go b/src/crypto/md5/md5_test.go
index c445b10832..6a8258a67e 100644
--- a/src/crypto/md5/md5_test.go
+++ b/src/crypto/md5/md5_test.go
@@ -69,7 +69,7 @@ func TestGolden(t *testing.T) {
if j < 2 {
io.WriteString(c, g.in)
} else if j == 2 {
- io.WriteString(c, g.in[0:len(g.in)/2])
+ io.WriteString(c, g.in[:len(g.in)/2])
c.Sum(nil)
io.WriteString(c, g.in[len(g.in)/2:])
} else if j > 2 {
diff --git a/src/crypto/sha1/sha1_test.go b/src/crypto/sha1/sha1_test.go
index 32b01d4dee..d03892c57d 100644
--- a/src/crypto/sha1/sha1_test.go
+++ b/src/crypto/sha1/sha1_test.go
@@ -74,7 +74,7 @@ func TestGolden(t *testing.T) {
io.WriteString(c, g.in)
sum = c.Sum(nil)
case 2:
- io.WriteString(c, g.in[0:len(g.in)/2])
+ io.WriteString(c, g.in[:len(g.in)/2])
c.Sum(nil)
io.WriteString(c, g.in[len(g.in)/2:])
sum = c.Sum(nil)
@@ -82,7 +82,7 @@ func TestGolden(t *testing.T) {
if boring.Enabled {
continue
}
- io.WriteString(c, g.in[0:len(g.in)/2])
+ io.WriteString(c, g.in[:len(g.in)/2])
c.(*digest).ConstantTimeSum(nil)
io.WriteString(c, g.in[len(g.in)/2:])
sum = c.(*digest).ConstantTimeSum(nil)
diff --git a/src/crypto/sha256/sha256_test.go b/src/crypto/sha256/sha256_test.go
index 92268f32da..3237c6a73e 100644
--- a/src/crypto/sha256/sha256_test.go
+++ b/src/crypto/sha256/sha256_test.go
@@ -104,7 +104,7 @@ func TestGolden(t *testing.T) {
if j < 2 {
io.WriteString(c, g.in)
} else {
- io.WriteString(c, g.in[0:len(g.in)/2])
+ io.WriteString(c, g.in[:len(g.in)/2])
c.Sum(nil)
io.WriteString(c, g.in[len(g.in)/2:])
}
@@ -126,7 +126,7 @@ func TestGolden(t *testing.T) {
if j < 2 {
io.WriteString(c, g.in)
} else {
- io.WriteString(c, g.in[0:len(g.in)/2])
+ io.WriteString(c, g.in[:len(g.in)/2])
c.Sum(nil)
io.WriteString(c, g.in[len(g.in)/2:])
}
diff --git a/src/crypto/subtle/constant_time_test.go b/src/crypto/subtle/constant_time_test.go
index 033301a6e4..c2ccd28ad7 100644
--- a/src/crypto/subtle/constant_time_test.go
+++ b/src/crypto/subtle/constant_time_test.go
@@ -78,9 +78,9 @@ func TestConstantTimeEq(t *testing.T) {
func makeCopy(v int, x, y []byte) []byte {
if len(x) > len(y) {
- x = x[0:len(y)]
+ x = x[:len(y)]
} else {
- y = y[0:len(x)]
+ y = y[:len(x)]
}
if v == 1 {
copy(x, y)
@@ -90,9 +90,9 @@ func makeCopy(v int, x, y []byte) []byte {
func constantTimeCopyWrapper(v int, x, y []byte) []byte {
if len(x) > len(y) {
- x = x[0:len(y)]
+ x = x[:len(y)]
} else {
- y = y[0:len(x)]
+ y = y[:len(x)]
}
v &= 1
ConstantTimeCopy(v, x, y)