Browse papers
A

Section A: Long Answer Questions

Attempt any TWO questions.

3 questions·10 marks each
1long10 marks

Explain the structure of the Data Encryption Standard (DES) algorithm with a block diagram. Describe a single round of DES including the function F.

Data Encryption Standard (DES)

DES is a symmetric-key block cipher that encrypts a 64-bit plaintext block using a 56-bit key (supplied as 64 bits, with 8 parity bits) and produces a 64-bit ciphertext. It is based on a Feistel structure with 16 rounds.

Overall Structure (Block Diagram in words)

64-bit Plaintext
      |
[ Initial Permutation (IP) ]
      |
  split into L0 (32 bits) | R0 (32 bits)
      |
  Round 1  (uses subkey K1)
  Round 2  (uses subkey K2)
     ...
  Round 16 (uses subkey K16)
      |
  swap (R16 | L16)  -> 32+32 = 64 bits
      |
[ Inverse Initial Permutation (IP^-1) ]
      |
64-bit Ciphertext

The 56-bit key is processed by a key schedule: it is passed through Permuted Choice 1 (PC-1), split into two 28-bit halves, circularly left-shifted each round, and compressed by Permuted Choice 2 (PC-2) into a 48-bit round subkey KiK_i.

A Single Round of DES

DES uses the Feistel structure. For round ii, the input (Li1,Ri1)(L_{i-1}, R_{i-1}) is transformed as:

Li=Ri1L_i = R_{i-1} Ri=Li1F(Ri1,Ki)R_i = L_{i-1} \oplus F(R_{i-1}, K_i)

The right half is fed to the round function FF, the result is XORed with the left half, and the halves are swapped.

The Function F (the heart of DES)

F takes the 32-bit Ri1R_{i-1} and the 48-bit subkey KiK_i and returns 32 bits:

  1. Expansion (E): the 32-bit right half is expanded to 48 bits by the expansion permutation E (some bits are duplicated).
  2. Key mixing (XOR): the 48-bit expanded value is XORed with the 48-bit subkey KiK_i.
  3. Substitution (S-boxes): the 48 bits are split into eight 6-bit groups; each group enters an S-box that maps 6 bits to 4 bits (non-linear, provides confusion), giving 8×4=328 \times 4 = 32 bits.
  4. Permutation (P): the 32-bit S-box output is permuted by the P-box (provides diffusion), producing the 32-bit output of F.

The S-boxes are the only non-linear component and are crucial to DES security.

Decryption

Decryption uses the same algorithm with subkeys applied in reverse order (K16,K15,,K1K_{16}, K_{15}, \ldots, K_1), a property of the Feistel network.

des
2long10 marks

Explain the structure of the Advanced Encryption Standard (AES) algorithm. Describe the four transformations: SubBytes, ShiftRows, MixColumns and AddRoundKey with examples.

Advanced Encryption Standard (AES)

AES is a symmetric block cipher that operates on 128-bit blocks with key sizes of 128, 192, or 256 bits, using 10, 12, or 14 rounds respectively. Unlike DES, AES is not a Feistel cipher; it is a substitution-permutation network (SPN).

The 128-bit block is arranged as a 4x4 matrix of bytes called the State, filled column by column. All arithmetic is done in the finite field GF(28)GF(2^8) with the irreducible polynomial x8+x4+x3+x+1x^8 + x^4 + x^3 + x + 1.

Structure (for AES-128, 10 rounds)

AddRoundKey (initial)
Rounds 1..9:  SubBytes -> ShiftRows -> MixColumns -> AddRoundKey
Round 10:     SubBytes -> ShiftRows -> AddRoundKey   (NO MixColumns)

The Four Transformations

1. SubBytes (substitution / confusion) Each byte of the State is replaced using a fixed S-box (a non-linear byte substitution = multiplicative inverse in GF(28)GF(2^8) followed by an affine transform). Example: the byte 0x53 is replaced by 0xED according to the S-box lookup.

2. ShiftRows (permutation / diffusion) The rows of the State are cyclically shifted left:

  • Row 0: no shift
  • Row 1: shift left by 1
  • Row 2: shift left by 2
  • Row 3: shift left by 3

