Download Public Key Encryption

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Addition wikipedia , lookup

Index of cryptography articles wikipedia , lookup

Arithmetic wikipedia , lookup

Cryptography wikipedia , lookup

Cryptanalysis wikipedia , lookup

Transcript
Public Key
Cryptography
Asymmetric Cryptography
The substitution and transposition techniques we’ve
examined up to this point are symmetric cryptography
algorithms. Symmetric cryptography uses a single private
key to both encrypt and decrypt data. Any party that has
the key can use it to encrypt and decrypt data. Symmetric
cryptography algorithms are typically fast and are
suitable for processing large streams of data. The
disadvantage of symmetric cryptography is that it
presumes two parties have agreed on a key and been able
to exchange that key in a secure manner prior to
communication. This is a significant challenge. Thus,
symmetric algorithms are usually mixed with asymmetric
algorithms to obtain a blend of security and speed.
Asymmetric cryptography or public-key cryptography
uses a pair of keys to encrypt and decrypt a message so
that it arrives securely. Any message that is encrypted by
using the public key can only be decrypted by using the
matching private key. This means that you do not have to
worry about passing public keys over the Internet (the
keys are supposed to be public). A problem with
asymmetric encryption, however, is that it is slower than
symmetric encryption. It requires far more processing
power to both encrypt and decrypt the content of the
message.
Modular Multiplicative Inverse
Modular arithmetic is a system of arithmetic for integers
where the numbers “wrap around.” A familiar use of
modular arithmetic is in the 12-hour clock, in which the
day is divided into two 12-hour periods. If the time is
7:00 now, then 8 hours later it will be 3:00. Usual
addition would suggest that the later time should be 7 + 8
= 15, but this is not the answer because clock time "wraps
around" every 12 hours; in 12-hour time, there is no "15
o'clock." The actual time is 15 modulus 12, which
represents the remainder after dividing 15 by 12. The
table below contains some examples. Notice that 12:00 is
the same as 0:00. In “math speak,” we say that 12 and 0
are “congruent modulo 12” (as are 13 and 1, and 14 and
2, and n and n + 12 for any integer n).
Dividend (n)
10
11
12
13
Divisor (k)
12
12
12
12
The multiplicative inverse
number, 𝑛−1 , such that 𝑛
1/𝑛 since 𝑛 × 1/𝑛 = 1.
for multiplicative inverse;
called it x.)
n modulus k
10
11
0
1
of a number, n, is another
× 𝑛−1 = 1 . Thus, 𝑛−1 =
(The 𝑛−1 is simply notation
we could have just as well
Modular Multiplicative Inverse
The modular multiplicative inverse of a number, n, is
another number, n-1, such that
(𝑛 × 𝑛−1 ) 𝑚𝑜𝑑𝑢𝑙𝑢𝑠 𝑘 = 1.
This constraint means that
𝑛 × 𝑛−1 = 𝑑 × 𝑘 + 1
𝑛−1 = (𝑑 × 𝑘 + 1)/𝑛
for some integer d. For example, since
(3 × 3) 𝑚𝑜𝑑𝑢𝑙𝑢𝑠 8 = 1
there exists an integer 𝑑 such that
(3 × 3) = 𝑑 × 8 + 1
and
3 = ((𝑑 × 8) + 1)/3
In fact, the value of 𝑑 is 1.
Thus we can figure out values for 𝑛−1 , by finding integer
values for 𝑑 that result in an integer quotient. (Okay, we
could do this using the Euclidean algorithm, but a trial
and error approach works fine for small divisors.) For
example, suppose we want to find the multiplicative
modular inverse for 3 𝑚𝑜𝑑𝑢𝑙𝑢𝑠 10. We need to find a
value for 𝑑 where (𝑑 × 10 + 1)/3 is an integer. This
is the case for 𝑑 = 2 since (2 × 10 + 1)/3 = 7 .
Thus, the multiplicative modular inverse for
3 𝑚𝑜𝑑𝑢𝑙𝑢𝑠 10 is 7. We can check this is correct by
calculating (7 × 3) 𝑚𝑜𝑑𝑢𝑙𝑢𝑠 10. Since the result is 1,
we are correct.
Modular Multiplicative Inverse
Here is a table of modular multiplicative inverses.
Divisor Dividend Inverse
Check
(𝒏)
(𝒌)
(𝒏−𝟏 )
2
7
4
(2 × 4) 𝑚𝑜𝑑 7 = 1
3
10
7
(3 × 7) 𝑚𝑜𝑑 10 = 1
5
11
9
(5 × 9) 𝑚𝑜𝑑 11 = 1
7
13
2
(7 × 2) 𝑚𝑜𝑑 13 = 1
Modular inverses can be used to generate public and
private keys. For example, suppose that the message we
want to encode is “SECRET”. Each character in the
message is given a numeric value; let’s say S = 1, E = 2,
C = 3, R = 4, T = 5. Thus, the plaintext of the message
is:
Plaintext: 1 2 3 4 2 5
The public and private keys are (𝑘, 𝑛) and (𝑘, 𝑛−1 )
respectively. Let’s choose 𝑘 = 11, 𝑛 = 5, 𝑛−1 = 9.
We encrypt the message using the formula:
c(m) = (m × n) mod k
for each character m in the plaintext and (𝑘, 𝑛) =
(11, 5).
Modular Multiplicative Inverse
Thus the ciphertext is
Character
Plaintext Ciphertext
S
1
(1 × 5) 𝑚𝑜𝑑 11 = 5
E
2
(2 × 5) 𝑚𝑜𝑑 11 = 10
C
3
(3 × 5) 𝑚𝑜𝑑 11 = 4
R
4
(4 × 5) 𝑚𝑜𝑑 11 = 9
E
2
(2 × 5) 𝑚𝑜𝑑 11 = 10
T
5
(5 × 5) 𝑚𝑜𝑑 11 = 3
Ciphertext: 5 10 4 9 10 3
The receiver of the ciphertext decrypts it using his own
private key: (𝑘, 𝑛−1 ) and the formula:
m(c) = (c × 𝑛−1 ) mod k
for each ciphertext character, c, and (𝑘, 𝑛−1 ) = (11, 9).
Thus the plaintext is
Ciphertext Plaintext
5
(5 × 9) 𝑚𝑜𝑑 11 = 1
10
(10 × 9) 𝑚𝑜𝑑 11
= 2
4
(4 × 9) 𝑚𝑜𝑑 11 = 3
9
(9 × 9) 𝑚𝑜𝑑 11 = 4
10
(10 × 9) 𝑚𝑜𝑑 11
= 2
Character
S
E
C
R
E
Modular Multiplicative Inverse
3
(3 × 9) 𝑚𝑜𝑑 11 = 5 T
Challenge your Partner
Part 1. Choose a value 𝑘 for your dividend and a value 𝑛
for your divisor such that 𝑔𝑐𝑑(𝑘, 𝑛) = 1. Calculate the
value 𝑛−1 . (Do not use 𝑘 and 𝑛 from previous pages; use
new ones, but keep them small. However, don’t make 𝑘
too small because it bounds the number of distinct
characters in the message.) (𝑘, 𝑛) and (𝑘, 𝑛−1 ) are your
public and private keys. Fill in the worksheet (last page)
with your public key. Put your private key here. Put your
public key on the worksheet. Trade worksheets with
partner.
Private key (𝑘, 𝑛−1 ) :
Part 2. Choose a secret message and encode each distinct
character in the secret message using the numbers 1 . . 𝑚
where 𝑚 is less than the 𝑘 field of your partner’s public
key. Write the secret message, partner’s public key, and
character codes here. Fill in the table to show the
calculation of the ciphertext using your partner’s public
key. Copy the ciphertext onto the worksheet. Trade
worksheets with your partner.
Partner’s public key (𝑘, 𝑛):
Modular Multiplicative Inverse
Secret message:
Character Codes
Letter
Code
Character
Plaintext: m
Ciphertext: (𝒎 ×
𝒏)𝒎𝒐𝒅 𝒌
Modular Multiplicative Inverse
Part 3. Fill in the table below to show the calculation of
the plaintext from your partner’s ciphertext using your
private key. Write your plaintext on the worksheet and
check with your partner to see if this is the correct
plaintext.
Ciphertext: c Plaintext: (𝒄 ×
𝒏−𝟏 )𝒎𝒐𝒅 𝒌
Note: the plaintext is a sequence of numbers. To see
what the message is, you’ll need to get the character
codes used by your partner. The RSA public key
encryption algorithm doesn’t go through additional stages
Modular Multiplicative Inverse
of translating letters to number and number to letters
because on a computer, letters are already represented by
numbers.
Modular Multiplicative Inverse
Worksheet
Part I. Create public and private keys. Write your
public key here. Trade worksheets.
Public key (𝑘, 𝑛):
Part II. Encrypt a message using your partner’s
public key. Write the ciphertext here. Trade
worksheets.
Ciphertext:
Part III. Use your private key to decrypt the
ciphertext. Ask you partner for the character codes
to see what the original message is.
Plaintext: