forked from cwtch.im/cwtch
Use a constant-time compare
This commit is contained in:
parent
ef417848ad
commit
f24b8a3d2b
|
@ -37,12 +37,11 @@ func compareSignatures(a []byte, b []byte) bool {
|
||||||
if len(a) != len(b) {
|
if len(a) != len(b) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
int d = 0
|
||||||
for i := range a {
|
for i := range a {
|
||||||
if a[i] != b[i] {
|
d := d | (a[i] ^ b[i])
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true
|
return d == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMessages returns a copy of the entire timeline
|
// GetMessages returns a copy of the entire timeline
|
||||||
|
|
Loading…
Reference in New Issue