Glossary
Constant-time comparison
Comparing signatures in fixed time so a mismatch leaks nothing through timing. OneLifeVibe checks webhook signatures this way before parsing the body.
Updated November 12, 2026
At OneLifeVibe
- Verify against the raw body, before parsing, with a constant-time comparison, and reject timestamps more than 5 minutes away.
Related terms
What it means
Constant-time comparison means checking two values, usually a signature you received and a signature you computed, in a way that takes the same amount of work no matter where they differ. A normal string equality check stops at the first byte that doesn't match. That is faster and easier, and it quietly tells the caller something: how many leading bytes it got right.
That matters when the caller can send many requests and watch how long each one takes. Small timing differences add up across enough samples, and a signature can be guessed one byte at a time instead of all at once. Constant-time comparison removes that signal. It does not make the signature stronger or the secret harder to guess. It only stops the comparison itself from answering questions it was never meant to answer.
How it works
The usual pattern is to walk every byte of both values, fold the differences together, and decide once at the end. In practice that means exclusive-ORing the bytes, OR-ing the results into an accumulator, and testing the accumulator after the loop rather than returning early. Some languages ship a helper for this, such as a fixed-time byte comparison in their crypto library. Writing the loop yourself is fine if you keep the no-early-return rule.
A few details sit around the loop. Decode both sides the same way before comparing, so a hex string is never compared to raw bytes. Handle a length mismatch without branching on secret data, and compare over a fixed length where you can. Remember what the comparison protects: it is one step in a chain that starts with reading the exact bytes that were signed and ends with deciding whether to trust the message.
How OneLifeVibe uses it
OneLifeVibe signs webhook deliveries with HMAC-SHA256. When a delivery arrives, the signature is verified against the raw body, before that body is parsed, using a constant-time comparison. The raw body is the point: JSON that is parsed and serialized again can come out with different whitespace or key order, and the HMAC would be computed over different bytes than the ones that were signed.
Deliveries also carry a timestamp, and OneLifeVibe rejects timestamps more than 5 minutes away. That check runs alongside the signature verification, so a captured request that is replayed later falls outside the window and is refused. The practical order for your handler is: read the raw bytes, check the timestamp is within 5 minutes, compute the expected HMAC-SHA256 with your signing secret, compare it in constant time, and only then parse the payload and act on it. If the signature or the timestamp check fails, treat the delivery as unverified and do nothing with its contents.
Common mistakes
Parsing first is the most common one. If your framework hands you an already-parsed object, the bytes you sign are gone, so look for the raw body option the framework provides and keep it available to the verification step. The second is comparing with a plain equality operator or a string comparison on the hex digest, which brings back the early exit.
A few others are easy to miss. Skipping the timestamp window means a signed request stays valid forever once it has been captured, and checking it after you have already processed the event is too late. Logging the full signature or the signing secret puts the material in places it should not be. And answering failures with detail about which part did not match gives back the information the constant-time comparison was there to withhold.
Questions
Why does the webhook signature have to be checked against the raw body?
Because the signature is computed over the exact bytes that were sent. Parsing and re-serializing the JSON can change whitespace, escaping or key order, so the HMAC over the rebuilt body will not match even when the content is identical. Keep the raw bytes and verify those.
Does constant-time comparison prevent replay attacks?
No. It only hides timing information during the comparison. Replay protection comes from the timestamp check: OneLifeVibe rejects deliveries with timestamps more than 5 minutes away. Within that window, a handler that must not process the same event twice needs its own record of what it has already handled.
See it working. The OneLifeVibe connector and Platform API put these pieces together.
Written from the OneLifeVibe tool registry and platform configuration, and checked automatically before publishing. Something wrong? Tell us.