PV181 Laboratory of security and applied cryptography Part 3, seminar 10: Advanced Topics Łukasz Chmielewski chmiel@fi.muni.cz | PV1811 Outline • Organizational • Finishing Seminar’s 3 exercises (10min) – Discuss the most common issue in the solutions – Optional task discussion • Recall from the last seminars – We concentrate on signatures • RSA, RSA-CRT • DSA, ECDSA • Efficiency • Post Quantum 2 | PV181 Organization • 22.11 Advanced Crypto by Lukasz +HW • 29.11: Biometrics by Agata & Katarina +HW • 6.12: Crypto-libraries protected against hardware attacks by Lukasz +HW • 13.12: Passwords Security by Alessia and Lukasz +HW 3 | PV181 Issues in Solutions • Multiple OS, libraries, OpenSSL versions – In some cases even if you tell me the details, I cannot run it easily. Let’s double-check the code together. • Encryption of large files: – Encrypting line by line; line length might be very long – Encrypting chunks of files separately • they can be re-reordered – Forgetting to run finalize after encryption. 4 | PV181 Finishing Seminar 3 last tasks • demo.py • Tasks 6 and 7… – Did anyone try to do it? 5 | 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: … 6 | 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_hw7.zip. Put there both the python code, the analysis document, and all data produced during analysis (as long as the size is reasonable). • The code must contain comments so that it is reasonably easy to understand how to run the script for evaluating each answer. 33 | PV181 Assignment 7 - 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. To have reliable results, perform operations a number of times and average results. [4 points] Remarks: (1) For the sake of computational time, use a small message (e.g., a text file) 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 a scheme, for example, some algorithms are slow but have fast verification, which might make them suitable for some applications. 5) Include file reading in signature generation time. 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 point] 6. Bonus: perform a similar analysis to point 4 for a larger file (approximately 100Mb) What is the difference here? What could be the reason of the change (if any)? [1 point] Good luck!!! 34 | PV181 Assignment 7 – extra info 35 | PV181