Produce something only you could have produced

short · 30 min · Objective 1.2

Task

Demonstrate the difference between integrity, authentication and non-repudiation by producing three artefacts over the same file and showing what each one does and does not prove.

Steps

  1. Create a document: printf 'Transfer 500 to account 4471\n' > /tmp/instruction.txt.
  2. Integrity only: sha256sum /tmp/instruction.txt > /tmp/digest.txt.
  3. Authentication between two parties sharing a secret: openssl dgst -sha256 -hmac 'shared-lab-secret' /tmp/instruction.txt > /tmp/hmac.txt.
  4. Non-repudiation: generate a key pair with openssl genpkey -algorithm RSA -out /tmp/priv.pem -pkeyopt rsa_keygen_bits:2048 and openssl rsa -in /tmp/priv.pem -pubout -out /tmp/pub.pem, then sign with openssl dgst -sha256 -sign /tmp/priv.pem -out /tmp/sig.bin /tmp/instruction.txt.
  5. Verify the signature with the PUBLIC key only: openssl dgst -sha256 -verify /tmp/pub.pem -signature /tmp/sig.bin /tmp/instruction.txt.
  6. Now alter the file — change 500 to 5000 — and re-run all three checks. Note which of them fail and write one sentence on what each failure does and does not tell you about who made the change.

Verify

openssl dgst -sha256 -verify /tmp/pub.pem -signature /tmp/sig.bin /tmp/instruction.txt
sha256sum -c /tmp/digest.txt 2>&1 | tail -1
test -s /tmp/hmac.txt && awk '{print "hmac present: "$NF}' /tmp/hmac.txt

Before the edit, the first must print Verified OK and the second OK. After the edit both must fail. The distinction to write down is that the digest and the HMAC prove the file changed, while only the signature proves who produced the original — because only you hold /tmp/priv.pem, and the verifier needed nothing secret at all.

Notes

Delete /tmp/priv.pem when you are done, and notice why that sentence exists: the entire non-repudiation claim rests on exactly one file being under your sole control. Key escrow, from the PKI lesson, is the business requirement that deliberately breaks it.

This is an independent study companion for CompTIA Security+ SY0-701 and is not produced by or endorsed by CompTIA.