]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/crypto/aes/cipher_amd64.go
[dev.boringcrypto] all: merge master into dev.boringcrypto
[gostls13.git] / src / crypto / aes / cipher_amd64.go
index 7efab31065d2fafb7faf9febc2bfd78e94c74fef..fd88343cae8af51d10596c0ceccaf22746678134 100644 (file)
@@ -7,6 +7,7 @@ package aes
 import (
        "crypto/cipher"
        "crypto/internal/boring"
+       "crypto/internal/subtle"
        "internal/cpu"
 )
 
@@ -54,6 +55,9 @@ func (c *aesCipherAsm) Encrypt(dst, src []byte) {
        if len(dst) < BlockSize {
                panic("crypto/aes: output not full block")
        }
+       if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
+               panic("crypto/aes: invalid buffer overlap")
+       }
        encryptBlockAsm(len(c.enc)/4-1, &c.enc[0], &dst[0], &src[0])
 }
 
@@ -65,6 +69,9 @@ func (c *aesCipherAsm) Decrypt(dst, src []byte) {
        if len(dst) < BlockSize {
                panic("crypto/aes: output not full block")
        }
+       if subtle.InexactOverlap(dst[:BlockSize], src[:BlockSize]) {
+               panic("crypto/aes: invalid buffer overlap")
+       }
        decryptBlockAsm(len(c.dec)/4-1, &c.dec[0], &dst[0], &src[0])
 }