Cryptography & Network Security: RSA Algorithm, Diffie-Hellman & PKI
Essential cybersecurity concepts, encryption schemes, digital certificates (X.509), and authentication protocols required for government tech officer roles.
In-Depth Interview Questions & Model Solutions
Q1Explain the mathematical foundation of the RSA algorithm and why finding private key d is computationally hard.
RSA relies on the mathematical difficulty of factoring the product of two large prime numbers (Prime Factorization Problem). (1) Key Generation: Choose two large distinct primes p and q. Compute n = p*q and Euler totient φ(n) = (p-1)*(q-1). Choose public exponent e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1. (2) Private Key: Compute d such that (d * e) ≡ 1 (mod φ(n)) using Extended Euclidean Algorithm. Encryption: C = M^e mod n. Decryption: M = C^d mod n. An attacker knowing n and e cannot compute d without finding φ(n), which requires factoring n into p and q.
- Security is based on integer factorization problem.
- Key sizes: 2048-bit or 4096-bit recommended for modern security.
- OAEP padding prevents chosen-ciphertext attacks.
Q2How does Diffie-Hellman Key Exchange establish a shared secret over an insecure channel, and how is Man-In-The-Middle (MITM) prevented?
Diffie-Hellman allows two parties to agree on a symmetric session key without transmitting the secret itself: (1) Alice and Bob publicly agree on prime p and generator g. (2) Alice picks private secret a, sends A = g^a mod p. (3) Bob picks private secret b, sends B = g^b mod p. (4) Shared secret: Alice calculates K = B^a mod p, Bob calculates K = A^b mod p (both equal g^(ab) mod p). Because raw DH lacks authentication, an active attacker can intercept and substitute keys (MITM). Mitigation: Authenticated DH using digital certificates signed by a trusted Certificate Authority (CA) or Ephemeral Diffie-Hellman with RSA/ECDSA (ECDHE).
- Solves Discrete Logarithm Problem (DLP).
- Ephemeral DH (DHE/ECDHE) provides Perfect Forward Secrecy (PFS).
- Requires PKI / Digital Signature for authentication.
Technical Panel Interview Strategy Tips
- In NIC / MeitY interviews, emphasize the difference between Hashing (one-way, e.g. SHA-256), Encryption (two-way), and Encoding (Base64).