Answer the question
In order to leave comments, you need to log in
RSA 576 bit how to decrypt?
Good day, I need help deciphering the text or an indication of an error in completing the task, I am going through a challenge on the root-me.org website, where the public key and ciphertext are given:
-----BEGIN PUBLIC KEY-----
MGQwDQYJKoZIhvcNAQEBBQADUwAwUAJJAMLLsk/b+SO2Emjj8Ro4lt5FdLO6WHMM
vWUpOIZOIiPu63BKF8/QjRa0aJGmFHR1mTnG5Jqv5/JZVUjHTB1/uNJM0VyyO0zQ
owIDAQAB
-----END PUBLIC KEY-----
e8oQDihsmkvjT3sZe+EE8lwNvBEsFegYF6+OOFOiR6gMtMZxxba/bIgLUD8pV3yEf0gOOfHuB5bC3vQmo7bE4PcIKfpFGZBA
from Crypto.PublicKey import RSA
key = RSA.importKey(open('pubkey.pem').read())
print('n = ',key.n)
print('e = ',key.e)
def egcd(a, b):
x,y,u,v = 0,1,1,0
while a != 0:
q, r = b // a, b % a
m, n = x - u * q, y - v * q
b,a,x,y,u,v = a,r,u,v,m,n
return b, x, y
def modinv(e, m):
g, x, y = egcd(e, m)
if g != 1:
return None
else:
return x % m
def pqe2rsa(p, q, e):
n = p * q
phi = (p - 1) * (q - 1)
d = modinv(e, phi)
key_params = (int(n), int(e), int(d), int(p), int(q))
priv_key = RSA.construct(key_params)
with open('privkey.pem', 'wb') as f:
f.write(priv_key.exportKey())
-----BEGIN RSA PRIVATE KEY-----
MIIBXwIBAAJJAMLLsk/b+SO2Emjj8Ro4lt5FdLO6WHMMvWUpOIZOIiPu63BKF8/Q
jRa0aJGmFHR1mTnG5Jqv5/JZVUjHTB1/uNJM0VyyO0zQowIDAQABAkgyAw5Cxp1O
d95+I5exPbouUvLFeiBfWXP+1vh2MvU8+IhmCf9j+hFOK13x22JJ+Orwv1+iatW4
5It/qwUNMvxXS0RuItCLp7ECJQDM6VRX8SfElUbleEECmsavcGBMZOgoEBisu1OC
M7tX83puaJUCJQDzXLgl8AM5bxHxSaWaD+c9tDFiyzBbjr/tpcqEC+JMU2tqrlcC
JQCjGt8+GQD0o3YJVc05i4W3RBYC+RcqPJXHeFyieRcYjP/ZPnkCJQDVUULBTl8l
KuzJWcrk/metuJNJi925g6lMwHSBxoD4cm7HtkUCJFqWTOzCIODw7eoypcJYjm2O
/ohEsSjEXsg6Bh8mY3LunBaqiA==
-----END RSA PRIVATE KEY-----
openssl rsautl -decrypt -in ciphertext -out text -inkey privkey.pem
Answer the question
In order to leave comments, you need to log in
I found the answer as follows, maybe I didn’t copy the factorization from Wikipedia correctly, transferred it to the code, recompiled everything and decrypted it using https://8gwifi.org/rsafunctions.jsp of this service. The answer turned out to be: up2l6DnaIhZgxA
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question