Crypto- Symmetric RSA
Who needs public keys? - w0152
Challenge
#!/usr/bin/env python3
from Crypto.Util.number import long_to_bytes as ltb, bytes_to_long as btl, getPrime
p = getPrime(1024)
q = getPrime(1024)
n = p*q
e = p
with open("flag.txt", "rb") as f:
PT = btl(f.read())
CT = pow(PT, e, n)
print(f"{CT = }")
for _ in range(4):
CT = pow(int(input("Plaintext: ")), e, n)
print(f"{CT = }")We are given the ciphertext and 4 chances to encrypt by the server, but no modulus.
Additionally, they use e=p instead of 65537 which allows for some interesting exploits.
First, we need to find the modulus, which we can do by simply giving -1 as input and adding 1
We actually have enough information to decrypt using univariate coppersmith. This approach is used to solve the next part, however in this part, we opt for the simpler method of finding p instead
From Fermat's Little Theorem, we have
for some arbitrary k1
If we can find k*p, then gcd(k*p,n) yields p
The server outputs a^p (mod n), so we multiply by a^-1 which gives is a^p-1 (mod n)
for some arbitrary k2
We can find p by gcd(i2-1,n) and find phi(n)
Last updated