Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit017a1aa

Browse files
committed
chacha20poly1305: panic on dst and additionalData overlap
The cipher.AEAD interface specifies that these should not overlap.This mirrors the check that the GCM implementation does.Fixesgolang/go#75968Updatesgolang/go#21624Change-Id: If5fbb8611ff6c0aae44d50079bad29f56ce00f5bReviewed-on:https://go-review.googlesource.com/c/crypto/+/712860Reviewed-by: Roland Shoemaker <roland@golang.org>Reviewed-by: David Chase <drchase@google.com>Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parentcf29fa9 commit017a1aa

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

‎chacha20poly1305/chacha20poly1305_amd64.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ func (c *chacha20poly1305) seal(dst, nonce, plaintext, additionalData []byte) []
5656

5757
ret,out:=sliceForAppend(dst,len(plaintext)+16)
5858
ifalias.InexactOverlap(out,plaintext) {
59-
panic("chacha20poly1305: invalid buffer overlap")
59+
panic("chacha20poly1305: invalid buffer overlap of output and input")
60+
}
61+
ifalias.AnyOverlap(out,additionalData) {
62+
panic("chacha20poly1305: invalid buffer overlap of output and additional data")
6063
}
6164
chacha20Poly1305Seal(out[:],state[:],plaintext,additionalData)
6265
returnret
@@ -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
ifalias.InexactOverlap(out,ciphertext) {
76-
panic("chacha20poly1305: invalid buffer overlap")
79+
panic("chacha20poly1305: invalid buffer overlap of output and input")
80+
}
81+
ifalias.AnyOverlap(out,additionalData) {
82+
panic("chacha20poly1305: invalid buffer overlap of output and additional data")
7783
}
7884
if!chacha20Poly1305Open(out,state[:],ciphertext,additionalData) {
7985
fori:=rangeout {

‎chacha20poly1305/chacha20poly1305_generic.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ func (c *chacha20poly1305) sealGeneric(dst, nonce, plaintext, additionalData []b
3131
ret,out:=sliceForAppend(dst,len(plaintext)+poly1305.TagSize)
3232
ciphertext,tag:=out[:len(plaintext)],out[len(plaintext):]
3333
ifalias.InexactOverlap(out,plaintext) {
34-
panic("chacha20poly1305: invalid buffer overlap")
34+
panic("chacha20poly1305: invalid buffer overlap of output and input")
35+
}
36+
ifalias.AnyOverlap(out,additionalData) {
37+
panic("chacha20poly1305: invalid buffer overlap of output and additional data")
3538
}
3639

3740
varpolyKey [32]byte
@@ -67,7 +70,10 @@ func (c *chacha20poly1305) openGeneric(dst, nonce, ciphertext, additionalData []
6770

6871
ret,out:=sliceForAppend(dst,len(ciphertext))
6972
ifalias.InexactOverlap(out,ciphertext) {
70-
panic("chacha20poly1305: invalid buffer overlap")
73+
panic("chacha20poly1305: invalid buffer overlap of output and input")
74+
}
75+
ifalias.AnyOverlap(out,additionalData) {
76+
panic("chacha20poly1305: invalid buffer overlap of output and additional data")
7177
}
7278
if!p.Verify(tag) {
7379
fori:=rangeout {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp