Beruflich Dokumente
Kultur Dokumente
1
RSA
• RSA (Rivest, Shamir, Adleman)
– developed in 1977
– only widely accepted public-key encryption alg.
– given tech advances need 1024+ bit keys
2
Creating public/private keys
1. Choose two large prime numbers p, q.
(e.g., 1024 bits each)
e
c = m mod n
4
Decryption
m = cd mod n
5
Implementation
• Write a program implementing RSA public
key encyption algorithm.
• Your program should do 3 activities:
6
Implementation
• Your program should have a GUI.
7
Implementation
• Help user for public and private key selection
– Get 2 prime numbers (p and q) from user
– Check whether they are prime or not
– Calculate n and z (n should be grater than 127)
– Get e from user ( e<n, and e and z are relatively
prime)
– Choose d automatically such that ed mod z = 1
– Write public key as {e, n}
– Write private key as {d, n}
8
Implementation
• Encrypt the given text
– Get public key as {e, n} from user
– Get text string from user
– Encrypt each character by using ASCII code
of each character (convert to a number)
– Write the encrypted text in HEX encoding (4
characters output for each input- put 0 if it is
less than 4 chars).For example:
– Dec: 326 => Hex: 146 => on screen: 0146
9
Implementation
• Decrypt the given text
– Get private key as {d, n} from user
– Get encrypted text string from user as HEX
stream
– Decrypt each character by using ASCII code
of each character (convert to a number)
– Write the plaintext
10
Due date
• Due date: March 26, 2020
11
Hints
e • c = 1;
c = m mod n for (i=0;i< e;i++)
c=c*m%n;
c = c%n;
12
Hints
• To convert a decimal to Hex in c:
value.ToString("X4");
13
Screenshot of an example
program
14
Screenshot of an example
program
15
Screenshot of an example
program
16