Challenges › Cryptography

Inspect Weak RSA Keys

medium · 100 XP · flag · free · solves: 0

Northgate Records made three RSA certificates for its relay, ledger and archive servers. An audit suspects that the key generator reused a prime.

Each certificate is in PEM (relay.pem, ledger.pem, archive.pem) and DER (.der) form. All keys use e = 65537. archive-message.json holds a textbook RSA ciphertext c = m^e mod n for the archive key, with no padding. The message m is UTF-8 text read as one big-endian integer.

  1. Extract n and e from each certificate. loading-reference.txt shows the OpenSSL and Python commands.
  2. Compute the GCD of each pair of moduli. Find the two certificates that share a prime p.
  3. Factor the archive modulus and compute d = inverse(e, (p - 1)(q - 1)).
  4. Decrypt the message with m = c^d mod n and convert m to bytes.

Check your work with python3 verify.py --prime P --certs NAME NAME --d D --message "TEXT". It checks the shared prime, the certificate pair, the archive private exponent and the full message. The verifier and the Python examples need the cryptography package.

The message ends with a restore phrase. Submit CSEMA{...} with the recovered phrase in place of the dots.

Tags: learn

Try next