Cryptanalysis and Security Proofs Questions
Evaluating the strength of cryptographic constructions: attack techniques, cryptanalysis of ciphers and protocols, reduction-based security proofs, and formal analysis. Covers reasoning about what an adversary can and cannot do and how security guarantees are argued rigorously. The offensive-and-verification counterpart to scheme design.
Explain the meet-in-the-middle attack on double-DES (ciphertext C = E_{k2}(E_{k1}(P))). Derive the time and memory complexity in terms of single-DES key size k=56 and show the numeric work factor and memory requirement. Explain why double-DES was not considered secure and how 3DES addresses the issue.
Sample Answer
Direct answer
Stacking two independent 56-bit DES keys as C = E_k2(E_k1(P)) looks like it should give 112 bits of security, but a meet-in-the-middle (MITM) attack, one that attacks from both ends of the computation at once instead of guessing the whole key pair, breaks it in only about 2^57 time and 2^56 memory. That is barely more work than breaking single DES, which is exactly why double-DES was never adopted and why triple-DES (3DES, using a third independent key) became the real fix.
Structured elaboration
Given one known plaintext/ciphertext pair (P, C):
- Forward pass: for every candidate k1 (all 2^56 values), compute X = E_k1(P) and store the pair (X, k1) in a lookup table, sorted or hashed by X.
- Backward pass: for every candidate k2 (all 2^56 values), compute Y = D_k2(C) and check whether Y appears in the table. Any match (X == Y) gives a candidate key pair (k1, k2) satisfying E_k2(E_k1(P)) = C for this one plaintext/ciphertext pair.
- Because a single pair produces many false-positive matches by chance, confirm each candidate against a second known plaintext/ciphertext pair, which quickly eliminates all but the true key pair.
Total time: roughly 2 x 2^56 = 2^57 operations (one pass to build the table, one to probe it), instead of the naive 2^112 needed to brute-force every key pair directly. Total memory: about 2^56 stored table entries, which turns out to be the real bottleneck.
Worked example
Time: 2 x 2^56 = 2^57 ≈ 1.44 x 10^17 single-DES operations, versus a naive brute force of 2^112 ≈ 5.19 x 10^33 key-pair trials, a reduction of about 17 orders of magnitude in time.
Memory: 2^56 ≈ 7.21 x 10^16 entries; at roughly 16 bytes per entry (a 64-bit ciphertext block plus a 56-bit key, with indexing overhead), that is about 1.15 x 10^18 bytes, on the order of an exabyte. This is genuinely large, but well within reach of a well-funded adversary as storage costs fall, and it does not require anywhere near 2^112 time, which is the entire point: MITM shows double-DES's real security sits close to single DES's 2^56, not the naively expected 2^112.
Trade-offs and pitfalls
A common wrong turn is looking at 2^57 in isolation and concluding "that's still huge, so double-DES is fine." The relevant comparison is not to zero, it is to the intended 112-bit target: MITM shows the actual margin is barely one bit better than single DES. Triple-DES fixes this by adding a genuinely independent third key (encrypt-decrypt-encrypt with three keys); the same MITM trick against 3DES would need to search a much larger combined space, restoring most of the intended margin (2-key 3DES is generally estimated at only about 80 bits of practical security against known attacks, still well short of the naive 112, which is one reason NIST now treats 3DES itself as deprecated legacy technology, recommending AES for any new system rather than any variant of DES.
Describe how you would convert a theoretical attack cost (for example 2^{60} operations and 128 GB memory) into a real-world feasibility assessment. Include considerations such as attacker parallelism, memory distribution, hardware & electricity cost, logistics of acquiring hardware, time-to-completion, and how to present risk to non-technical stakeholders.
Sample Answer
Direct answer
A raw complexity figure like "2^60 operations, 128 GB memory" tells you almost nothing about real-world risk on its own. Converting it into an actionable assessment means pinning down a realistic hardware throughput assumption, computing wall-clock time and dollar cost from that assumption, checking whether the memory requirement is a genuine bottleneck or something that parallelizes cleanly, and then translating the result into terms a non-technical stakeholder can weigh against a business decision, a specific dollar figure and timeframe under stated assumptions, never a bare exponent.
Structured elaboration
- Attacker parallelism: is the workload embarrassingly parallel, like brute force, where each unit works an independent slice, or does it need shared, growing state, like one giant sorted table, that resists easy distribution? Parallel work divides wall-clock time roughly linearly with machine count; non-parallel work does not.
- Memory distribution: 128 GB might comfortably fit on one server today, but if the real attack needs 128 GB PER PARALLEL WORKER rather than shared, the total footprint multiplies by worker count and can become the actual bottleneck instead of the operation count.
- Hardware and electricity cost: pick a concrete throughput-per-dollar and power-draw assumption for the hardware class actually suited to the workload (general CPU vs GPU vs custom ASIC, since purpose-built silicon is often 100 to 1,000 times cheaper per operation), then multiply by the operation count and a stated electricity rate to get a total dollar figure.
- Hardware acquisition logistics: can an attacker actually buy or rent this much compute quickly (cloud spot capacity, ASIC lead times, export controls), or does it require years of custom fabrication and warehouse space? This changes whether the threat is "a well-funded criminal group next month" or "a nation-state over several years."
- Time-to-completion: state the wall-clock duration explicitly under the chosen hardware assumption, and how it scales down with more budget.
- Presenting risk to non-technical stakeholders: translate the final numbers into business-relevant framing, for example "under these stated assumptions this would cost roughly $X and Y months for an attacker with Z resources," always naming the assumptions rather than presenting one deceptively precise figure, and being explicit that estimates should be treated as an upper bound on required attacker sophistication, since cheaper attacks tend to be discovered later, not more expensive ones.
Worked example
Take the example given, 2^60 operations and 128 GB memory, with an explicitly stated hardware assumption: a cluster delivering a combined 10^11 (100 billion) operations per second.
Tseconds=1011260≈10111.153×1018≈1.153×107 seconds≈133.5 days≈0.37 yearsThis number is only as good as the stated 10^11 operations/second assumption, a plausible mid-size GPU-cluster figure for many cryptographic operations; the SAME 2^60-operation attack could complete in hours on a large dedicated ASIC farm, or take years on a single laptop. A real feasibility assessment shows the number under a couple of clearly different, explicitly stated hardware assumptions, rather than one unexplained figure presented as fact.
Trade-offs and pitfalls
A common wrong turn is presenting the raw exponent to a non-technical stakeholder ("2^60 operations") without translation; it either sounds meaninglessly abstract or gets anchored to whatever the listener's gut feeling about "a big number" happens to be. Another common wrong turn is picking an unrealistically weak, or unrealistically strong, hardware assumption to make the risk look however the presenter wants; always state the assumption explicitly and, where possible, anchor it to a real public benchmark or a documented prior attack's resources rather than inventing one.
Explain the birthday paradox and why generic collision search against an n-bit hash function requires about 2^{n/2} evaluations. Compute approximate expected work to find a collision for n=128 and n=256, and discuss practical implications for choosing hash output size in modern systems.
Sample Answer
Direct answer
The birthday paradox says that among random samples drawn from N equally likely outcomes, you only need about sqrt(N) samples before two of them collide, far fewer than the N/2 that intuition suggests. For an n-bit hash function with N = 2^n possible outputs, this means generic collision search costs about 2^(n/2) hash evaluations no matter how the hash is designed internally: it is a structural limit, not a weakness of any particular construction.
Structured elaboration
With k random samples, the probability that at least one pair collides is approximately:
P(collision)≈1−e−k2/2NSetting this to 0.5 and solving gives the classic birthday bound:
k≈1.1774N=1.1774⋅2n/2so roughly 2^(n/2) evaluations, not 2^n, are needed to find a collision with even odds. This matters because it caps collision resistance well below preimage resistance for the same output size: finding a hash output that matches one SPECIFIC target still costs about 2^n (you are not helped by the birthday effect when only one target exists), but finding ANY two inputs that collide only costs about 2^(n/2). An n-bit hash therefore never offers more than n/2 bits of collision resistance, even in the best possible design.
A memory-efficient variant worth naming: Pollard's rho style parallel collision search with distinguished points still costs about 2^(n/2) time but needs only small, roughly constant memory instead of storing every sample, which is why collision search is considered practical at moderate n even without huge storage budgets.
Worked example
For n = 128: 2^(128/2) = 2^64 ≈ 1.84 x 10^19 evaluations.
For n = 256: 2^(256/2) = 2^128 ≈ 3.40 x 10^38 evaluations.
This is exactly why MD5 (128-bit output, generic 2^64 collision bound) and SHA-1 (160-bit output, generic 2^80 collision bound) were both retired as collision-resistant hashes, though not because raw compute simply caught up to those generic bounds: both were broken by cryptanalysis finding a structural shortcut well BELOW the generic bound, not by brute-force reaching it. Wang et al.'s 2004 differential attack found MD5 collisions in minutes on ordinary hardware, far cheaper than 2^64. The 2017 SHAttered attack found a real SHA-1 collision using about 2^63.1 SHA-1 evaluations (reported as roughly 6,500 CPU-years plus 100 GPU-years of compute), a huge computation in absolute terms but still roughly 120,000x cheaper than the naive 2^80 generic bound (2^80 / 2^63.1 = 2^16.9 ~ 1.2 x 10^5), because it exploited a differential path through SHA-1's compression function rather than searching blindly. Both breaks are a reminder that the birthday bound is a ceiling on what a well-designed hash forces an attacker to pay, not a floor every hash automatically delivers: a hash with real cryptanalytic weaknesses can fall far below it. SHA-256's 256-bit output, giving a generic 2^128 collision bound with no known shortcut anywhere near that scale, is the reason it replaced them for anything needing collision resistance, since 2^128 evaluations remains far beyond any realistic compute budget.
Trade-offs and pitfalls
The most common mistake is conflating "n-bit hash" with "n-bit security" across the board. If an application only needs preimage resistance (for example, reversing a single stored hash), the full 2^n generic bound applies and n bits may be enough. If it needs collision resistance (digital signatures, deduplication, content-addressed storage, anywhere two different inputs producing the same hash is a real problem), you must budget for the n/2 bound instead, which is why "128-bit security" claims for a hash function almost always mean a 256-bit output, not a 128-bit one.
Explain how you would distinguish a theoretical cryptographic weakness (e.g., best-published attack complexity slightly below brute force) from a practically exploitable weakness in an in-use protocol. List at least five criteria or heuristics you would evaluate and describe one empirical test you could run to validate practical exploitability.
Sample Answer
Direct answer
A theoretical weakness, a published attack complexity slightly below brute force, only becomes a practically exploitable one once you check it against real deployment constraints: the attacker capability it actually assumes, the amount of data or queries it needs, the absolute size of the resulting complexity number, and whether the exact oracle or side channel it relies on genuinely exists in the target system. The fastest way to validate this empirically is to actually implement the published attack against a scaled-down or realistic reproduction of the real target and measure whether it behaves as claimed, rather than trusting the asymptotic complexity figure alone.
Structured elaboration
At least five criteria to evaluate, given here as seven for completeness:
- Attacker capability match: does the published attack assume a capability, such as chosen-ciphertext access, related-key access, or many adaptive queries, that the real deployment actually grants an attacker, or is it a capability no realistic attacker in this system could ever obtain?
- Required data or query volume vs realistic limits: does the attack need, say, 2^40 chosen plaintexts under one key, and does the real protocol ever let one key produce that many messages before rotating? An attack needing more data than the system will ever generate under one key is not practically exploitable there.
- Absolute complexity, not just "below brute force": an attack at 2^126 instead of an ideal 2^128 is still practically infeasible; "below brute force" only matters once it crosses into an actually reachable range, calibrated against known real compute budgets.
- Constants and hidden factors: asymptotic notation hides real multiplicative constants and memory requirements; a formally sub-exponential attack can remain computationally or memory-infeasible at the parameter sizes actually deployed.
- Whether the deployment actually exposes the needed oracle or side channel: many published attacks assume an oracle, such as a padding-error distinguishing signal or precise timing measurement, that a specific real implementation may or may not expose; check the actual system rather than assuming the abstract protocol description grants it.
- Reproduction against a real or realistic implementation: has anyone actually run the attack end to end against a live or faithfully reproduced target and measured real resource use, or does it exist only as an asymptotic claim in a paper?
- Independent confirmation or peer scrutiny: has the result been reproduced or reviewed by others? A single, not-yet-reviewed claim deserves more skepticism before it changes deployment decisions.
Empirical test to validate practical exploitability: implement, or obtain a reference implementation of, the published attack, and run it against a scaled-down instance of the real target (a smaller key or parameter size, same algorithm and structure) small enough that the FULL attack can actually complete on available hardware. If it behaves as the paper predicts at that reduced size, recovering the key, forging a tag, or distinguishing as claimed with the predicted resource use, that is strong empirical evidence the underlying mechanism is real and will scale, rather than trusting the asymptotic formula alone. Separately, instrument the actual target system for the SPECIFIC oracle or side channel the attack needs (for example, timing real server responses) to confirm the required leak genuinely exists in this deployment, not just in the abstract protocol description.
Worked example
Walking a real published result type through the criteria: related-key attacks against AES-192 and AES-256 achieve complexities meaningfully below the ideal brute-force bound, but only under a related-key attacker model, where the attacker can request encryptions under keys mathematically related to the target key. Applying the criteria: (1) essentially no real AES deployment ever derives one key from another in a way that grants an attacker related-key access, so this fails criterion 1 immediately; (3) even setting that aside, the resulting complexity remains far outside any reachable compute budget, failing criterion 3 as well. So despite being a genuine, published, peer-reviewed cryptanalytic result, it has essentially zero practical deployment impact for ordinary AES usage, exactly the theoretical-versus-practical gap this question is about.
Trade-offs and pitfalls
A common wrong turn is treating "peer-reviewed and published" as equivalent to "operationally urgent"; most cryptanalytic advances stay purely academic for years, or forever, because they fail one or more of the criteria above. The opposite wrong turn is equally dangerous: dismissing a real published attack as "just theoretical" without actually checking the criteria against the specific deployment, since some results initially waved away as impractical later turned out to be genuinely devastating once someone actually implemented and tested them against a real target.
Estimate the time required to brute-force symmetric keys of length 56, 80, 112, and 128 bits on a machine that can test 1e9 keys per second. Provide results in seconds, days, and years, and briefly discuss how parallelization or specialized hardware changes these estimates.
Sample Answer
Direct answer
Exhaustive key search over an n-bit keyspace costs up to 2^n trial operations (2^(n-1) on average before success), so dividing the keyspace size by the attacker's throughput gives wall-clock time directly. At 1e9 keys per second, a 56-bit key falls in about a day, an 80-bit key takes tens of millions of years, and 112- or 128-bit keys push into numbers vastly beyond the age of the universe for a single machine at this rate. Every extra key bit doubles the required work, which is why these numbers grow so explosively.
Structured elaboration
The governing relationship, worst case (exhaustive search of the full space):
Tseconds=R2nwhere R is keys tested per second. The average case (expected time to find the one correct key, searching in a random order) is half that. All results below use one consistent basis: seconds, converted to days by dividing by 86,400, then to years by dividing by 365.25.
Brute force is embarrassingly parallel: each machine searches a disjoint slice of the keyspace, so P independent machines at the same per-machine rate divide the total time by P almost exactly. Specialized hardware (ASICs, FPGAs) also matters far more than raw machine count: the EFF's 1998 Deep Crack machine, a purpose-built ASIC design, broke a 56-bit DES key in under three days using hardware that would look unremarkable a decade later, demonstrating that "impractical for a lone attacker on commodity CPUs" is very different from "impractical for an adversary willing to invest in custom silicon."
Worked example
At R = 1e9 keys/second, worst-case (full exhaustive search) times:
| Key size | Keyspace (2^n) | Seconds | Days | Years |
|---|---|---|---|---|
| 56 bits | 7.21 x 10^16 | 7.21 x 10^7 | ~834 | ~2.28 |
| 80 bits | 1.21 x 10^24 | 1.21 x 10^15 | ~1.40 x 10^10 | ~3.83 x 10^7 |
| 112 bits | 5.19 x 10^33 | 5.19 x 10^24 | ~6.01 x 10^19 | ~1.65 x 10^17 |
| 128 bits | 3.40 x 10^38 | 3.40 x 10^29 | ~3.94 x 10^24 | ~1.08 x 10^22 |
(Average-case time, if you only need to search until the actual key is found rather than the whole space, is exactly half of every figure above, on the same basis.)
Trade-offs and pitfalls
Notice the scale jump between 80 and 112 bits: 80-bit keys are firmly within reach of a sufficiently resourced attacker over realistic timeframes, while 112 bits (2-key 3DES territory) sits at the edge of adequate margin and 128 bits (AES-128) remains solid. A common mistake is assuming more hardware erodes security proportionally; it does not, because keyspace grows exponentially while hardware only scales resources linearly (or with parallel machine count). A million-fold increase in an attacker's compute buys only about 20 bits of effective security reduction (log2(1,000,000) ≈ 19.9), which is why 128-bit keys stay comfortably out of reach even against enormous, well-funded compute budgets, while 56- and 80-bit keys do not.
Unlock Full Question Bank
Get access to all 6 Cryptanalysis and Security Proofs interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.