PV181 Laboratory of security and applied cryptography Part 3, seminar 8: Advanced Topics Łukasz Chmielewski chmiel@fi.muni.cz | PV1811 Outline • Finishing the last week’s exercises (10min) – Optional task discussion • Recall from the last seminars – We concentrate on signatures • RSA, RSA-CRT • DSA, ECDSA • Efficiency • Post Quantum 2 | PV181 Finishing the last week’s exercises • Anything before Task 6? • Task 6 and 7… • Email encryption – Assignment 7 3 | PV181 Tasks 6 & 7: • Both are doable but mathematically not trivial for arbitrary e.. – For a complete solution see: Handbook of Applied Cryptography (chapter 8, section 8.2.2, page 287). Link: https://cacr.uwaterloo.ca/hac/ • However e is normally small: e=0x010001=65537 • Therefore, the following attack is possible for d, n, and e known: 1. We have eꞏd = kꞏ𝜑 𝑛 + 1 for some integer k. Since d < 𝜑 𝑛 , we know that k < e. So you only have a small number of k to try to get 𝜑 𝑛 . • Note that 𝜑 𝑛 ≈ 𝑛 or at least most significant bits. • For small e: k'=round(ed/n). k' is very close to k (i.e. |k'-k| <= 1). 2. Given k, you easily get 𝜑 𝑛 = (ed-1)/k. 3. Now 𝜑 𝑛 = (p-1)(q-1) = n + 1 - (p+q). Thus, you get p+q = n + 1 - 𝜑 𝑛 . • So we have p+q and n=pꞏq. • Note that for all real numbers a and b, a and b are the two solutions of the quadratic equation X2-(a+b)ꞏX+aꞏb=0. 4. Compute: … 4 | PV181 Tasks 6 & 7 cont’d 4. Compute: • p = ((p+q) + (p+q)2 − 4ꞏpq) / 2 • q = ((p+q) - (p+q)2 − 4ꞏpq))/2 • Easier way, there is a function to compute p and q from (n,e,d): – cryptography.hazmat.primitives.asymmetric.rsa.rsa_recover_prime_factors(n,e,d) • For dp=d (mod p), n, and e known, the attack is easier: – dp ≤ d < 𝜑 𝑛 – eꞏdp = 1 (mod (p-1)) and therefore eꞏdp = kꞏ(p-1) – k_hw8.zip. Put there both the python code and the analysis document. • It must contain comments so that it is reasonably easy to understand how to run the script for evaluating each answer. 30 | PV181 Assignment 8 - Tasks 1. Using hazmat implement the following signature schemes: RSA, DSA, ECDSA. In particular, implement key generation, signature generation, and signature verification. [2 points] 2. Implement HMAC with SHA2 and SHA3. All implementations should be in one file. [1 point] 3. Implement all the above schemes for taking input from a file (e.g., attached alice.txt). Make sure all your code works for large files (larger than your RAM). [2 points] 4. Perform an efficiency comparison analysis for RSA, DSA, ECDSA, HMAC-SHA2, and HMAC-SHA3. For the signature schemes’ parameters see the following slide. Analyze key generation, signature generation, and signature verification separately. Write a summary of your results, which primitive seems to be the best, and for which use case. Attach such a summary to your exercise submission. [4 points] Remarks: (1) For the sake of computational time, use a small message to be signed. The same message should be used for all comparisons. For the comparison also use the same hash function (once SHA2 and once SHA3). (2) For HMAC use the key size suggested by the symmetric crypto column in the next slide. (3) For DSA just specify the larger prime number (p). The smaller prime number (q) will be chosen automatically. (4) By “use case”, I mean the a scheme, for example, some algorithms are slow but have fast verification which might make them suitable for some applications. 5. Additionally, analyze whether varying the private key affects the algorithms’ execution time (or the corresponding standard deviations of algorithms’ execution time). Please comment on the results (what could be the reason for the observed results). [1 points] Good luck!!! 31 | PV181 Assignment 8 – extra info 32 | PV181