Example: row [b0 b1 b2 b3] becomes [b1 b2 b3 b0] (1-byte shift).

3. MixColumns (diffusion) Each column is treated as a polynomial over GF(28)GF(2^8) and multiplied (mod x4+1x^4+1) by the fixed matrix:

[02030101010203010101020303010102][s0s1s2s3]\begin{bmatrix} 02 & 03 & 01 & 01 \\ 01 & 02 & 03 & 01 \\ 01 & 01 & 02 & 03 \\ 03 & 01 & 01 & 02 \end{bmatrix}\begin{bmatrix} s_0 \\ s_1 \\ s_2 \\ s_3 \end{bmatrix}

Multiplication is in GF(28)GF(2^8) and addition is XOR. This spreads each input byte across all four output bytes of the column. (Omitted in the final round.)

4. AddRoundKey The 128-bit round key (derived from the cipher key by the key expansion / key schedule) is XORed byte-by-byte with the State:

State=StateRoundKeyi\text{State} = \text{State} \oplus \text{RoundKey}_i

Decryption

Decryption applies the inverse transformations (InvSubBytes, InvShiftRows, InvMixColumns, AddRoundKey) in reverse order.

aes
3long10 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

Diffie-Hellman (DH) lets two parties establish a shared secret key over an insecure channel without prior secrets. Its security rests on the Discrete Logarithm Problem: it is easy to compute gamodpg^a \bmod p but hard to recover aa from it.

Algorithm

Public parameters: a large prime pp and a primitive root (generator) gg of pp.

  1. Alice picks a private aa, computes A=gamodpA = g^a \bmod p, sends AA to Bob.
  2. Bob picks a private bb, computes B=gbmodpB = g^b \bmod p, 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=Ba=(gb)a=gab=(ga)b=Ab(modp)K = B^a = (g^b)^a = g^{ab} = (g^a)^b = A^b \pmod p

Numerical Example

Let p=23p = 23, g=5g = 5.

  • Alice: private a=6a = 6, A=56mod23=15625mod23=8A = 5^6 \bmod 23 = 15625 \bmod 23 = 8.
  • Bob: private b=15b = 15, B=515mod23=19B = 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=8,B=19p, g, A=8, B=19 but cannot easily find aa or bb.

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:

Alice  --A=g^a-->  Mallory  --M1=g^m-->  Bob
Alice  <--M2=g^n-- Mallory  <--B=g^b---  Bob
  1. Alice sends A=gaA = g^a; Mallory intercepts it and sends her own gmg^m to Bob.
  2. Bob sends B=gbB = g^b; Mallory intercepts it and sends her own gng^n to Alice.
  3. Alice computes K1=(gn)a=gnaK_1 = (g^n)^a = g^{na} (shared with Mallory).
  4. Bob computes K2=(gm)b=gmbK_2 = (g^m)^b = g^{mb} (shared with Mallory).

Now Mallory shares key K1K_1 with Alice and K2K_2 with Bob. She decrypts every message from one side, reads/alters it, re-encrypts with the other key, and forwards it. Neither party detects the attack.

Countermeasure: authenticate the exchanged values (e.g. signed/certified public values, station-to-station protocol, or DH within TLS with certificates).

diffie-hellman
B

Section B: Short Answer Questions

Attempt any EIGHT questions.

9 questions·5 marks each
4short5 marks

Explain the Caesar cipher and the mono-alphabetic substitution cipher with examples of their cryptanalysis.

Caesar Cipher

The Caesar cipher is a mono-alphabetic shift substitution: each letter is shifted by a fixed key kk.

C=(P+k)mod26,P=(Ck)mod26C = (P + k) \bmod 26, \qquad P = (C - k) \bmod 26

Example (k=3k=3): HELLO -> KHOOR.

Cryptanalysis: the key space has only 25 possibilities, so a brute-force attack trying all shifts breaks it instantly; alternatively frequency analysis on a single letter reveals the shift.

Mono-alphabetic Substitution Cipher

Here each plaintext letter maps to an arbitrary fixed letter, giving a key space of 26!4×102626!\approx 4\times10^{26} permutations, so brute force is infeasible.

