Message authentication codes and digital signatures
Integrity with authenticity
A message authentication code (MAC) is a tag computed with a shared secret and a message. The receiver uses the shared key to verify it. A digital signature is produced with a private signing key and checked with the corresponding public key. Both can detect unauthorized changes when used correctly, but neither by itself hides the message. Here MAC is unrelated to a network MAC address.
Shared-key verification with HMAC
HMAC is a MAC construction using a cryptographic hash and a secret key. Two services exchanging inventory messages can use an established protocol with HMAC to check authenticity and integrity. A valid tag shows that a holder of the secret could have produced the message; it does not identify which holder. Verification failure means the message must not be trusted. MAC alone does not prevent replay of a previously valid message.
Public verification with signatures
A publisher signs a catalog release using its protected private signing key. Customers verify the signature using an independently trusted public key. They do not need the signing key. A successful verification provides evidence of integrity and origin relative to that key, not proof that the content is safe or that every business claim is true. If a signing key is compromised, trust in affected signatures needs review.
Compare the evidence
A plain digest can be recomputed by anyone; a MAC needs the shared secret; a signature can be verified without the private signing key. If public verification is needed, a shared MAC key is unsuitable because verifiers with that key can also generate tags. A signature is not simply encryption with a private key. Use dedicated signature schemes and established libraries.
Practice: select a verifier
Select a mechanism for a public software announcement and another for two internal services that already share a secret. Explain how each verifier gets trusted key material and what a failed verification means. Next, study how keys are created, protected and associated with identities.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Message authentication codes and digital signatures — knowledge check
Apply the cryptographic concept to fictional scenarios.
What distinguishes HMAC from a plain hash?
Two services share the same MAC key. Can a valid tag uniquely identify which service created it?
What must a customer have to verify a publisher’s digital signature?
What does a valid signature not establish by itself?
A received MAC fails verification. What is the safe response?