mirror of https://github.com/golang/go.git
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
This commit is contained in:
parent
6b29f7bfbe
commit
384f4380e8
|
|
@ -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++ {
|
||||
|
|
|
|||
Loading…
Reference in New Issue