mirror of
https://github.com/golang/go
synced 2024-11-24 10:30:10 -07:00
crypto/subtle: note that input length mismatch makes ConstantTimeCompare return immediately
Change-Id: Id1ae6c8fbb8c2f31b251ba141dc2bbedae189006 Reviewed-on: https://go-review.googlesource.com/c/go/+/316169 Trust: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Trust: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
This commit is contained in:
parent
c18f398f32
commit
07b0c57a75
@ -8,7 +8,8 @@ package subtle
|
||||
|
||||
// ConstantTimeCompare returns 1 if the two slices, x and y, have equal contents
|
||||
// and 0 otherwise. The time taken is a function of the length of the slices and
|
||||
// is independent of the contents.
|
||||
// is independent of the contents. If the lengths of x and y do not match it
|
||||
// returns 0 immediately.
|
||||
func ConstantTimeCompare(x, y []byte) int {
|
||||
if len(x) != len(y) {
|
||||
return 0
|
||||
|
Loading…
Reference in New Issue
Block a user