---
title: "Discussion on \"Comparing license tokens without a timing leak\" | Hashnode"
description: "Discussion on \"Comparing license tokens without a timing leak\". Here is a comparison that looks obviously correct and is quietly a security hole:\nstatic bool TokenMatches(byte[] presented, byte[] expected)\n{\n    if (presented.Length != expected.Length) return fals"
url: "https://hashnode.com/posts/comparing-license-tokens-without-a-timing-leak/6b0e80557d3f7ad7077e7b1e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Comparing license tokens without a timing leak](https://delta1labs.hashnode.dev/comparing-license-tokens-without-a-timing-leak?utm_source=hashnode&utm_medium=feed)

Here is a comparison that looks obviously correct and is quietly a security hole: static bool TokenMatches(byte\[\] presented, byte\[\] expected) { if (presented.Length != expected.Length) return fals

1d ago · 10 min read · delta1labs.hashnode.dev  
Updated 4h ago  
Read the article

-   [#keyright](https://hashnode.com/tag/keyright)
-   [#security](https://hashnode.com/tag/security)
-   [#cryptography](https://hashnode.com/tag/cryptography)

## Written by

[Zero Heartbeat](https://hashnode.com/@clustron)

@clustron

  
[View profile](https://hashnode.com/@clustron)

## Responses 1

Markdown supported · ⌘↵ to post

[AI Developer](https://hashnode.com/@lycore)

[1d ago](https://hashnode.com/posts/comparing-license-tokens-without-a-timing-leak/6b0e80557d3f7ad7077e7b1e/comment/6b0e9d2a98a242d6985e30ab)

The hash-to-fixed-width step is a neat way to close the length channel. One question: if the secret is a short, human-typed activation code, would a bare SHA-256 of it make offline guessing cheap once the stored digest leaks, so that an HMAC with a server-side key is the better way to collapse both sides before FixedTimeEquals? That also keeps the comparison input independent of what the attacker controls. Separately, remote timing attacks are noisy, so a per-code and per-IP attempt limit is probably what stops a byte-at-a-time search in practice. It would be interesting to see how many samples per byte a real network measurement needs before the prefix signal becomes distinguishable from jitter.
