HMAC
Definition
Hash-based Message Authentication Code, RFC 2104. Combines a secret key with a hash function to produce a MAC; immune to the length-extension attack that affects bare SHA-2.
- Standard
- RFC 2104
- Inputs
- Secret key plus a cryptographic hash function
- Output
- Message authentication code (MAC)
- Key resistance
- Immune to length-extension attacks
Common questions
Why is HMAC preferred over simply hashing key and message together?+
A naive concatenation of key and message, hashed with SHA-2, is vulnerable to length-extension attacks that let an attacker forge a valid MAC for an extended message without knowing the key. HMAC's nested construction avoids this.
Where does HMAC appear in a forensic or evidentiary context?+
It is used to verify that a digital artefact such as a log file, signed URL, or seized data export has not been altered since it was generated, provided the verifying party holds the same secret key used to create the original MAC.
Related terms
- Asymmetric Cryptography
- Cryptosystem that uses a key pair: a public key (shareable) and a private key (secret). Built on mathematical trapdoor functions where the...
- Digital Signature
- Cryptographic proof of authenticity, integrity and non-repudiation. Sign by encrypting a hash of the message with the signer's private key; verify by...
- DSC
- Digital Signature Certificate. An Indian X.509 certificate issued by a CCA-licensed CA. Class 3 is the current mandatory tier for income tax,...
- ECC
- Elliptic Curve Cryptography. Smaller keys for equivalent security; 256-bit ECC is roughly equivalent to 3072-bit RSA. Used in ECDSA signatures, ECDH key...
- Hash Function
- Deterministic function that maps an input of arbitrary length to a fixed-length output. A cryptographic hash adds pre-image resistance, second pre-image resistance,...
- PKI
- Public Key Infrastructure. The set of roles (CA, RA, VA) and artefacts (X.509 certificates, CRL, OCSP) that bind a public key to...
- RSA
- Rivest-Shamir-Adleman, 1977. Public-key cryptosystem based on the hardness of factoring a product of two large primes. Common sizes today: 2048-bit (standard), 3072-bit...
- Trapdoor Function
- A one-way function with a secret 'trapdoor' that makes the reverse direction tractable. RSA's trapdoor is the factorisation of n into p...