Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

A model for network security

A clear, exam-focused set of study notes that builds a practical model for thinking about network security: assets, adversary (Dolev–Yao), goals (CIA+), policies, mechanisms (cryptography, reference monitor), and formal limits (Shannon perfect secrecy).

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Two or three sentences: where an engineer uses this.

Networked systems expose important data and services to attackers; an engineer uses a clear model for network security to decide what to defend, what adversary strength to assume, which cryptographic and protocol mechanisms to apply, and how to test or verify the design. A good model reduces design mistakes (e.g. assuming confidentiality also gives integrity) and guides deployment choices such as key management and trusted components.

Key ideas

(Explain plainly; define every term before using it.)

  • Asset: anything of value in the system (data, keys, services). Draw a box labelled "Asset(s)" and list examples: user secrets, session keys, database.

  • Adversary (attacker): an entity attempting to harm assets. Define the adversary model precisely before designing defenses — it states what the attacker can and cannot do.

  • Security goals: the primary goals are Confidentiality (prevent unauthorised parties from learning the information), Integrity (unauthorised modification is detectable or prevented), and Availability (authorized users can use the system when needed). Also include Authentication (prove identity), Authorization (permissions), and Non-repudiation (cannot deny an action).

  • Policy vs Mechanism: A security policy is a statement of what is allowed/forbidden (e.g. "only managers may read salary database"). A mechanism is an implementation that enforces the policy (e.g. access control lists, encryption). Always state the policy first.

  • Kerckhoffs's principle: A system should remain secure even if everything about the system, except the key, is public. This guides designs and assumptions in adversary models.

  • Reference Monitor concept: A reference monitor is an abstract mechanism that mediates all accesses to resources; it must be (1) always invoked, (2) tamper-proof, and (3) small enough to be verifiable. The set of code/hardware that implements trusted functions is the Trusted Computing Base (TCB); the small part that enforces the security policy is the security kernel.

  • Network model components: Participants (principals), channels, messages, cryptographic primitives, trust anchors (e.g. CA root public keys), and long-term secrets (e.g. private keys). When drawing, show principals (A, B), communication channel (line), attacker on channel (dashed arrow intercepting), and trust anchor store (box near each principal labelled "trusted keys").

  • Dolev–Yao adversary model (exact statement): The adversary controls the communication network: it can read, delete, reorder, inject, and modify any message. The adversary cannot break cryptography primitives — i.e., it can only decrypt a ciphertext if it knows the correct key and cannot invert hash functions or derive keys from ciphertexts. This is a formal model used for protocol analysis and assumes perfect cryptography.

    Assumptions behind Dolev–Yao: (a) cryptographic primitives are ideal (no cryptanalysis); (b) principals can securely generate and store their secret keys; (c) channels are otherwise unreliable (subject to control by adversary).

  • Shannon's perfect secrecy (exact statement): A scheme provides perfect secrecy if for all messages M and ciphertexts C, the conditional probability of M given C equals the prior probability of M: P(M | C) = P(M). Equivalently in information-theory terms, H(M | C) = H(M). Shannon proved that if keys are independent of messages and chosen from some distribution, then perfect secrecy implies H(K) >= H(M). For uniformly distributed messages over a finite message space and deterministic encryption, perfect secrecy implies that the key space must be at least as large as the message space; for binary strings this means key length must be at least message length (as in the one-time pad).

    Assumptions: messages and keys are random variables; attacker has unlimited computational power. This result is an information-theoretic limit, not a practical construction except for the one-time pad.

  • Security protocol model: Define principals, nonces (fresh random values), session keys, and the goals (secrecy/freshness/authentication). When analysing a protocol on paper for an exam, write a message sequence diagram: vertical lines for principals, horizontal arrows for messages, and annotate each message with contents and encryption keys.

  • Failure modes to model: replay attacks, man-in-the-middle, key compromise, insider threats, denial of service. For each, state attacker capabilities that enable the attack (e.g., replay requires the attacker can capture and resend messages — a Dolev–Yao capability). Also recall the X.800 classification: passive attacks (eavesdropping, traffic analysis) vs active attacks (masquerade, replay, modification of messages, denial of service), and the security services they motivate (authentication, access control, data confidentiality, data integrity, non-repudiation).

Formulas

(Each formula on its own line, symbol meaning and units when applicable.)

C = E_k(P) — C is ciphertext, E is encryption function, k is key, P is plaintext (units: bits for P and k; function maps bit-strings to bit-strings). Applies when using a deterministic or probabilistic encryption scheme.

P = D_k(C) — D is decryption function using key k; output is plaintext P. Same units as above.

MAC = MAC_k(M) — MAC (message authentication code) is a function of message M and key k. Verification succeeds if Verify_k(M, MAC) = true.

H(M | C) = H(M) — conditional entropy; H is Shannon entropy in bits. Means perfect secrecy: observing ciphertext gives no additional information about message.

H(K) >= H(M) — key entropy (bits) at least message entropy is necessary for perfect secrecy (Shannon). Units: bits. Applies under Shannon assumptions (keys independent of messages, adversary unbounded).