Cryptanalysis (frequency analysis): the cipher preserves letter frequencies. In English, E (~12.7%), T, A, O are most common. By matching the most frequent ciphertext letters to common English letters and using digram/trigram patterns (e.g. TH, THE), the substitution table is recovered. Example: if X is the most frequent ciphertext letter, it likely maps to E.

Conclusion: both are insecure - Caesar by brute force, mono-alphabetic by frequency analysis.

caesar-cipher
5short5 marks

Explain modular arithmetic and Euler's totient function. Compute phi(35) and phi(24).

Modular Arithmetic

Modular arithmetic is arithmetic over the integers where numbers wrap around after reaching a modulus nn. We write ab(modn)a \equiv b \pmod{n} if nn divides (ab)(a-b), i.e. they leave the same remainder when divided by nn. Example: 175(mod12)17 \equiv 5 \pmod{12}. It underlies almost all modern public-key cryptography (RSA, Diffie-Hellman, ElGamal).

Euler's Totient Function ϕ(n)\phi(n)

ϕ(n)\phi(n) counts the integers in {1,2,,n}\{1,2,\ldots,n\} that are coprime to nn (i.e. gcd=1\gcd = 1).

Properties used for computation:

  • If pp is prime, ϕ(p)=p1\phi(p) = p-1.
  • ϕ\phi is multiplicative: if gcd(m,n)=1\gcd(m,n)=1, ϕ(mn)=ϕ(m)ϕ(n)\phi(mn)=\phi(m)\phi(n).
  • For n=pikin = \prod p_i^{k_i},  ϕ(n)=npn(11p)\ \phi(n) = n\prod_{p\mid n}\left(1-\tfrac1p\right).

Compute ϕ(35)\phi(35)

35=5×735 = 5 \times 7 (both prime, coprime):

ϕ(35)=ϕ(5)ϕ(7)=(51)(71)=4×6=24\phi(35) = \phi(5)\,\phi(7) = (5-1)(7-1) = 4 \times 6 = \boxed{24}

Compute ϕ(24)\phi(24)

24=23×324 = 2^3 \times 3:

ϕ(24)=24(112)(113)=24×12×23=8\phi(24) = 24\left(1-\tfrac12\right)\left(1-\tfrac13\right) = 24 \times \tfrac12 \times \tfrac23 = \boxed{8}

(The 8 numbers coprime to 24 are 1, 5, 7, 11, 13, 17, 19, 23.)

modular-arithmetic
6short5 marks

Explain the ElGamal cryptographic system for encryption and decryption.

ElGamal Cryptosystem

ElGamal is a public-key (asymmetric) encryption scheme whose security is based on the Discrete Logarithm Problem. It is probabilistic (the same plaintext encrypts to different ciphertexts).

Key Generation

  1. Choose a large prime pp and a generator gg of Zp\mathbb{Z}_p^*.
  2. Choose a private key xx with 1<x<p11 < x < p-1.
  3. Compute the public value y=gxmodpy = g^x \bmod p.
  • Public key: (p,g,y)(p, g, y) Private key: xx.

Encryption (of message mm, where 1m<p1 \le m < p)

  1. Pick a random ephemeral kk with 1<k<p11 < k < p-1.
  2. Compute C1=gkmodpC_1 = g^k \bmod p.
  3. Compute C2=mykmodpC_2 = m \cdot y^k \bmod p.
  • Ciphertext: (C1,C2)(C_1, C_2).

Decryption

Using private key xx:

m=C2(C1x)1modpm = C_2 \cdot (C_1^{x})^{-1} \bmod p

This works because C1x=gkx=ykC_1^x = g^{kx} = y^k, so C2(C1x)1=myk(yk)1=mC_2 \cdot (C_1^x)^{-1} = m\,y^k\,(y^k)^{-1} = m.

Small Example

Let p=11p=11, g=2g=2, private x=3y=23mod11=8x=3 \Rightarrow y = 2^3 \bmod 11 = 8. To encrypt m=7m=7 with k=4k=4: C1=24mod11=5C_1 = 2^4 \bmod 11 = 5, C2=784mod11=74mod11=6C_2 = 7\cdot 8^4 \bmod 11 = 7\cdot 4 \bmod 11 = 6. Ciphertext (5,6)(5,6). Decrypt: C1x=53=1254C_1^x = 5^3 = 125 \equiv 4, inverse of 4 mod 11 is 3, so m=63mod11=18mod11=7m = 6\cdot 3 \bmod 11 = 18 \bmod 11 = 7.

