]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/subtle: note that input length mismatch makes ConstantTimeCompare return immed...
authorDan Kortschak <dan@kortschak.io>
Mon, 3 May 2021 03:47:04 +0000 (13:17 +0930)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 5 Apr 2022 01:54:27 +0000 (01:54 +0000)
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>

src/crypto/subtle/constant_time.go

index 7c3cf05c462c4c474231a7c7b5869d43dba33c42..4e0527f9d5a61c0862454f9610d2adbe7390fa0c 100644 (file)
@@ -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