N_sym = n(n-1)/2 — number of distinct symmetric keys needed for pairwise shared keys among n principals. Unit: count (dimensionless). Applies when symmetric keys are unique per pair.

N_pk = n (or n key pairs) — number of public/private key pairs needed for n principals; each principal stores its private key (secret) and copies of others' public keys as needed. Unit: count. Applies to public-key systems.

Worked examples

(University-exam standard; each step numbered, formulas before numbers, units carried through.)

Example 1 — Key count comparison (numerical)

Problem: Compare key storage for n = 100 users if using pairwise symmetric keys vs public-key pairs.

Step 1: Symmetric keys needed: use N_sym = n(n-1)/2.

Step 2: Substitute: N_sym = 100·99/2 = 4950 distinct keys.

Step 3: Public-key pairs: N_pk = n = 100 key pairs (each user has one private key and one public key). If storing only others' public keys, each user stores 99 public keys, but system-wide distinct private keys remain 100.

Answer: 4950 symmetric keys system-wide vs 100 public/private key pairs system-wide. This shows why public-key systems simplify key distribution at the cost of heavier computation. With a symmetric-key distribution center (KDC), each user can instead share one long-term symmetric key with the KDC, reducing stored long-term keys to O(n) while using per-session keys.

Example 2 — One-time pad (demonstrates Shannon perfect secrecy)

Problem: Encrypt binary message M = 1011 with key K = 0110 using XOR one-time pad and decrypt.

Step 1: Formula C = M XOR K.

Step 2: Compute bitwise: 1011 XOR 0110 = 1101. So ciphertext C = 1101 (bits).

Step 3: Decrypt using M = C XOR K: 1101 XOR 0110 = 1011 recovers original message.

Comment: The one-time pad provides perfect secrecy only when K is uniformly random, used once, and length(K) = length(M). Key unit: bits. Final answer: C = 1101, decrypted M = 1011.

Example 3 — Replay attack (protocol trace)

Problem: Show a simple replay attack on a protocol that uses no freshness.

Protocol (intended): A -> B: {A, M}_k (A sends encrypted message M under shared key k)

Attack steps:

  1. Attacker intercepts message from A to B: record {A, M}_k.
  2. Later attacker resends (replays) {A, M}_k to B.
  3. B receives {A, M}_k and, if no freshness checks, accepts M as new — leading to duplicate or unauthorized repeated action.

Defence: include a nonce or timestamp: A -> B: {A, nonceA, M}_k and B verifies nonce freshness. Message sequence diagram to draw: vertical lines for A, Attacker, B; arrow A->Attacker labelled original ciphertext; arrow Attacker->B labelled replayed ciphertext.

Common mistakes

  • Miscounting keys: using n for symmetric pairwise keys instead of n(n-1)/2.
  • Believing perfect secrecy is practical for long messages: forgetting the one-time pad key-length requirement (key must be as long as message and used once).
  • Using timestamps without considering clock skew and replay windows (forgetting to specify how freshness is checked).
  • Applying Dolev–Yao conclusions to real cryptographic weaknesses (Dolev–Yao assumes perfect cryptography — a real-world implementation may have flaws).

For your exam

Kinds of questions this topic produces and what a full-marks answer includes:

  • Definitions: Give precise definitions of adversary model, reference monitor, perfect secrecy, and trusted computing base. State assumptions for each.
  • Short notes: Explain Dolev–Yao model, and contrast computational vs information-theoretic security (Shannon perfect secrecy). Mention practical implications.
  • Derivations: Prove Shannon's necessary condition H(K) >= H(M) for perfect secrecy (sketch: H(M) = H(M|C) = H(M,C) - H(C) and use H(K) ≥ ... provide full steps expected in exam).
  • Numericals: Key-count problems (n(n-1)/2), one-time pad example with XOR, or simple MAC verification trace.
  • Protocol analysis: Draw message sequence diagrams; state attacker capabilities; produce an attack trace (replay, MITM) or show why protocol resists attack under Dolev–Yao assumptions.
  • Diagrams: Sequence diagram for a protocol with labelled messages and attacker interactions; network diagram showing principals, channels and trust anchors. A full-marks diagram clearly labels principals (A,B), attacker, messages (with contents), and keys used.

A full-marks answer always states assumptions (e.g., perfect cryptography, secure key storage) and concludes security relative to those assumptions.

Quick check

Three short questions:

  1. What is the Dolev–Yao adversary allowed to do to messages?
  2. State the condition for Shannon perfect secrecy in terms of conditional entropy.
  3. For n users, write the formula for the number of symmetric pairwise keys required.

Answers: 1) Read, delete, reorder, inject and modify any message on the network (but cannot break ideal cryptography). 2) H(M | C) = H(M). 3) n(n-1)/2.

Note for reviewer: I have prioritized standard textbook statements (Dolev–Yao, Shannon) and exam-style worked examples. I may have simplified some implementation details (e.g., how public keys are stored vs distributed). See verify list below for exact claims to check.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?