We show a high–level though working description of RSA. Then, we give an example with easy to work with numbers.
To initialise RSA, follow the steps
Pick two large primes, p and q.
Find N = p * q. N is the RSA modulus.
Let e be a number relatively prime to (p-1)*(q-1).
Find d, so that d*e = 1 mod (p-1)*(q-1) .
The set (e, N) is the public key. Make it known to every one.
The set (d, N) is the private key. Keep it private and safe.
To encrypt a message m,
Make sure m < N, otherwise chop m in suitably small pieces and perform RSA on each individual piece.
Compute c = m ^ e mod N
c is the encrypted message
To decrypt a ciphertext c,
Compute m = c ^ d mod N
m is the original message
To sign message m,
Compute s = m ^ d mod N
s is the digital signature. Send along with message m.
To verify signed message s,
Compute m = s ^ e mod N
Check if m from above calculation is the same with message sent.
TODO