Is it possible to leak private key data if attacker control signing request ?
Everyone know $N$ and $E$ because they are public.
My server is designed to decrypt incoming request which is encrypted with public key.
Make sign and for decrypted data which have SHA-2 return back RSA sign for that data.
Is it possible that an attacker can learn my private key?
I am testing this in my local workshop for education purposes.
I am using PKCS#1 public key encrypted message for incoming request; data is decrypted by my private key and its have SHA-2 so I just sign & return back signed data to client.
Example in Python:
Message & key pair generation:
message = struct.pack('>IIII', 0, 0, 0, 1)
(pub, priv) = rsa.newkeys(512) //only for example, I know no one uses 512 bit
Incoming request:
encrypted = pkcs1.encrypt(message, pub)
Server operations:
decrypted = pkcs1.decrypt(encrypted, priv)
signature = pkcs1.sign(decrypted, priv, 'SHA-256')
and return back answer.