Browse papers
A

Section A: Long Answer Questions

Attempt any TWO questions.

3 questions·10 marks each
1long10 marks

Explain the Diffie-Hellman key exchange algorithm with an example. Show how an eavesdropper can perform a man-in-the-middle attack on this protocol.

Diffie-Hellman Key Exchange

The Diffie-Hellman (DH) algorithm allows two parties to agree on a shared secret key over an insecure channel without ever transmitting the key itself. Its security rests on the difficulty of the Discrete Logarithm Problem.

Algorithm

Public parameters (agreed in advance):

  • A large prime pp.
  • A primitive root gg modulo pp (the generator).

Steps:

  1. Alice picks a secret integer aa and computes A=gamodpA = g^{a} \bmod p; she sends AA to Bob.
  2. Bob picks a secret integer bb and computes B=gbmodpB = g^{b} \bmod p; he sends BB to Alice.
  3. Alice computes K=BamodpK = B^{a} \bmod p.
  4. Bob computes K=AbmodpK = A^{b} \bmod p.

Both obtain the same key because

K=(gb)a=(ga)b=gabmodp.K = (g^{b})^{a} = (g^{a})^{b} = g^{ab} \bmod p.

Example (p=23, g=5p = 23,\ g = 5)

  • Alice: a=6A=56mod23=8a = 6 \Rightarrow A = 5^{6} \bmod 23 = 8.
  • Bob: b=15B=515mod23=19b = 15 \Rightarrow B = 5^{15} \bmod 23 = 19.
  • Alice: K=196mod23=2K = 19^{6} \bmod 23 = 2.
  • Bob: K=815mod23=2K = 8^{15} \bmod 23 = 2.

Shared secret K=2K = 2. An eavesdropper sees p,g,A,Bp,g,A,B but cannot find aa or bb without solving the discrete log.

Man-in-the-Middle (MITM) Attack

DH provides no authentication, so an attacker Mallory sitting between Alice and Bob can impersonate each to the other:

  1. Alice sends A=gaA = g^{a}. Mallory intercepts it and instead sends her own M=gmM = g^{m} to Bob.
  2. Bob sends B=gbB = g^{b}. Mallory intercepts it and sends M=gmM = g^{m} to Alice.
  3. Alice computes K1=Ma=gamK_1 = M^{a} = g^{am}; Mallory computes the same K1=AmK_1 = A^{m}.
  4. Bob computes K2=Mb=gbmK_2 = M^{b} = g^{bm}; Mallory computes the same K2=BmK_2 = B^{m}.

Now Mallory shares K1K_1 with Alice and K2K_2 with Bob. She decrypts every message from one side with one key and re-encrypts it with the other, reading and altering traffic while both believe they share a secret.

Countermeasure: Authenticate the exchanged public values, e.g. by signing AA and BB (digital signatures / certificates) — this gives authenticated Diffie-Hellman (as in TLS/IKE/STS).

diffie-hellman
2long10 marks

What are cryptographic hash functions? Explain the SHA-1 algorithm and describe how a 160-bit message digest is generated.

Cryptographic Hash Functions

A cryptographic hash function HH maps an arbitrary-length message MM to a fixed-length output h=H(M)h = H(M) called the message digest. Required properties:

  • Preimage resistance (one-way): given hh, infeasible to find MM with H(M)=hH(M)=h.
  • Second-preimage resistance: given MM, infeasible to find MMM' \neq M with H(M)=H(M)H(M')=H(M).
  • Collision resistance: infeasible to find any pair MMM \neq M' with H(M)=H(M)H(M)=H(M').
  • Avalanche effect: a 1-bit input change flips ~half the output bits.

Uses: integrity checks, digital signatures, MACs, password storage.

SHA-1 Algorithm

SHA-1 produces a 160-bit digest using the Merkle-Damgård construction and processes the message in 512-bit blocks.

1. Padding

Append a 1 bit, then 0 bits, then a 64-bit length field so that the total length 448(mod512)\equiv 448 \pmod{512}. Final length is a multiple of 512 bits.

2. Initialize the five 32-bit chaining variables

H0=67452301, H1=EFCDAB89, H2=98BADCFE, H3=10325476, H4=C3D2E1F0.H_0=\texttt{67452301},\ H_1=\texttt{EFCDAB89},\ H_2=\texttt{98BADCFE},\ H_3=\texttt{10325476},\ H_4=\texttt{C3D2E1F0}.

3. Process each 512-bit block

Expand the sixteen 32-bit words W0..W15W_0..W_{15} to eighty words:

