@@ -56,7 +56,10 @@ func (c *chacha20poly1305) seal(dst, nonce, plaintext, additionalData []byte) []
5656
5757 ret , out := sliceForAppend (dst , len (plaintext )+ 16 )
5858 if alias .InexactOverlap (out , plaintext ) {
59- panic ("chacha20poly1305: invalid buffer overlap" )
59+ panic ("chacha20poly1305: invalid buffer overlap of output and input" )
60+ }
61+ if alias .AnyOverlap (out , additionalData ) {
62+ panic ("chacha20poly1305: invalid buffer overlap of output and additional data" )
6063 }
6164 chacha20Poly1305Seal (out [:], state [:], plaintext , additionalData )
6265 return ret
@@ -73,7 +76,10 @@ func (c *chacha20poly1305) open(dst, nonce, ciphertext, additionalData []byte) (
7376 ciphertext = ciphertext [:len (ciphertext )- 16 ]
7477 ret , out := sliceForAppend (dst , len (ciphertext ))
7578 if alias .InexactOverlap (out , ciphertext ) {
76- panic ("chacha20poly1305: invalid buffer overlap" )
79+ panic ("chacha20poly1305: invalid buffer overlap of output and input" )
80+ }
81+ if alias .AnyOverlap (out , additionalData ) {
82+ panic ("chacha20poly1305: invalid buffer overlap of output and additional data" )
7783 }
7884 if ! chacha20Poly1305Open (out , state [:], ciphertext , additionalData ) {
7985 for i := range out {
0 commit comments