Note: a fresh random kk must be used for every message; reusing kk leaks the plaintext.

elgamal
7short5 marks

Differentiate between block ciphers and stream ciphers. Explain the different modes of operation of block ciphers.

Block Ciphers vs Stream Ciphers

FeatureBlock CipherStream Cipher
Unit of operationFixed-size blocks (e.g. 64/128 bits)One bit/byte at a time
MethodSubstitution-permutation over a blockXOR plaintext with a keystream
Speed/latencySlower, needs full blockFast, low latency
Error propagationHigher (depends on mode)Limited to affected bit(s)
ExamplesDES, 3DES, AESRC4, A5/1, ChaCha20

Modes of Operation of Block Ciphers

Modes let a block cipher securely encrypt messages longer than one block.

  • ECB (Electronic Codebook): each block encrypted independently, Ci=EK(Pi)C_i = E_K(P_i). Simple but identical plaintext blocks give identical ciphertext, leaking patterns - not secure for structured data.
  • CBC (Cipher Block Chaining): Ci=EK(PiCi1)C_i = E_K(P_i \oplus C_{i-1}) with an IV for C0C_0. Identical blocks encrypt differently; errors propagate to two blocks. Encryption is sequential.
  • CFB (Cipher Feedback): turns the block cipher into a self-synchronizing stream cipher; Ci=PiEK(Ci1)C_i = P_i \oplus E_K(C_{i-1}).
  • OFB (Output Feedback): generates a keystream by repeatedly encrypting the IV (Oi=EK(Oi1)O_i = E_K(O_{i-1}), Ci=PiOiC_i = P_i \oplus O_i); no error propagation, but no self-synchronization.
  • CTR (Counter): encrypts an incrementing counter to form a keystream, Ci=PiEK(counteri)C_i = P_i \oplus E_K(\text{counter}_i). Parallelizable and random-access; widely used.
block-stream
8short5 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 and a shared secret key KK that provides data integrity and authentication of origin. The sender computes T=MAC(K,M)T = \text{MAC}(K, M) and sends (M,T)(M, T); the receiver recomputes the MAC and accepts only if the tags match. Anyone without KK cannot forge a valid tag. (Unlike a digital signature, a MAC uses a symmetric key, so it does not provide non-repudiation.)

HMAC (Hash-based MAC)

HMAC builds a MAC from a cryptographic hash function HH (e.g. SHA-256) and a 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)

where:

  • KK' is the key padded/hashed to the hash block size.
  • ipad = the byte 0x36 repeated; opad = the byte 0x5C repeated.
  • \| denotes concatenation.

How it works: the inner hash mixes the (ipad-keyed) value with the message; the outer hash re-keys the result with opad. The nested two-pass construction protects against length-extension attacks that affect plain H(KM)H(K \| M). HMAC is provably secure as long as the underlying hash's compression function is a good PRF, and is used in TLS, IPsec and JWT.

mac
9short5 marks

Explain key management and key distribution in symmetric cryptography.

Key Management and Distribution in Symmetric Cryptography

Key management covers the full life cycle of secret keys: generation, distribution, storage, use, update/rotation, and destruction. In symmetric cryptography both parties share the same secret key, so securely delivering that key is the central challenge.

The Key Distribution Problem

For nn users who all wish to communicate pairwise, (n2)=n(n1)2\binom{n}{2} = \dfrac{n(n-1)}{2} distinct keys are needed, which scales poorly. Keys must reach both parties without exposure to attackers.

Distribution Methods

  1. Manual / physical delivery: key handed over out-of-band (courier, smart card). Secure but not scalable.
  2. Key encrypting key (KEK): a previously shared master key is used to encrypt and transmit fresh session keys.
  3. Key Distribution Center (KDC): a trusted server shares a long-term key with each user and issues short-lived session keys on demand (basis of Kerberos). Reduces the number of long-term keys to nn.
  4. Public-key assisted exchange: use Diffie-Hellman or encrypt the symmetric key under the recipient's public key, then communicate symmetrically.