Wt=(Wt3Wt8Wt14Wt16)1,16t79.W_t = (W_{t-3}\oplus W_{t-8}\oplus W_{t-14}\oplus W_{t-16}) \lll 1,\quad 16\le t\le 79.

Set a,b,c,d,e=H0..H4a,b,c,d,e = H_0..H_4. For t=0..79t=0..79 run 80 rounds:

T=(a5)+ft(b,c,d)+e+Kt+Wt,T = (a\lll 5) + f_t(b,c,d) + e + K_t + W_t, e=d, d=c, c=(b30), b=a, a=T.e=d,\ d=c,\ c=(b\lll 30),\ b=a,\ a=T.

The round function ftf_t and constant KtK_t change every 20 rounds:

Roundsft(b,c,d)f_t(b,c,d)KtK_t
0–19(bc)(¬bd)(b\wedge c)\vee(\lnot b\wedge d)5A827999
20–39bcdb\oplus c\oplus d6ED9EBA1
40–59(bc)(bd)(cd)(b\wedge c)\vee(b\wedge d)\vee(c\wedge d)8F1BBCDC
60–79bcdb\oplus c\oplus dCA62C1D6

4. Update chaining values

H0 ⁣+ ⁣=a, H1 ⁣+ ⁣=b, H2 ⁣+ ⁣=c, H3 ⁣+ ⁣=d, H4 ⁣+ ⁣=e(mod232).H_0\!+\!=a,\ H_1\!+\!=b,\ H_2\!+\!=c,\ H_3\!+\!=d,\ H_4\!+\!=e \pmod{2^{32}}.

5. Output

After all blocks, the 160-bit digest is the concatenation

H0H1H2H3H4.H_0 \,\|\, H_1 \,\|\, H_2 \,\|\, H_3 \,\|\, H_4.

Note: SHA-1 is now considered broken for collision resistance (SHAttered attack, 2017) and is deprecated in favour of SHA-2/SHA-3.

hash-functions
3long10 marks

Explain classical encryption techniques. Describe the Playfair cipher and the Hill cipher with examples of encryption.

Classical Encryption Techniques

Classical ciphers work on plaintext letters and fall into two classes:

  • Substitution ciphers – replace letters with other symbols (Caesar, Playfair, Hill, Vigenère).
  • Transposition ciphers – rearrange letter positions (Rail Fence, Columnar).

Playfair Cipher (digraph substitution)

Encrypts pairs of letters using a 5×55\times5 key matrix (I/J share a cell).

Key = "MONARCHY":

M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z

Rules (after splitting plaintext into digraphs; insert X between repeated letters and pad if odd):

  1. Same row: replace each letter by the one to its right (wrap).
  2. Same column: replace each by the one below (wrap).
  3. Rectangle: replace each by the letter in its own row but the other letter's column.

Example: plaintext BALLOON → digraphs BA LX LO ON.

  • BA: rectangle → IB
  • LX: rectangle → SU
  • LO: rectangle → PM (L row, O column = P; O row, L column = M)
  • ON: same row → NA

Ciphertext = IBSUPMNA.

Hill Cipher (polygraphic, linear algebra)

Encrypts blocks of nn letters using an invertible n×nn\times n key matrix KK modulo 26. Letters map A=0,,Z=25A=0,\dots,Z=25.

C=KPmod26,P=K1Cmod26.C = K P \bmod 26, \qquad P = K^{-1} C \bmod 26.

Example with K=(3325)K=\begin{pmatrix}3 & 3\\ 2 & 5\end{pmatrix}, plaintext HI = (78)\begin{pmatrix}7\\8\end{pmatrix}:

C=(3325)(78)=(4554)mod26=(192)=TC.C=\begin{pmatrix}3&3\\2&5\end{pmatrix}\begin{pmatrix}7\\8\end{pmatrix}=\begin{pmatrix}45\\54\end{pmatrix}\bmod 26=\begin{pmatrix}19\\2\end{pmatrix}=\texttt{TC}.

Ciphertext = TC. Decryption requires K1mod26K^{-1}\bmod 26, which exists only when gcd(detK,26)=1\gcd(\det K, 26)=1 (here detK=9\det K = 9, coprime to 26).

classical-ciphers
B

Section B: Short Answer Questions

Attempt any EIGHT questions.

9 questions·5 marks each
4short5 marks

What is a Message Authentication Code (MAC)? Explain how HMAC works.

Message Authentication Code (MAC)

A MAC is a short fixed-length tag computed from a message MM and a shared secret key KK: tag=MAC(K,M)\text{tag}=\text{MAC}(K,M). The sender appends the tag; the receiver recomputes it and accepts only if they match. A MAC provides data integrity and authentication (proof the message came from someone holding KK), but not non-repudiation (both parties share the key) or confidentiality.

