]> Cypherpunks repositories - gostls13.git/commit
crypto/subtle: document and test XORBytes overlap rules
authorFilippo Valsorda <filippo@golang.org>
Thu, 24 Oct 2024 14:27:44 +0000 (16:27 +0200)
committerFilippo Valsorda <filippo@golang.org>
Mon, 18 Nov 2024 18:26:39 +0000 (18:26 +0000)
commit7a20239ce8a877ae82b8c269a8ff28fe59609c69
tree49d0145aaa621cf6a72e8245d8b5b6ab8d2b2d82
parent5ec1457941d1754a583a745259b9c308749c0bd1
crypto/subtle: document and test XORBytes overlap rules

XORBytes doesn't say anything about how it deals with destination and
source overlaps. Current implementations as written do work if the
destination overlaps perfectly with a source, but will unavoidably
return nonsensical results if the destination is ahead of the source.
Lock in the current behavior with tests, docs, and panics.

Note that this introduces a new panic, but if any applications run into
it we are potentially catching a security issue.

Also, expand the tests and move them outside the FIPS module per #69536
convention. (We want to minimize changes within the module boundary.)

Updates #53021

Change-Id: Ibb0875fd38da3818079e31b83b1a227b53755930
Reviewed-on: https://go-review.googlesource.com/c/go/+/622276
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/crypto/internal/fips/subtle/xor.go
src/crypto/internal/fips/subtle/xor_test.go [deleted file]
src/crypto/subtle/xor.go
src/crypto/subtle/xor_linux_test.go [new file with mode: 0644]
src/crypto/subtle/xor_test.go [new file with mode: 0644]