Good Practice

  • Use session keys (short-lived) rather than reusing one key, limiting exposure.
  • Protect keys in storage (HSMs, key vaults); rotate and revoke keys; destroy expired keys securely.
key-management
10short5 marks

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

Fermat's Little Theorem

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

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

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

Use: primality testing and computing modular inverses (a1ap2(modp)a^{-1} \equiv a^{p-2} \pmod p).

Example: a=3a=3, p=7p=7: 36=729=104×7+13^{6} = 729 = 104\times7 + 1, so 361(mod7)3^{6} \equiv 1 \pmod{7}. ✓

Euler's Theorem

Statement (generalisation of Fermat's): 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 function. When nn is prime, ϕ(n)=n1\phi(n)=n-1 and this reduces to Fermat's little theorem.

Use: it is the basis of the RSA correctness proof and of modular exponentiation reduction.

Example: a=3a=3, n=10n=10, ϕ(10)=4\phi(10)=4: 34=81=8×10+13^{4} = 81 = 8\times10 + 1, so 341(mod10)3^{4} \equiv 1 \pmod{10}. ✓

fermat-euler
11short5 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 provides no authentication of the exchanged public values, so an active attacker (Mallory) positioned between the two parties can mount a man-in-the-middle attack.

Justification

Alice and Bob exchange A=gaA=g^a and B=gbB=g^b over the channel, but neither can verify who actually sent the value they received. Mallory intercepts and substitutes her own values:

  1. Alice -> Mallory: A=gaA = g^a. Mallory sends Bob gmg^m instead.
  2. Bob -> Mallory: B=gbB = g^b. Mallory sends Alice gng^n instead.
  3. Alice computes K1=(gn)a=ganK_1 = (g^n)^a = g^{an} (shared with Mallory, not Bob).
  4. Bob computes K2=(gm)b=gbmK_2 = (g^m)^b = g^{bm} (shared with Mallory, not Alice).

Mallory now shares a separate key with each party, so she can decrypt, read, modify and re-encrypt all traffic transparently. The DLP-hardness of DH does not help, because Mallory never needs to solve a discrete log - she simply uses her own private values.

Why it works / countermeasure

The vulnerability exists only because the public values are unauthenticated. It is prevented by authenticating the exchange: signed/certified public keys, the Station-to-Station (STS) protocol, or running DH inside an authenticated channel (e.g. TLS with certificates).

mim-attack
12short5 marks

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

SHA-2 Family

SHA-2 is a family of cryptographic hash functions designed by the NSA and standardised by NIST (FIPS 180-4). It is built on the Merkle-Damgard construction with a Davies-Meyer compression function and uses modular addition, logical functions, rotations and round constants.

Members of SHA-2

VariantOutput (bits)Block sizeWord sizeRounds
SHA-22422451232-bit64
SHA-25625651232-bit64
SHA-384384102464-bit80
SHA-512512102464-bit80
SHA-512/224, SHA-512/256224 / 256102464-bit80

SHA-224/256 share one algorithm (different IVs and truncation); SHA-384/512 share another (64-bit words, larger blocks).

Differences from SHA-1

AspectSHA-1SHA-2
Digest size160 bits (fixed)224 / 256 / 384 / 512 bits
Rounds8064 (256) / 80 (512)
Internal state5 x 32-bit words8 x 32-bit (or 64-bit) words
SecurityBroken - practical collisions found (SHAttered, 2017)No practical collision attack; considered secure
Word/block options32-bit / 512-bit only32-bit & 64-bit variants

Summary: SHA-2 offers larger and selectable digest sizes, a stronger internal structure (8 working variables, more complex message schedule), and far greater collision/preimage resistance, whereas SHA-1's 160-bit output is now considered cryptographically broken and deprecated.

sha2

Frequently asked questions

Where can I find the BSc CSIT (TU) Cryptography (BSc CSIT, CSC316) question paper 2075?
The full BSc CSIT (TU) Cryptography (BSc CSIT, CSC316) 2075 (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) 2075 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) 2075 paper?
The BSc CSIT (TU) Cryptography (BSc CSIT, CSC316) 2075 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.