Commit 384f4380 authored by Adam Langley's avatar Adam Langley

crypto/subtle: panic if slices of different lengths are passed to ConstantTimeCompare.

ConstantTimeCompare has always been documented to take equal length
slices but perhaps this is too subtle, even for 'subtle'.

Fixes #7304.

LGTM=hanwen, bradfitz
R=golang-codereviews, hanwen, bradfitz
CC=golang-codereviews
https://golang.org/cl/62190043
parent 6b29f7bf
......@@ -10,6 +10,10 @@ package subtle
// and y, have equal contents. The time taken is a function of the length of
// the slices and is independent of the contents.
func ConstantTimeCompare(x, y []byte) int {
if len(x) != len(y) {
panic("subtle: slices have different lengths")
}
var v byte
for i := 0; i < len(x); i++ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment