Keyed Cryptographic Hash
A keyed cryptographic hash is a way of scrambling data into a fixed-size fingerprint using both the data itself and a secret key. Because the key is required, someone who only knows the data cannot reproduce or reverse the result without also knowing the key. In payment security, it is one method used to protect a card number (PAN) when the PAN needs to be rendered unreadable.
A keyed cryptographic hash is an algorithm that produces a fixed-size output from a message combined with a secret key shared or held by the relevant endpoints, most commonly implemented as a message authentication code such as HMAC. Unlike an unkeyed hash, incorporating a secret key defends against precomputation and brute-force attacks that exploit the small input space of a PAN, since an attacker cannot enumerate candidate values and match the digest without also possessing the key. In PCI DSS, keyed cryptographic hashing of the entire PAN is one of the defined methods for rendering PAN unreadable where stored; note that a hash is not reversible like encryption and does not by itself constitute tokenization, truncation, or masking, and its acceptability and any associated key-management and version-specific requirements should be confirmed against the current published PCI DSS standard rather than an assumed requirement number.
Why it matters
A primary account number (PAN) occupies a comparatively small and well-structured input space: the leading digits identify issuers, a check digit constrains the final digit, and much of the remaining range is predictable. This means an unkeyed hash of a PAN is vulnerable to precomputation and brute-force attacks, where an attacker enumerates candidate PANs, hashes each one, and matches the result against stored digests. A keyed cryptographic hash addresses this weakness by incorporating a secret key into the computation, so that an attacker who obtains only the stored digests cannot reproduce or reverse them without also possessing the key.
In the context of PCI DSS, keyed cryptographic hashing of the entire PAN is one of the defined methods for rendering PAN unreadable where it is stored. This matters for organizations that need to retain a consistent, non-reversible representation of a PAN—for example to match or deduplicate records—without keeping the PAN itself in readable form. Because the security of this approach depends entirely on protecting the secret key, key-management controls become central; a compromised key can undermine the protection the hash was intended to provide.
It is important not to overstate what a keyed hash accomplishes. A hash is not reversible in the way encryption is, and it does not by itself constitute tokenization, truncation, or masking—these are distinct techniques with different properties and different effects on scope. Whether keyed hashing is acceptable for a given use, and what key-management and version-specific obligations apply, should be confirmed against the current published PCI DSS standard rather than an assumed requirement number, since numbering and wording differ between versions.
Who it's relevant to
Inside Keyed Cryptographic Hash
Common questions
Answers to the questions practitioners most commonly ask about Keyed Cryptographic Hash.