Cryptographic goals
Choose the security property
Separate confidentiality, integrity, authenticity, and non-repudiation before selecting a cryptographic operation.
Cryptography solves specific problems. Start by naming the property you need, because the property picks the tool for you.
Confidentiality hides content from anyone without the key. Integrity detects that data changed. Authenticity helps prove who created or approved a message. Non-repudiation goes one step further: the creator cannot later deny producing it, which is what digital signatures add over shared-secret authentication.
These sound similar. They are not, and mixing them up is where real systems break.
Why the property comes first
Here is a failure I want you to remember. A payroll file is encrypted before upload, but nobody verifies who created it. Its contents stay private while an attacker replaces it with different encrypted bytes. Confidentiality was achieved. Integrity and authenticity were never requested, so nobody got them.
Each property maps to a different operation:
confidentiality -> encryption (with a key)
integrity -> hash comparison against a trusted digest
authenticity -> MAC (shared secret) or signature (private key)
non-repudiation -> digital signature only
Notice that a MAC gives authenticity between two parties that share a secret, but not non-repudiation. Either party could have produced the MAC, so it proves nothing to a third party.
Some designs need several properties together. An encrypted session cookie usually needs confidentiality and authenticity at the same time, which is why authenticated encryption exists as a single construction.
What cryptography does not give you
Availability and authorization sit outside the cryptographic primitive. Encrypting a document does not decide who is allowed to request decryption, and a valid signature does not mean the signed action is permitted now. Name those needs separately and solve them with access control, not with more encryption.
My advice is to write the property down before touching any API. One line is enough: “this backup needs confidentiality against whoever steals the disk, and integrity so we notice tampering on restore.”
Practice
Write the required properties for a private note, a software installer, a session cookie, and a payroll upload. For each answer, name the attacker and the evidence that the control produces. Then change one case so confidentiality is unnecessary but authenticity remains essential, and explain the different choice. The installer is a good candidate: its contents are public, but you care deeply about who built it.
Lesson completed