Analysis and Use of RSA Keypair Generation Bias

Analysis and Use of RSA Keypair Generation Bias

Analysis and use of RSA keypair generation bias Learning from the discovery, disclosure, and mitigation of vulnerable RSA key generation on smartcards Marek Sýs [email protected] Centre for Research on Cryptography and Security, Masaryk University Joint work with: Petr Švenda, Matúš Nemec, Dušan Klinec, Vasilios Mavroudis, Andrea Cerulli, Dan Cvrček, George Danesis, Peter Sekan, Rudolf Kvašnovský, David Formánek, David Komárek and Vashek Matyáš Credits: Petr Švenda https://crocs.fi.muni.cz @CRoCS_MUNI About lab • Masaryk University, Brno • Smartcards analysis from 2002 • Cryptographic smartcards are pervasive (SIM, EMV, eID, tokens…) • Yet smartcard industry is very closed – NDA just to see detailed specifications, proprietary APIs, no design details… • Security certifications performed by testing labs (FIPS, CC) – But details are not public • Idea in 2014: Infer details using keys similarity to open-source libraries 2 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI https://roca.crocs.fi.muni.cz RSA primer – what does it mean and why should I care? • RSA is widely used public-key cryptosystem (1977) • Used for digital signatures (mail, software distribution, contracts…) • Used for key exchange (HTTPS/TLS, PGP…) • Private part: random primes P and Q, private exponent d • Public part: modulus N,public exponent e (often 65,537) P x Q = N • Factorization attack: compute primes P and Q from the knowledge of N • Problem: How to generate a large prime (1024- or 2048-bit length)? 3 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI 60+ million fresh RSA keypairs 22 sw. libraries 16 smart cards Distribution of primes (MSB) Large factors of p-1 / p+1 Bit stream statistics Number of factors and more… 7 implementation choices observable in public keys (biased bits of public modulus, “mask”) 4 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Input key Precomputed matrix -----BEGIN CERTIFICATE----- MIIG9zCCBd+gAwIBAgIIJOR2wFUwc20wDQYJKoZI hvcNAQELBQAwSTELMAkGA1UEBhMCVVMxEzAR BgNVBAoTCkdvb2dsZSBJbmMxJTAjBgNVBAMTHE dvb2dsZSBJbnRlcm5ldCBBdXRob3JpdHkgRzIwHhc NMTYwNzA2MDgxNzQzWhcNMTYwOTI4MDgwMzA wk2zlQSqmqHS14NRoQD9zPk/rEp4miQ9aVgC6k7i bLukl4cGi5myPc0kCQr8kNUBhH25DS6HpekTmO1s 9q81KbtS2E7+4Q/57xgdghBLiaTEv7O7+gskLQ/qJa TouwiDPM6SHIVU6X2Ca1lNKg2wbx8h2Q63SDIwFJ 52HsNAClKp4ADvjvvImYoWVitcLlhpXogOAzbLz3HIs 6Jk= Classification -----END CERTIFICATE----- 111001010 44% ‘s group 11% ‘s group 9% ‘s group … 5 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Try at https://rsa.sekan.eu 6 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Impact (of the possibility) of public key classification • Information leakage vulnerability 7 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Impact (of the possibility) of public key classification • Information leakage vulnerability • Statistics: current library usage trends RSA key classification (USENIXSec’16, ACSAC’17) 8 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI https://crocs.fi.muni.cz/papers/acsac2017 Internet-wide TLS IPv4 scan public exponent e (often 65,537), 9 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Impact (of the possibility) of public key classification • Information leakage vulnerability • Statistics: current library usage trends RSA key classification (USENIXSec’16, ACSAC’17) EE eID injected keys • Audit: identify source libs in target organization (Arnis Paršovs, 05/2018) 10 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI EE eID injected keys (Arnis Paršovs, 05/2018) Problem reported from Estonia (17.5.2018) • Estonian eIDs generate private key always on chip (by design) – Some keys found to be injected from outside • Found by observed discrepancy in RSA public key properties (MSB) – Expected: MSB {144,145,…,167} – Observed: outside Not generated on chip https://geenius.ee/uudis/id-kaartide-tootja-rikkus-tahtsaimat-turvapohimotet-12-500-tulebMSB-inimestel value -valja-vahetada/ 11 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Impact (of the possibility) of public key classification • Information leakage vulnerability • Statistics: current library usage trends RSA key classification (USENIXSec’16, ACSAC’17) EE eID injected keys • Audit: identify source libs in target organization (Arnis Paršovs, 05/2018) Source of factorable TLS • Forensics: source lib/device of weak keys keys (I. Mironov, 2012) • Quick search for other keys from vulnerable library ROCA vulnerability (ACM CCS’17) 12 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI ROCA vulnerability 13 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI https://roca.crocs.fi.muni.cz But we were unaware on another issue that time Primeexpected = random a PrimeInfineon = k * M + 65537 mod M 14 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Prime generation slow ! - primality tests (modular exponentiation) Algorithms 1. Random sampling – generate & test, generate & test, … – Many iterations – random number has typically small divisors – 50% that 2 is divisor, 33% that 3 is divisor … 2. Incremental search – generate & test, increment & test, increment… – skip numbers with small prime factors – similar methods Joye & Pailier algorithm , “Fast Prime” algorithm (Infineon) 15 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Structure of Infineon primes 푝푟푖푚푒 = 푘. 푀 + 65537푎 푚표푑 푀, 푀 = 2 ∗ 3 ∗ 5 ∗ 7 … . • Entropy loss in prime: Infineon 푘 푎 Determined by 푎 Random Random bits Consequences: • Strong fingerprint of RSA keys • Practical factorization of RSA keys is possible 16 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Detection of vulnerable keys • Based on public modulus 푁 1. Vulnerable if 푐 exists: 푁 ≡ 65537풄 푚표푑 푀 푐푖 2. Equivalent to 푐 exist for all 푝 | 푀: 푁 ≡ 65537 푚표푑 푝 – small 푝⇒ very fast - microseconds • Errors: – False negatives - all Infineon primes have the specific form – False positives - negligible probability (푃푟 < 2−150 ) 17 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Coppersmith’s attack as a black box 1. Modulus 푁 푁 2. Unknown factors 푝, 푞 푝 - unknown * 푞 - unknown 푝 3. Partial knowledge of prime ℎℎ 푝푙표푤 * 푞 - unknown (at least ½ of bits of 풑) coppersmith 4. Apply Coppersmith’s algorithm 푝ℎℎ 18 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI Naïve algorithm (RSA -2048) • 푝 = 푘. 푀 + 65537푎 푚표푑 푀 256 bits • Guess 푎 푎 푘. 푀 + 65537푎 푚표푑 푀 54 bits 970 bits = size of 푀 • compute 푘 using Coppersmith’s alg. (requires ½ of known bits – much more than that – large 푀) • Infeasible – large 푎 19 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI How to make attack practical ? Idea: ½ known (= size of 푀) bits of 풑 is sufficient - smaller 푀′ ⇒ smaller (or equal) 푎′ - 푝 of the same form ⇒ 푀′|푀 푎 푝 = 푘 . 푀 + 65537푎 푚표푑 푀 of size 푀 ½ 푎′ 푝 = 푘′. 푀′ + 65537푎′ 푚표푑 푀′ of size 푀′ 20 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI ROCA in general 21 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI https://roca.crocs.fi.muni.cz Algorithmic flaw in Infineon’s RSALib (CVE-2017-15361) • All keys generated by vulnerable Infineon library are affected • Practical factorization of common lengths 512/1024/2048b (+ others) – Randomly selected 512 and 1024b keys factorized (Masaryk University) – Randomly selected 2048b (Estonian RIA, April 2018, “several thousands euro”) • All public keys have unique “fingerprint” (easy to scan for) – Tool for detection, https://github.com/crocs-muni/roca/ • Tool for factorization (made public by Lange&Bernstein, 5th Nov) – Random 2048b key: 6442450944000000 vCPU years Attack is perfectly parallelizable – Infineon 2048b key: 140 vCPU years 1000 cores => 1000x speedup 22 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI https://roca.crocs.fi.muni.cz Estimated energy-only cost (2017) 3936b Prime = k * M + 65537a mod M 3072b 4096b 2048b, ~$1000 1024b, ~$2 512b, ~¢1 23 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI https://roca.crocs.fi.muni.cz What is the cost of an attack on RSA 2048b (year after)? • Our paper (2017): $20,000 average price on Amazon AWS – Estimate: energy-only price is likely around $1000 • Lange, Bernstein (2017) – 25% faster attack (LLL chaining) – Found in 3 days and without an access to our paper! • Estonian RIA (04/2018): “several thousand euros” energy price • Our work (WAC 2018): algorithmic improvement, 2x faster • Implementation speedups by graphic cards, FPGA… – Not (publicly) tested (typical speed-up factor 3-10x) 24 CA/Browser forum, Bratislava, 20.02.2020 https://crocs.fi.muni.cz @CRoCS_MUNI https://roca.crocs.fi.muni.cz Responsible disclosure I. • (NIST responsible disclosure guidelines followed) • End of January 2017: Proof of Concept attack (1024b keys factorized) • Feb 1st: Infineon notified (email to contact at crypto group) • Mid May: First Infineon’s customers contact us back for verification • Jun 20th: Incident report ID 163484, Austria eHealth certs revoked – eIDAS regulation and Article 19 – Countries around Europe should have been notified – BUT: unspecific third party failure, concrete vendor named (but not Infineon) 25 CA/Browser forum, Bratislava, 20.02.2020

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    31 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us