RSA Encryption Packet 2
RSA Encryption Packet 2
RSA Encryption Packet 2
n is
e is
just
d is
Encryption
Sender A does the following:1. Obtains the recipient B's public key (n, e).
2. Represents the plaintext message as a positive integer m
[see note 4].
3. Computes the ciphertext c = me mod n.
4. Sends the ciphertext c to B.
Decryption
Recipient B does the following:1. Uses his private key (n, d) to compute m = cd mod n.
2. Extracts the plaintext from the message representative m.
Digital signing
Sender A does the following:1. Creates a message digest of the information to be sent.
2. Represents this digest as an integer m between 0 and n-1.
[See note 5].
3. Uses her private key (n, d) to compute the signature s = md
mod n.
4. Sends this signature s to the recipient, B.
Signature verification
Recipient B does the following:1. Uses sender A's public key (n, e) to compute integer v = se
mod n.
2. Extracts the message digest from this integer.
3. Independently computes the message digest of the
information that has been signed.
4. If both message digests are identical, the signature is
valid.
Summary of RSA
Even though there are more steps in this procedure, the modular
exponentation to be carried out uses much shorter exponents and
so it is less expensive overall.
[2008-09-02] Chris Becke has pointed out that most large integer
packages will fail when computing h if m1 < m2. This can be easily
fixed by computing
h = qInv(m1 + p - m2) mod p
0
0
1
1
2 3 4 5 6 7 8
8 27 31 26 18 13 17
9 10 11 12 13 14 15 16
3 10 11 12 19 5 9 4
m 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
c 29 24 28 14 21 22 23 30 16 20 15 7 2 6 25 32
Using our table above, we obtain ciphertext integers c1, c2, ...
(3,18,19,19,4,30,4,28,19,26)
=
=
=
=
=
For this example, to keep things simple, we'll not worry about
numbers and punctuation characters, or what happens with groups
AAA or AAB.
In this system of encoding, the maximum value of a group (ZZZ)
would be 263-1 = 17575, so we require a modulus n greater than
this value.
1. We "generate" primes p=137 and q=131 (we cheat by looking
for suitable primes around n)
2. n = pq = 137.131 = 17947
phi = (p-1)(q-1) = 136.130 = 17680
3. Select e = 3
check gcd(e, p-1) = gcd(3, 136) = 1, OK and
check gcd(e, q-1) = gcd(3, 130) = 1, OK.
4. Compute d = e-1 mod phi = 3-1 mod 17680 = 11787.
5. Hence public key, (n, e) = (17947, 3) and private key (n,
d) = (17947, 11787).
Question: Why couldn't we use e=17 here?
To encrypt the first integer that represents "ATT", we have
c = me mod n = 5133 mod 17947 = 8363.