- Setup message(M) for encryption (Convert message to integer)
- Public key{n,e}, e: exponent
- Get cipher C = π^π πππ π using powMod function
- Private key{p,q}
- Compute n, n=p*q
- Compute Ξ¦(n)=(p-1)*(q-1)
- We know that e.d=1 mod Ξ¦(n) so get d as the inverse of e mod Ξ¦(n)
- M=πΆ^π πππ π
- We used socket programming.
- At the sender, we initialize a host and port and then begin listening waiting for the receiver.
- At the receiver, it makes the private key{p.q}, generate exponent, connect with the sender with its host and port, and first send the public key{n,e}, where n=p*q so that the sender could send the messages encrypted using the public key. The receiver waits for the sender to send messages so it can decrypt them.
- Whenever the sender gets a connection, it receives the public key and then uses it to encrypt messages and send them to the receiver.
The attack goal is to retrieve the original plain-text message by getting the key value. It depends on factorizing the public key βnβ. The Algorithm is as follows:
- To know the first prime(p), try numbers from 2 until n
- Take p whenever two conditions are satisfied: a. n is divisible by p b. p is a prime number
- Get the second prime(q) where q=n//p
- Decrypt the cypher the attacker has with the attacker generated private keys(p&q), to get a message
- Encrypt this message, to get cypher text
- Compare the attacker generated cypher with the original cypher, if they meet then those were the correct private keys, and the message in step 4 is correct.
- If itβs not correct, repeat from step 2 until it finds the correct message or it reaches n and couldnβt know the message.
The attack goal is to retrieve the original plain-text message regardless of the key value. The Algorithm is as follows:
- Intercept the communication between two entities.
- Choose random integer number βrβ
- Encrypt βrβ with the RSA public key as π^π πππ π
- Multiply the encrypted r with the received ciphertext modulo n to get (π^π) * (π^π) πππ π
- Send the result to the right entity.
- The entity responds with (π^π * π^π)π πππ π
- Knowing that ed=1 mod Ξ¦(n), this gives that the received message is actually Mr modn
- Divide it by the randomly generated number βrβ to obtain the original message.
To run RSA, CCA, MA, use:
python main.py input_file="input.txt" --output_file="output.txt"
if it gives error then use python3 instead of python
To run the communication, open two terminals, then write in order:
python sender.py
python receiver.py 256
write in the sender terminal and see the message in the receiver terminal.