HMAC (Hash-based MAC)

HMAC builds a MAC from any cryptographic hash HH (e.g. SHA-256). It uses two padded constants — ipad (0x36 repeated) and opad (0x5C repeated) — and the key KK:

HMAC(K,M)=H((Kopad)  H((Kipad)  M))\text{HMAC}(K,M) = H\big((K \oplus opad)\ \|\ H((K \oplus ipad)\ \|\ M)\big)

Steps:

  1. Pad/hash key KK to the block size.
  2. Inner hash: XOR key with ipad, prepend to MM, hash it.
  3. Outer hash: XOR key with opad, prepend to the inner result, hash again.

The nested (two-pass) structure defeats length-extension attacks that affect plain H(KM)H(K\|M), and HMAC is provably secure if the underlying hash's compression function is a PRF.

mac
5short5 marks

Explain key management and key distribution in symmetric cryptography.

Key Management and Distribution in Symmetric Cryptography

In symmetric cryptography both parties share one secret key, so the central problem is securely generating, distributing, storing and renewing that key. For nn users wanting pairwise communication, (n2)=n(n1)/2\binom{n}{2}=n(n-1)/2 keys are needed — this key-explosion is the core scaling challenge.

Key Distribution Methods

  1. Physical/manual delivery: A hands the key to B in person or via courier. Secure but unscalable.
  2. Encrypted via an existing key: if A and B already share a key, a new session key can be sent encrypted under it.
  3. Third-party encrypted delivery: a trusted Key Distribution Center (KDC) shares a master key with each user and issues short-lived session keys on demand (the basis of Kerberos).
  4. Public-key based exchange: use a public-key method or Diffie-Hellman to establish the symmetric session key.

KDC Operation (typical)

  • A requests a session key for B from the KDC.
  • The KDC generates session key KsK_s and sends it to A encrypted under A's master key, plus a ticket EKb(Ks,IDA)E_{Kb}(K_s, ID_A) for B.
  • A forwards the ticket; B decrypts it to obtain KsK_s.

Key Lifecycle

Generation → distribution → storage (protected) → usage → periodic rotation → revocation/destruction. Session keys are short-lived to limit exposure; master keys are long-lived and heavily protected.

key-management
6short5 marks

State and explain Fermat's little theorem and Euler's theorem with examples.

Fermat's Little Theorem

Statement: If pp is prime and gcd(a,p)=1\gcd(a,p)=1, then

ap11(modp).a^{p-1} \equiv 1 \pmod{p}.

Equivalently, for any integer aa: apa(modp)a^{p} \equiv a \pmod p.

Example: p=7, a=3p=7,\ a=3:

36=729=104×7+1361(mod7). 3^{6} = 729 = 104\times 7 + 1 \Rightarrow 3^{6}\equiv 1 \pmod 7.\ \checkmark

Euler's Theorem (generalisation)

Statement: If gcd(a,n)=1\gcd(a,n)=1, then

aϕ(n)1(modn),a^{\phi(n)} \equiv 1 \pmod{n},

where ϕ(n)\phi(n) is Euler's totient = count of integers in [1,n][1,n] coprime to nn. For prime pp, ϕ(p)=p1\phi(p)=p-1, so Fermat's theorem is the special case.

Example: n=10, a=3n=10,\ a=3. ϕ(10)=4\phi(10)=4 (the units 1,3,7,91,3,7,9):

34=81=8×10+1341(mod10). 3^{4}=81 = 8\times 10 + 1 \Rightarrow 3^{4}\equiv 1 \pmod{10}.\ \checkmark

Relevance to cryptography: Euler's theorem underlies RSA — choosing ed1(modϕ(n))ed \equiv 1 \pmod{\phi(n)} guarantees medm(modn)m^{ed}\equiv m \pmod n, so decryption inverts encryption. It also speeds modular exponentiation by reducing exponents modulo ϕ(n)\phi(n).

fermat-euler
7short5 marks

Is a man-in-the-middle attack possible in the Diffie-Hellman algorithm? Justify your answer.

Is MITM Possible in Diffie-Hellman?

Yes. Plain Diffie-Hellman is vulnerable to a man-in-the-middle attack because it establishes a shared secret but provides no authentication of the communicating parties — neither side can verify that the public value it received actually came from the intended partner.

Why

