package client

import "crypto/subtle"

// constantTimeEqual compares two strings without leaking their contents
// through timing. Used for peer tokens, where a byte-by-byte comparison would
// let an attacker recover the expected value one byte at a time.
func constantTimeEqual(a, b string) bool {
	if len(a) != len(b) {
		return false
	}
	return subtle.ConstantTimeCompare([]byte(a), []byte(b)) == 1
}
