Implementation of digital signature using RSA
- Crypto - https://pypi.python.org/pypi/pycrypto
- gmpy2 - https://pypi.python.org/pypi/gmpy2
- We take the user input for message
- First, we generate two random prime numbers p and q of 512 bit length.
- We calculate n = p * q
- We calculate Φ(n) = p-1 * q-1
- We calculate e, such that gcd(e, Φ(n)) = 1
- We calculate d, such that e * d = 1 mod Φ(n)
- We calculate the message digest using SHA-224, M
- We encrypt the message digest using senders public key CT = M^d mod n.
- We send the M+S to receiver and (e, n) is made known to public.
- We first separate the message from encrypted message digest
- We then decrypt the message digest using sender public key S'= M^e mod n.
- We then calculate the message digest of the message using SHA-224, M'
- If M' = S', then the sender is indeed the real sender and the message is not been tampered with.