An attacker Mallory between Alice and Bob can substitute her own public values:

  1. Alice sends A=gaA=g^{a}; Mallory replaces it with gmg^{m} toward Bob.
  2. Bob sends B=gbB=g^{b}; Mallory replaces it with gmg^{m} toward Alice.
  3. Alice forms K1=gamK_1=g^{am} with Mallory; Bob forms K2=gbmK_2=g^{bm} with Mallory.

Mallory now holds both keys, decrypting and re-encrypting all traffic while Alice and Bob believe they share one secret. The underlying discrete-log hardness is never broken — the weakness is the missing authentication.

Justification & Fix

The attack is possible precisely because messages AA and BB are unauthenticated. Authenticating the exchange — signing the public values with digital signatures, using certificates/PKI, or a password-authenticated variant (e.g. the Station-to-Station protocol, used in TLS and IKE) — prevents the substitution and stops the MITM attack.

mim-attack
8short5 marks

Explain the families of SHA-2 and their differences from SHA-1.

The SHA-2 Family

SHA-2 is a family of cryptographic hash functions designed by the NSA and standardised by NIST (FIPS 180-4). It comprises six variants distinguished mainly by digest length and internal word size:

VariantDigest (bits)Block sizeWord sizeRounds
SHA-22422451232-bit64
SHA-25625651232-bit64
SHA-384384102464-bit80
SHA-512512102464-bit80
SHA-512/224224102464-bit80
SHA-512/256256102464-bit80

SHA-224/256 use eight 32-bit working variables; SHA-384/512 use eight 64-bit variables (with truncated outputs for 224/384). The 224/384 versions are truncations of 256/512 with different initial hash values.

Differences from SHA-1

AspectSHA-1SHA-2
Digest size160 bits (fixed)224–512 bits (variable)
Working variables5 (×32-bit)8 (×32 or ×64-bit)
Rounds8064 (SHA-256) / 80 (SHA-512)
Round functionone ftf_t per 20 rounds, simplericher functions (Σ,σ\Sigma,\sigma, Ch, Maj) + per-round constants KtK_t
Securitybroken (collisions found, 2017)no practical collision; considered secure

Summary: SHA-2 offers larger, configurable digests, more chaining variables, a stronger message-schedule and round function, and far greater collision resistance, making it the recommended replacement for the now-deprecated SHA-1.

sha2
9short5 marks

What is Public Key Infrastructure (PKI)? Explain the role of a Certificate Authority and digital certificates.

Public Key Infrastructure (PKI)

PKI is the framework of hardware, software, policies, people and procedures used to create, manage, distribute, store and revoke digital certificates and public keys. Its purpose is to reliably bind a public key to an identity, enabling authentication, confidentiality, integrity and non-repudiation in public-key cryptography.

Main components: Certificate Authority (CA), Registration Authority (RA), digital certificates, a certificate repository/directory, and a revocation mechanism (CRL / OCSP).

Certificate Authority (CA)

The CA is the trusted third party that:

  • Verifies an applicant's identity (often via an RA).
  • Issues digital certificates by signing them with the CA's private key.
  • Maintains and publishes Certificate Revocation Lists (CRLs) for compromised/expired certificates.
  • Forms a chain of trust: root CA → intermediate CAs → end-entity certificates.

Digital Certificate (X.509)

A digital certificate is a signed data structure that binds a public key to its owner. An X.509 certificate contains:

  • Version, serial number.
  • Subject name (owner) and the subject's public key.
  • Issuer name (the CA).
  • Validity period (not-before / not-after).
  • Signature algorithm and the CA's digital signature over the certificate.

A relying party trusts the certificate by verifying the CA's signature with the CA's (already trusted) public key, thereby trusting the bound public key without prior contact.

pki
10short5 marks

Explain the basic logic of malicious code: viruses, worms and trojan horses.

Malicious Code (Malware)

Malicious code is software intentionally written to damage, disrupt or gain unauthorised access to systems and data.

1. Virus

A virus is a code fragment that attaches itself to a host program or file and cannot run independently — it executes when the infected host is run. On execution it replicates by inserting copies into other programs/files and may carry a payload (corrupting data, displaying messages). Spread requires user action (running the host), e.g. boot-sector, file-infector and macro viruses.

2. Worm

A worm is a standalone program that does not need a host and self-propagates across networks automatically by exploiting vulnerabilities or using email/file shares — no user action required. Because it replicates autonomously, a worm can spread extremely fast and consume bandwidth/resources (e.g. Code Red, ILOVEYOU, Conficker).

3. Trojan Horse

A trojan horse is a program that disguises itself as legitimate or useful software but hides malicious functionality (backdoor, data theft, spyware). It does not self-replicate; it relies on the user being tricked into installing/running it.

