Skip to content

Commit 90466e1

Browse files
rscgopherbot
authored andcommitted
crypto/internal/subtle: rename to crypto/internal/alias
This avoids an import conflict with crypto/subtle. CL 424175 does the same for x/crypto. Change-Id: Id4a319b3283b8affaaf769062388325b31fe1715 Reviewed-on: https://go-review.googlesource.com/c/go/+/424194 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Auto-Submit: Russ Cox <[email protected]>
1 parent ebda5a7 commit 90466e1

19 files changed

+51
-95
lines changed

src/crypto/aes/aes_gcm.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package aes
88

99
import (
1010
"crypto/cipher"
11-
subtleoverlap "crypto/internal/subtle"
11+
"crypto/internal/alias"
1212
"crypto/subtle"
1313
"errors"
1414
)
@@ -114,7 +114,7 @@ func (g *gcmAsm) Seal(dst, nonce, plaintext, data []byte) []byte {
114114
gcmAesData(&g.productTable, data, &tagOut)
115115

116116
ret, out := sliceForAppend(dst, len(plaintext)+g.tagSize)
117-
if subtleoverlap.InexactOverlap(out[:len(plaintext)], plaintext) {
117+
if alias.InexactOverlap(out[:len(plaintext)], plaintext) {
118118
panic("crypto/cipher: invalid buffer overlap")
119119
}
120120
if len(plaintext) > 0 {
@@ -167,7 +167,7 @@ func (g *gcmAsm) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) {
167167
gcmAesData(&g.productTable, data, &expectedTag)
168168

169169
ret, out := sliceForAppend(dst, len(ciphertext))
170-
if subtleoverlap.InexactOverlap(out, ciphertext) {
170+
if alias.InexactOverlap(out, ciphertext) {
171171
panic("crypto/cipher: invalid buffer overlap")
172172
}
173173
if len(ciphertext) > 0 {

src/crypto/aes/cbc_ppc64x.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package aes
88

99
import (
1010
"crypto/cipher"
11-
"crypto/internal/subtle"
11+
"crypto/internal/alias"
1212
)
1313

1414
// Assert that aesCipherAsm implements the cbcEncAble and cbcDecAble interfaces.
@@ -54,7 +54,7 @@ func (x *cbc) CryptBlocks(dst, src []byte) {
5454
if len(dst) < len(src) {
5555
panic("crypto/cipher: output smaller than input")
5656
}
57-
if subtle.InexactOverlap(dst[:len(src)], src) {
57+
if alias.InexactOverlap(dst[:len(src)], src) {
5858
panic("crypto/cipher: invalid buffer overlap")
5959
}
6060
if len(src) > 0 {

src/crypto/aes/cbc_s390x.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package aes
66

77
import (
88
"crypto/cipher"
9-
"crypto/internal/subtle"
9+
"crypto/internal/alias"
1010
)
1111

1212
// Assert that aesCipherAsm implements the cbcEncAble and cbcDecAble interfaces.
@@ -50,7 +50,7 @@ func (x *cbc) CryptBlocks(dst, src []byte) {
5050
if len(dst) < len(src) {
5151
panic("crypto/cipher: output smaller than input")
5252
}
53-
if subtle.InexactOverlap(dst[:len(src)], src) {
53+
if alias.InexactOverlap(dst[:len(src)], src) {
5454
panic("crypto/cipher: invalid buffer overlap")
5555
}
5656
if len(src) > 0 {

src/crypto/aes/cipher.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ package aes
66

77
import (
88
"crypto/cipher"
9+
"crypto/internal/alias"
910
"crypto/internal/boring"
10-
"crypto/internal/subtle"
1111
"strconv"
1212
)
1313

@@ -62,7 +62,7 @@ func (c *aesCipher) Encrypt(dst, src []byte) {
6262
if len(dst) < BlockSize {
6363
panic("crypto/aes: output not full block")
6464
}
65-
if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
65+
if alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
6666
panic("crypto/aes: invalid buffer overlap")
6767
}
6868
encryptBlockGo(c.enc, dst, src)
@@ -75,7 +75,7 @@ func (c *aesCipher) Decrypt(dst, src []byte) {
7575
if len(dst) < BlockSize {
7676
panic("crypto/aes: output not full block")
7777
}
78-
if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
78+
if alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
7979
panic("crypto/aes: invalid buffer overlap")
8080
}
8181
decryptBlockGo(c.dec, dst, src)

src/crypto/aes/cipher_asm.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ package aes
88

99
import (
1010
"crypto/cipher"
11+
"crypto/internal/alias"
1112
"crypto/internal/boring"
12-
"crypto/internal/subtle"
1313
"internal/cpu"
1414
"internal/goarch"
1515
)
@@ -75,7 +75,7 @@ func (c *aesCipherAsm) Encrypt(dst, src []byte) {
7575
if len(dst) < BlockSize {
7676
panic("crypto/aes: output not full block")
7777
}
78-
if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
78+
if alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
7979
panic("crypto/aes: invalid buffer overlap")
8080
}
8181
encryptBlockAsm(len(c.enc)/4-1, &c.enc[0], &dst[0], &src[0])
@@ -89,7 +89,7 @@ func (c *aesCipherAsm) Decrypt(dst, src []byte) {
8989
if len(dst) < BlockSize {
9090
panic("crypto/aes: output not full block")
9191
}
92-
if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
92+
if alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
9393
panic("crypto/aes: invalid buffer overlap")
9494
}
9595
decryptBlockAsm(len(c.dec)/4-1, &c.dec[0], &dst[0], &src[0])

src/crypto/aes/cipher_s390x.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package aes
66

77
import (
88
"crypto/cipher"
9-
"crypto/internal/subtle"
9+
"crypto/internal/alias"
1010
"internal/cpu"
1111
)
1212

@@ -69,7 +69,7 @@ func (c *aesCipherAsm) Encrypt(dst, src []byte) {
6969
if len(dst) < BlockSize {
7070
panic("crypto/aes: output not full block")
7171
}
72-
if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
72+
if alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
7373
panic("crypto/aes: invalid buffer overlap")
7474
}
7575
cryptBlocks(c.function, &c.key[0], &dst[0], &src[0], BlockSize)
@@ -82,7 +82,7 @@ func (c *aesCipherAsm) Decrypt(dst, src []byte) {
8282
if len(dst) < BlockSize {
8383
panic("crypto/aes: output not full block")
8484
}
85-
if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
85+
if alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
8686
panic("crypto/aes: invalid buffer overlap")
8787
}
8888
// The decrypt function code is equal to the function code + 128.

src/crypto/aes/ctr_s390x.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package aes
66

77
import (
88
"crypto/cipher"
9-
"crypto/internal/subtle"
9+
"crypto/internal/alias"
1010
"encoding/binary"
1111
)
1212

@@ -69,7 +69,7 @@ func (c *aesctr) XORKeyStream(dst, src []byte) {
6969
if len(dst) < len(src) {
7070
panic("crypto/cipher: output smaller than input")
7171
}
72-
if subtle.InexactOverlap(dst[:len(src)], src) {
72+
if alias.InexactOverlap(dst[:len(src)], src) {
7373
panic("crypto/cipher: invalid buffer overlap")
7474
}
7575
for len(src) > 0 {

src/crypto/aes/gcm_s390x.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package aes
66

77
import (
88
"crypto/cipher"
9-
subtleoverlap "crypto/internal/subtle"
9+
"crypto/internal/alias"
1010
"crypto/subtle"
1111
"encoding/binary"
1212
"errors"
@@ -211,7 +211,7 @@ func (g *gcmAsm) Seal(dst, nonce, plaintext, data []byte) []byte {
211211
}
212212

213213
ret, out := sliceForAppend(dst, len(plaintext)+g.tagSize)
214-
if subtleoverlap.InexactOverlap(out[:len(plaintext)], plaintext) {
214+
if alias.InexactOverlap(out[:len(plaintext)], plaintext) {
215215
panic("crypto/cipher: invalid buffer overlap")
216216
}
217217

@@ -260,7 +260,7 @@ func (g *gcmAsm) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) {
260260
g.auth(expectedTag[:], ciphertext, data, &tagMask)
261261

262262
ret, out := sliceForAppend(dst, len(ciphertext))
263-
if subtleoverlap.InexactOverlap(out, ciphertext) {
263+
if alias.InexactOverlap(out, ciphertext) {
264264
panic("crypto/cipher: invalid buffer overlap")
265265
}
266266

@@ -312,7 +312,7 @@ func (g *gcmKMA) Seal(dst, nonce, plaintext, data []byte) []byte {
312312
}
313313

314314
ret, out := sliceForAppend(dst, len(plaintext)+g.tagSize)
315-
if subtleoverlap.InexactOverlap(out[:len(plaintext)], plaintext) {
315+
if alias.InexactOverlap(out[:len(plaintext)], plaintext) {
316316
panic("crypto/cipher: invalid buffer overlap")
317317
}
318318

@@ -342,7 +342,7 @@ func (g *gcmKMA) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) {
342342
tag := ciphertext[len(ciphertext)-g.tagSize:]
343343
ciphertext = ciphertext[:len(ciphertext)-g.tagSize]
344344
ret, out := sliceForAppend(dst, len(ciphertext))
345-
if subtleoverlap.InexactOverlap(out, ciphertext) {
345+
if alias.InexactOverlap(out, ciphertext) {
346346
panic("crypto/cipher: invalid buffer overlap")
347347
}
348348

src/crypto/cipher/cbc.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
package cipher
1313

14-
import "crypto/internal/subtle"
14+
import "crypto/internal/alias"
1515

1616
type cbc struct {
1717
b Block
@@ -72,7 +72,7 @@ func (x *cbcEncrypter) CryptBlocks(dst, src []byte) {
7272
if len(dst) < len(src) {
7373
panic("crypto/cipher: output smaller than input")
7474
}
75-
if subtle.InexactOverlap(dst[:len(src)], src) {
75+
if alias.InexactOverlap(dst[:len(src)], src) {
7676
panic("crypto/cipher: invalid buffer overlap")
7777
}
7878

@@ -143,7 +143,7 @@ func (x *cbcDecrypter) CryptBlocks(dst, src []byte) {
143143
if len(dst) < len(src) {
144144
panic("crypto/cipher: output smaller than input")
145145
}
146-
if subtle.InexactOverlap(dst[:len(src)], src) {
146+
if alias.InexactOverlap(dst[:len(src)], src) {
147147
panic("crypto/cipher: invalid buffer overlap")
148148
}
149149
if len(src) == 0 {

src/crypto/cipher/cfb.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
package cipher
88

9-
import "crypto/internal/subtle"
9+
import "crypto/internal/alias"
1010

1111
type cfb struct {
1212
b Block
@@ -21,7 +21,7 @@ func (x *cfb) XORKeyStream(dst, src []byte) {
2121
if len(dst) < len(src) {
2222
panic("crypto/cipher: output smaller than input")
2323
}
24-
if subtle.InexactOverlap(dst[:len(src)], src) {
24+
if alias.InexactOverlap(dst[:len(src)], src) {
2525
panic("crypto/cipher: invalid buffer overlap")
2626
}
2727
for len(src) > 0 {

src/crypto/cipher/ctr.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
package cipher
1414

15-
import "crypto/internal/subtle"
15+
import "crypto/internal/alias"
1616

1717
type ctr struct {
1818
b Block
@@ -76,7 +76,7 @@ func (x *ctr) XORKeyStream(dst, src []byte) {
7676
if len(dst) < len(src) {
7777
panic("crypto/cipher: output smaller than input")
7878
}
79-
if subtle.InexactOverlap(dst[:len(src)], src) {
79+
if alias.InexactOverlap(dst[:len(src)], src) {
8080
panic("crypto/cipher: invalid buffer overlap")
8181
}
8282
for len(src) > 0 {

src/crypto/cipher/gcm.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package cipher
66

77
import (
8-
subtleoverlap "crypto/internal/subtle"
8+
"crypto/internal/alias"
99
"crypto/subtle"
1010
"encoding/binary"
1111
"errors"
@@ -174,7 +174,7 @@ func (g *gcm) Seal(dst, nonce, plaintext, data []byte) []byte {
174174
}
175175

176176
ret, out := sliceForAppend(dst, len(plaintext)+g.tagSize)
177-
if subtleoverlap.InexactOverlap(out, plaintext) {
177+
if alias.InexactOverlap(out, plaintext) {
178178
panic("crypto/cipher: invalid buffer overlap")
179179
}
180180

@@ -225,7 +225,7 @@ func (g *gcm) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) {
225225
g.auth(expectedTag[:], ciphertext, data, &tagMask)
226226

227227
ret, out := sliceForAppend(dst, len(ciphertext))
228-
if subtleoverlap.InexactOverlap(out, ciphertext) {
228+
if alias.InexactOverlap(out, ciphertext) {
229229
panic("crypto/cipher: invalid buffer overlap")
230230
}
231231

src/crypto/cipher/ofb.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
package cipher
88

9-
import "crypto/internal/subtle"
9+
import "crypto/internal/alias"
1010

1111
type ofb struct {
1212
b Block
@@ -59,7 +59,7 @@ func (x *ofb) XORKeyStream(dst, src []byte) {
5959
if len(dst) < len(src) {
6060
panic("crypto/cipher: output smaller than input")
6161
}
62-
if subtle.InexactOverlap(dst[:len(src)], src) {
62+
if alias.InexactOverlap(dst[:len(src)], src) {
6363
panic("crypto/cipher: invalid buffer overlap")
6464
}
6565
for len(src) > 0 {

src/crypto/des/cipher.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package des
66

77
import (
88
"crypto/cipher"
9-
"crypto/internal/subtle"
9+
"crypto/internal/alias"
1010
"encoding/binary"
1111
"strconv"
1212
)
@@ -45,7 +45,7 @@ func (c *desCipher) Encrypt(dst, src []byte) {
4545
if len(dst) < BlockSize {
4646
panic("crypto/des: output not full block")
4747
}
48-
if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
48+
if alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
4949
panic("crypto/des: invalid buffer overlap")
5050
}
5151
encryptBlock(c.subkeys[:], dst, src)
@@ -58,7 +58,7 @@ func (c *desCipher) Decrypt(dst, src []byte) {
5858
if len(dst) < BlockSize {
5959
panic("crypto/des: output not full block")
6060
}
61-
if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
61+
if alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
6262
panic("crypto/des: invalid buffer overlap")
6363
}
6464
decryptBlock(c.subkeys[:], dst, src)
@@ -91,7 +91,7 @@ func (c *tripleDESCipher) Encrypt(dst, src []byte) {
9191
if len(dst) < BlockSize {
9292
panic("crypto/des: output not full block")
9393
}
94-
if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
94+
if alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
9595
panic("crypto/des: invalid buffer overlap")
9696
}
9797

@@ -126,7 +126,7 @@ func (c *tripleDESCipher) Decrypt(dst, src []byte) {
126126
if len(dst) < BlockSize {
127127
panic("crypto/des: output not full block")
128128
}
129-
if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
129+
if alias.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
130130
panic("crypto/des: invalid buffer overlap")
131131
}
132132

src/crypto/internal/subtle/aliasing.go renamed to src/crypto/internal/alias/alias.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !appengine
6-
7-
// Package subtle implements functions that are often useful in cryptographic
8-
// code but require careful thought to use correctly.
9-
//
10-
// This is a mirror of golang.org/x/crypto/internal/subtle.
11-
package subtle // import "crypto/internal/subtle"
5+
// Package alias implements memory alaising tests.
6+
// This code also exists as golang.org/x/crypto/internal/alias.
7+
package alias
128

139
import "unsafe"
1410

0 commit comments

Comments
 (0)