Document 10490701

advertisement
Math 482, Spring 2013 RSA Encoding Chelsea Hawryluk RSA encryption is a method of encoding alphanumeric symbols into a
string of numbers that can be sent safely across the Internet and
decoded by a second party. The RSA method was developed in 1978
by Rivest, Shamir, and Adleman while studying at MIT and is
considered to be a relatively safe method of encoding because if the
difficulty of breaking down of the encryption key.
The RSA algorithm requires a public and private key, also
known as an encryption and decryption key, that are created from a
number N. N is computed with two large, relatively prime numbers
that are multiplied together. We denote the primes used as p and q,
meaning that N=PQ. We can used choose a p and q and then use
the Euclidean algorithm to test for the greatest common divisor of two
integers to confirm that the integers are prime. In pseudo-code the
Euclidean algorithm can be represented by
Fermat’s Factorization Algorithm
Input: A positive odd integer n
Step1.
𝒙 = 𝒏 π’Šπ’‡ 𝒙 = π’πŸ 𝒕𝒉𝒆𝒏 𝒙 π’Šπ’” 𝒂 𝒇𝒂𝒄𝒕𝒐𝒓, π’Šπ’‡ 𝒏𝒐𝒕 π’ˆπ’ 𝒕𝒐 𝑺𝒕𝒆𝒑 𝟐
Step2.
𝒙→𝒙+𝟏=
𝒏!𝟏
𝟐 , π’Šπ’‡ 𝒕𝒓𝒖𝒆 𝒕𝒉𝒂𝒏 𝒏 π’Šπ’” π’‘π’“π’Šπ’Žπ’†, 𝒆𝒍𝒔𝒆 π’„π’π’Žπ’‘π’–π’•π’† π’š = π’™πŸ − 𝒏
Step 3.
π’Šπ’‡ π’š ∈
β„•, 𝒏 𝒉𝒂𝒔 𝒇𝒂𝒄𝒕𝒐𝒓𝒔 𝒙 + π’š 𝒂𝒏𝒅 𝒙 − π’š, 𝒆𝒍𝒔𝒆 π’ˆπ’ π’ƒπ’‚π’„π’Œ 𝒕𝒐 𝑺𝒕𝒆𝒑 𝟐
Math 482, Spring 2013 RSA Encoding Chelsea Hawryluk The Euclidean algorithm with an input of two integers that are
relatively prime will yield a common divisor of one, which is what we
need for the RSA algorithm. Numbers such as three and five would
work in theory for encoding however fifteen is an extremely simple
number to factor, for RSA we need numbers that are much larger,
somewhere in the range of 22 digits or larger. Large numbers ensure
that factoring N would take a very long time. To make sure that the
two numbers you choose are large enough it is advised that you use
a n that is at least 231 digits. If we let n have r number of digits than
you calculate the length of p that would give you between
a q that has
!"!
!
!! !"!
,
!" !""
and
digits. We can use the pi function to see how many
primes are between two numbers, so if we know how large we want
our p and q to be we can find the primes that exist in that range.
Math 482, Spring 2013 RSA Encoding Chelsea Hawryluk Which can be adapted to find the number of primes between two
numbers as so
πœ‹ π‘₯ + πœ€ − πœ‹ π‘₯ = π‘₯+πœ€
π‘₯
πœ€
−
≈
log π‘₯ + log 1
log π‘₯
log (π‘₯)
You can find the two prime numbers through this method, which
doesn’t give you a prime, only the number of primes, or you can try to
calculate a prime with the Mersenne numbers calculated by
Now that you have found your two large prime numbers you can
begin encoding. First you multiply PQ resulting in n. Then you choose
an integer e, for encryption, that is relatively prime to the totient
function.
The totient function is a way of calculating the number of positive
inters less than n that are relatively prime to n. Because of n is the
product of two primes the totient equation can be reduced down to
πœ‘ 𝑛 = πœ‘ 𝑝 πœ‘ π‘ž = (𝑝 − 1)(π‘ž − 1)
When you have solved for the e (encryption integer) you can begin to
encode the information. You still need to find out how to decrypt the
Math 482, Spring 2013 RSA Encoding Chelsea Hawryluk information however. Let d be the inverse of e mod (n). This is what
makes the RSA system work so well, in order to decode the
information sent you must know e, which is sent with the information,
and you must know n or the prime factors of n. This is why it is
advised to use very large primes as they will take an unreasonable
amount of time to factor. Let’s finish with an example that will
illustrate how the methods described above are used and the
application of RSA.
EXAMPLE
First you need either a numerical sequence of list of lists to encode.
We will use “KNOW THYSELF” in our example. Because RSA works
on strings of numbers we will first convert the sentence into numbers
using the table below.
A 10 K 20 U 30 B 11 L 21 V 31 C 12 M 22 D 13 N 23 W 32 E 14 O 24 X 33 F 15 P 25 G 16 Q 26 Y 34 H 17 R 27 Z 35 I J 18 19 S T 28 29 SPACE 99 We start the numbering with ten to ensure that several letters are not
mistaken for one with the general consensus that all letters are
represented by two digits.
Math 482, Spring 2013 RSA Encoding Chelsea Hawryluk With the change from letter to number made we have the sequence:
202324329929173428142115. Next we choose our p and q and
calculate n, for this example I’ve chosen p=149 and q= 157 with our
n=23393. Next we look at our string of numbers to be encoded and
divide the block into manageable chucks by dividing it into chunks
less than our n resulting in :
20232-4329-9291-7342-8142-115 which we can apply our encryption
key to. We pick e through the process described above with e being a
prime that does not divide n. We will let e=5 for simplicity. If we
calculate
chunke mod (n)
for each of the chunks we end up with a new number sequence:
20036-23083-11646-4827-4446-13152. This is the sequence that
would be sent along with n to the bank where, using the given n, the
bank can calculate d the decryption key. We calculate d as above,
with the end result being d=13853. Next we decode the sent blocks of
numbers with the same process as encryption but instead of the
chunk being raised to the e, we raise it to the d. The resultant string
of numbers is the original string and then each letter can be found
using the table above.
Math 482, Spring 2013 RSA Encoding Chelsea Hawryluk Sources
Coutinho, S. C. The Mathematics of Ciphers: Number Theory and
RSA Cryptography. Natick, MA: K Peters, 1999. Print.
"Euclidean Algorithm." Wikipedia. Wikimedia Foundation, 05 June
2013. Web. 08 May 2013.
http://en.wikipedia.org/wiki/Euclidean_algorithm
Download