FeatureVirusWormTrojan
Needs a hostYesNoNo
Self-replicatesYesYes (over network)No
Spreads viainfected files/user actionnetwork, automaticsocial engineering
malicious-code
11short5 marks

State the Chinese Remainder Theorem and use it to solve a system of congruences.

Chinese Remainder Theorem (CRT)

Statement: If n1,n2,,nkn_1, n_2, \dots, n_k are pairwise coprime positive integers, then the system of congruences

xa1(modn1),xa2(modn2), , xak(modnk)x \equiv a_1 \pmod{n_1},\quad x \equiv a_2 \pmod{n_2},\ \dots,\ x \equiv a_k \pmod{n_k}

has a unique solution modulo N=n1n2nkN = n_1 n_2 \cdots n_k.

Solution Method

Let N=niN=\prod n_i, Ni=N/niN_i = N/n_i, and Mi=Ni1modniM_i = N_i^{-1} \bmod n_i. Then

x=iaiNiMi(modN).x = \sum_i a_i N_i M_i \pmod N.

Worked Example

Solve:

x2 (mod 3),x3 (mod 5),x2 (mod 7).x\equiv 2\ (\bmod\ 3),\quad x\equiv 3\ (\bmod\ 5),\quad x\equiv 2\ (\bmod\ 7).

N=357=105.N = 3\cdot5\cdot7 = 105.

iinin_iaia_iNi=N/niN_i=N/n_iMi=Ni1modniM_i=N_i^{-1}\bmod n_i
1323535235\equiv2, 2122^{-1}\equiv2M1=2M_1=2
2532121121\equiv1, ⇒ M2=1M_2=1
3721515115\equiv1, ⇒ M3=1M_3=1
x=2(35)(2)+3(21)(1)+2(15)(1)=140+63+30=233.x = 2(35)(2) + 3(21)(1) + 2(15)(1) = 140 + 63 + 30 = 233. x233mod105=23.x \equiv 233 \bmod 105 = 23.

Answer: x23(mod105)x \equiv 23 \pmod{105}. Check: 23mod3=223\bmod3=2, 23mod5=323\bmod5=3, 23mod7=223\bmod7=2. ✓

CRT is widely used in cryptography to speed up RSA decryption by working modulo the prime factors pp and qq separately.

chinese-remainder
12short5 marks

Explain the goals of security: confidentiality, integrity and availability. List the different types of security attacks.

Goals of Security (CIA Triad)

  • Confidentiality: ensure information is accessible only to authorised parties; prevent unauthorised disclosure. Achieved by encryption and access control.
  • Integrity: ensure data is accurate and not modified in an unauthorised way; detect tampering. Achieved with hashes, MACs and digital signatures.
  • Availability: ensure systems and data are accessible to authorised users when needed. Threatened by Denial-of-Service attacks; protected by redundancy, backups and DoS mitigation.

Supporting goals: authentication, non-repudiation and access control.

Types of Security Attacks

By effect (passive vs active):

  • Passive attacks – attacker only observes; no modification. Hard to detect.
    • Release of message contents (eavesdropping).
    • Traffic analysis (inferring info from patterns/metadata).
  • Active attacks – attacker alters data or operation; easier to detect, harder to prevent.
    • Masquerade – impersonating another entity.
    • Replay – capturing and re-sending valid data.
    • Modification of messages – altering content.
    • Denial of Service (DoS) – disrupting availability.

By security-goal violated (Stallings model):

  • Interception → confidentiality.
  • Interruption → availability.
  • Modification → integrity.
  • Fabrication → authenticity.
security-services

Frequently asked questions

Where can I find the BSc CSIT (TU) Cryptography (BSc CSIT, CSC316) question paper 2078?
The full BSc CSIT (TU) Cryptography (BSc CSIT, CSC316) 2078 (regular) question paper is available free on Kekkei. You can read every question online and attempt the paper under timed exam conditions.
Does the Cryptography (BSc CSIT, CSC316) 2078 paper come with solutions?
Yes. Every question on this Cryptography (BSc CSIT, CSC316) past paper includes a step-by-step solution, plus instant AI feedback when you attempt it on Kekkei.
How many marks is the BSc CSIT (TU) Cryptography (BSc CSIT, CSC316) 2078 paper?
The BSc CSIT (TU) Cryptography (BSc CSIT, CSC316) 2078 paper carries 60 full marks and is meant to be completed in 180 minutes, across 12 questions.
Is practising this Cryptography (BSc CSIT, CSC316) past paper free?
Yes — reading and attempting this Cryptography (BSc CSIT, CSC316) past paper on Kekkei is completely free.