RSA Algorithm depends of the difficulty of factoring very large composite numbers. Remember, composite number n is a product of two or more prime numbers. For example for example 4,6,8,9,10,12,15.... are composite numbers. While 2,3,5,7,11,13... are prime numbers. Prime numbers are the root numbers of all other numbers in the universe. 2 is only even prime number and all other prime numbers have to be odd. Prime numbers are only divisible by themselves without leaving any remainder.
The difficulty is finding all of the prime numbers and there are infinite number of prime numbers. Especially, if you are trying to find huge prime numbers of hundred or more digits.
When you select 15, it is easy to guess 3 and 5 as the prime factors of 15. In a strong RSA implementation we will choose much bigger prime numbers p and q such that n = p.q such as the following huge composite number below:
n =
11929413484016950905552721133125564964460656966152763801206748195494305685115033
38063159570377156202973050001186287708466899691128922122454571180605749959895170
80042105263427376322274266393116193517839570773505632231596681121927337473973220
312512599061231322250945506260066557538238517575390621262940383913963
Can you guess what is p and q from this n?
Not so easy, this is the idea.
Now, we have to generate two large prime numbers p and q to determine
n = p.q called common modulus n.
t = (p-1).(q-1) called Euler-Totient number t.
Start by chosing an e such as 3 an easy to use small prime, and d related to e such that following formulas to calculate cenciphered data from aclear data and recover the clear data a from c by using exponent d.
You can find d iteratively from the equality e.d ≡ 1 mod t which can be rephrased as follows "Which d multiplied by e divided by t have a remainder of 1?"
We will call (e,n) our Public Key and (d,n) the secret key or private key.
Alice can publish or send her Public Key (e,n) to Bob to send her his private messages by email and Evil Corp's intelligence officer Eve reading every mail from Evil Corp's POP3/SNMP traffic should not be able to make any sense from the garbled text.
Bob will encipher the his message with the following encryption formula:
c = a e mod n
Finally, Alice will decipher the encrypted message c using the following decryption formula:
a = c d mod n
Simple RSA Example with Small Primes
Let's choose two small primes p=3 and q=11
Therefore, n = p . q = 3 x 11 = 33, the common modulus n=33.
Next, let's find the Euler-Totient number t=(p-1)(q-1)=(3-1)(11-1)=20.
We now choose the smallest possible odd prime number 3 as e and therefore Alice's public key is (3,33) and Alice sends this to Bob with WhatsApp as a different channel where both Alice and Bob trusts.
Alice than sets out the find d from e.d = 1 mod t equality and asks the question which d multiplied by 3 and divided by 20 gives a remainder of 1? This is not very hard to find, 3 x 7= 21 and 21 divided by 20 gives a remainder of 1.
Therefore, Alice's secret key is ( 7, 33 ) and she keeps this private only to be used by Alice to decipher secret message coming to her with her Public Key ( 3,33 )
Alice sends Bob a suggested coding table as follows with WhatsApp.
Eve intercepts SZZNYSZYANYDAXC,Y. MYNZXSCEALYNWIYIEYI.NYECEZYANYEIIE but she can not
make any sense out of this garbled text because she does not have the secret key.
Alice converts this message according to above coding table:
Cryptography with Liberty BASIC : 103 RSA Algorithm
Onur Alver (CryptoMan)Cryptography with Liberty BASIC : 103 RSA Algorithm
RSA ALGORITHM
There is an excellent description about RSA here . https://www.di-mgt.com.au/rsa_alg.html
Step by Step RSA Description
RSA Algorithm depends of the difficulty of factoring very large composite numbers.
Remember, composite number n is a product of two or more prime numbers. For example
for example 4,6,8,9,10,12,15.... are composite numbers. While 2,3,5,7,11,13... are
prime numbers. Prime numbers are the root numbers of all other numbers in the universe.
2 is only even prime number and all other prime numbers have to be odd. Prime numbers
are only divisible by themselves without leaving any remainder.
The difficulty is finding all of the prime numbers and there are infinite number of
prime numbers. Especially, if you are trying to find huge prime numbers of hundred
or more digits.
When you select 15, it is easy to guess 3 and 5 as the prime factors of 15. In a strong
RSA implementation we will choose much bigger prime numbers p and q such that n = p.q
such as the following huge composite number below:
Can you guess what is p and q from this n?
Not so easy, this is the idea.
Now, we have to generate two large prime numbers p and q to determine
n = p.q called common modulus n.
t = (p-1).(q-1) called Euler-Totient number t.
Start by chosing an e such as 3 an easy to use small prime, and d related to e
such that following formulas to calculate c enciphered data from a clear data and
recover the clear data a from c by using exponent d.
You can find d iteratively from the equality e.d ≡ 1 mod t which can be rephrased
as follows "Which d multiplied by e divided by t have a remainder of 1?"
We will call (e,n) our Public Key and (d,n) the secret key or private key.
Alice can publish or send her Public Key (e,n) to Bob to send her his private
messages by email and Evil Corp's intelligence officer Eve reading every mail
from Evil Corp's POP3/SNMP traffic should not be able to make any sense from
the garbled text.
Bob will encipher the his message with the following encryption formula:
c = a e mod n
Finally, Alice will decipher the encrypted message c using the following
decryption formula:
a = c d mod n
Simple RSA Example with Small Primes
Let's choose two small primes p=3 and q=11
Therefore, n = p . q = 3 x 11 = 33, the common modulus n=33.
Next, let's find the Euler-Totient number t=(p-1)(q-1)=(3-1)(11-1)=20.
We now choose the smallest possible odd prime number 3 as e and therefore
Alice's public key is (3,33) and Alice sends this to Bob with WhatsApp as
a different channel where both Alice and Bob trusts.
Alice than sets out the find d from e.d = 1 mod t equality and asks the
question which d multiplied by 3 and divided by 20 gives a remainder of 1?
This is not very hard to find, 3 x 7 = 21 and 21 divided by 20 gives a
remainder of 1.
Therefore, Alice's secret key is ( 7, 33 ) and she keeps this private
only to be used by Alice to decipher secret message coming to her with
her Public Key ( 3,33 )
Alice sends Bob a suggested coding table as follows with WhatsApp.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z . , ? ! _ ( )
Bob sends the following message to Alice:
SZZNYSZYANYDAXC,Y. MYNZXSCEALYNWIYIEYI.NYECEZYANYEIIE
Eve intercepts SZZNYSZYANYDAXC,Y. MYNZXSCEALYNWIYIEYI.NYECEZYANYEIIE but she can not
make any sense out of this garbled text because she does not have the secret key.
Alice converts this message according to above coding table:
19 26 26 14 25 19 26 25 01 14 25 04 01 24 03 28 25 27 31 13 25 14 26 24 19 03 05 01 12 25 14 23 09 25 09 05 25 09 27 14 25 05 03 05 26 25 01 14 25 05 09 09 05
Finally Alice deciphers each number with her secret key (7,33) using the formula :
a = c 7 mod 33
like
a = 19 7 mod 33 = 893871739 mod 33 = 13 which corresponds to letter M
When we calculate all the numbers in the above message we will get:
13 05 05 20 31 13 05 31 01 20 31 16 01 18 09 19 31 03 04 07 31 20 05 18 13 09 14 01 12 31 20 23 15 31 15 14 31 15 03 20 31 14 09 14 05 31 01 20 31 14 15 15 14
When we look at our coding table we obtain the following text message:
M E E T M E AT P A R I S C D G T E R M I N A L T W O O N O C T N I N E A T N O O N
Demonstration Program in Liberty Basic
Cryptography with Liberty BASIC : 103 RSA Algorithm