Skip to content

Commit 07b0c57

Browse files
kortschakmvdan
authored andcommitted
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í <[email protected]> Reviewed-by: Daniel Martí <[email protected]> Trust: Johan Brandhorst-Satzkorn <[email protected]>
1 parent c18f398 commit 07b0c57

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/crypto/subtle/constant_time.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ package subtle
88

99
// ConstantTimeCompare returns 1 if the two slices, x and y, have equal contents
1010
// and 0 otherwise. The time taken is a function of the length of the slices and
11-
// is independent of the contents.
11+
// is independent of the contents. If the lengths of x and y do not match it
12+
// returns 0 immediately.
1213
func ConstantTimeCompare(x, y []byte) int {
1314
if len(x) != len(y) {
1415
return 0

0 commit comments

Comments
 (0)