Download is n

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

Index of cryptography articles wikipedia , lookup

Wiles's proof of Fermat's Last Theorem wikipedia , lookup

List of prime numbers wikipedia , lookup

Quadratic reciprocity wikipedia , lookup

Transcript
Arab Open University - AOU
T209
Information and Communication
Technologies: People and Interactions
Seventh Session
1
Prepared by: Eng. Ali H. Elaywe
Reference Material

This session is based on the following references:
–
–
–
–

More references:
–
–
2
Module 5: Security, Book S: Security
Module 5: Security, Book N: Numeracy Skills
Module 5: Security, Book E: Experiments
Module 5: Security, (Text Book) Monograph: Security
Techniques in Digital Systems
http://www.cacr.math.uwaterloo.ca/hac/
http://en.wikipedia.org/wiki/Cryptography
Prepared by: Eng. Ali H. Elaywe
Topics to be covered in this session

Part 2 (Encryption) of Book S
–

1.
(S.2.3.4)
Encryption
exponentiation
modular
Part 3 (Modular arithmetic) of Book N
–
2. (N.3.4) Modular exponentition



3
using
(N.3.4.1) Performing exponentiation in modular
arithmetic
(N.3.4.2) The properties of modular exponentiation
(N.3.4.3) Summary of Section 3.4
Prepared by: Eng. Ali H. Elaywe
Continue

Chapter 3 (More encryption) of Book M
(Monograph)
–
3. (M.3.2) Using exponentiation




Part 2 (Encryption) of Book S
–
–
4
(M.3.2.1) Encryption
(M.3.2.2) Finding Powers
(M.3.2.3) Decryption
4. Back to (S.2.3.4) Encryption using modular
exponentiation
5. (S.2.3.5) Encryption and decryption
Prepared by: Eng. Ali H. Elaywe
Topic 1: (S.2.3.4) Encryption using modular
exponentiation


This section of Part 3 builds on your knowledge
of encryption using modular addition and
modular multiplication, and introduces
encryption using modular exponentiation
Book N:
–
5
Work through all of Section 3.4 ‘Modular
exponentiation’ in Book N. A summary follows
Prepared by: Eng. Ali H. Elaywe
Topic 2: (N.3.4) Modular exponentiation
Sub-Topic 2.1: (N.3.4.1) Performing exponentiation
in modular arithmetic


6
In mathematics, when one number is raised to the
power of another number, this is known as
exponentiation and is expressed by the notation xy
where x is known as the base and y is known as the
power or index . (y is also known as the exponent,
hence the term ‘exponentiation’.)
Alternatively, we can use the notation x^y, where the
symbol ^ is known as ‘carat’
Prepared by: Eng. Ali H. Elaywe
Continue

Example 1: Calculate 63 mod 7
–
First evaluate 63 in the conventional way:

–
Then divide the result by 7:

–
–
216 ÷ 7 = 30 remainder 6
Express the answer as the remainder (or
residue)
In mathematical language I can express this as:

7
6 × 6 × 6 = 216
63
6 mod 7
Prepared by: Eng. Ali H. Elaywe
Continue

Activity 35 (self-assessment)
–
Calculate the result of 34 mod 6 ?

8
34 mod 6
81 mod 6
3 mod 6
Prepared by: Eng. Ali H. Elaywe
Sub-Topic 2.2: (N.3.4.2) The properties of
modular exponentiation



9
Figure 1 which shows exponentiation tables for modulos 5, 6,
7, 8, 9 and 10
Since ab mod n does not yield the same result as ba mod n,
we have chosen the convention that the base is shown in the
vertical column on the left, and the power is shown in the
horizontal row at the top
The main purpose for including these tables is to demonstrate
the degree of apparent randomness and unpredictability
they display, though they do also have some regular features.
(Look, for instance, at the bottom row of each table.) Unlike
the tables for modular addition and modular multiplication,
there is no symmetry
Prepared by: Eng. Ali H. Elaywe
Continue
10
Figure 1 Exponentiation tables for modulos 5, 6, 7, 8, 9 and 10
Prepared by: Eng. Ali H. Elaywe
Continue

Activity 36 (exploratory)
–
–
Using the tables in Figure 1, evaluate:
(a) 64 mod 9

–
38
1 mod 10
(c) 53 mod 7

11
0 mod 9
(b) 38 mod 10

–
64
53
6 mod 7
Prepared by: Eng. Ali H. Elaywe
Continue

Property of associativity for modular
exponentiation:
–
–
We don’t intend to attempt this for modular
exponentiation: it is beyond the scope of this
course
Effect of changing the order of powers in an
expression:

12
We express this generally as (ab)c
Prepared by: Eng. Ali H. Elaywe
(ac)b mod n
Continue

Activity 37 (exploratory)
–
Test the validity of the general equation (ab)c
(ac)b mod n by confirming that:
 (a)
(52)4
(54)2 mod 6
52
25 1 mod 6 then 14
54
625
1 mod 6 then 12
So (52)4
(54)2 mod 6
13
Prepared by: Eng. Ali H. Elaywe
1 mod 6 and
1 mod 6
Continue
 (b)
(43)4
(44)3 mod 5
43
64
and 44
So (43)4
 (c)
(22)5
4 mod 5 then 44
256
1 mod 5
256
1 mod 5 then 13
1 mod 5
(44)3 mod 5
(25)2 mod 7
22
4 mod 7 then 45
1024
and 25 32 4 mod 7 then 42
So (22)5
(25)2 mod 7
14
Prepared by: Eng. Ali H. Elaywe
2 mod 7
16
2 mod 7
Continue

Some regularity in Figure 1 Tables:
–
–
Tables in Figure 1. display some regularity. This is
the row that shows the result of raising the element
that is 1 less than the modulus by some power that
is itself a member of the group
In every case the result is either 1, or 1 less than the
modulus. Mathematically we can express this as:

15
(n – 1)a mod n
1 or (n – 1)
Prepared by: Eng. Ali H. Elaywe
Sub-Topic 2.3: (N.3.4.3) Summary of
Section 3.4

In modular exponentiation the result of
performing two consecutive exponentiation
operations is independent of the order of the
powers:
(ab)c mod n

16
(n – 1)a mod n
(ac)b mod n
1 or (n – 1)
Prepared by: Eng. Ali H. Elaywe
Continue

Book E:
–
–

Monograph:
–
17
Students should work through all of Section 3.6 in
Book E about modular exponentiation
This is also a good time to start using the Modular
Powers Checker
Students should read the whole of Section 3.2
‘Using exponentiation’. A summary follows
Prepared by: Eng. Ali H. Elaywe
Topic 3: (M.3.2) Using exponentiation


18
Exponentiation gives rise to greater computational
difficulties than multiplication but has the useful
property that it is computationally infeasible, with a
suitably large modulus, to work out the key given a
sample of ciphertext and the corresponding plaintext
Encryption using exponentiation is also a feature of a
number of specialist protocols including the RSA
protocols that allow secure communications to take
place even when the encryption key is made public
Prepared by: Eng. Ali H. Elaywe
Continue
Sub-Topic 3.1: (M.3.2.1) Encryption



19
Exponentiation is a shorthand way of indicating
that a number is multiplied by itself several times
For example 2 × 2 × 2 is abbreviated by writing
23
This exponentiation operation can be combined
with modular arithmetic to provide a method of
encryption. The plaintext encoded as a number p
is encrypted by the operation:
pK mod n,
where K is the key
Prepared by: Eng. Ali H. Elaywe
Continue

Example 2:
–
20
If we work modulo 26 and use a key of 11 and we wish
to send the letter ‘T’ then first we encode ‘T’, the
twentieth letter of the alphabet, as 19. With p = 19 the
encrypted message is:
Prepared by: Eng. Ali H. Elaywe
Continue

Some problems:
–
–
–
–
21
There are some pitfalls with this method of encryption:
1- Firstly, if I were to encode the letter ‘A’ as a 0 then the
encrypted result would be 0 whatever the key. Similarly, if ‘A’
were coded as a 1 and then encrypted by raising 1 to some
power (that is, 1 multiplied by itself a number of times) the result
would always be 1 so ‘A’ would, whatever key was used, always
be encrypted as a 1
Similarly, for a modulus n, n – 1 raised to any power gives
either 1 or n – 1. Encoding ‘A’ as a 1 is easily avoided by coding
the letters using numbers starting at 2 and ending at 27
Working modulo 29 would then avoid the use of the
problematic numbers. The new coding table for the letters is
given in Table 1
Prepared by: Eng. Ali H. Elaywe
Continue
0
1
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Table 1 A coding table for the alphabet avoiding problematic
encodings
22
Prepared by: Eng. Ali H. Elaywe
Continue
28
–
2- A second drawback is that for certain
combinations of plaintext, key and modulus the
encoding is ambiguous. For example when we use a
key of 8, the new coding and a modulus of 29, I get
the ciphertexts shown in Table 2

23
There are several problems arising from the data in Table 2.
Perhaps the most serious is that different letters in the upper
row are encrypted using the same letters in the lower row.
This duplication in encoding leads to ambiguity in the
decryption as for example an ‘X’ in the ciphertext might
stand for ‘C’, ‘I’, ‘R’ or ‘X’ in the plaintext
Prepared by: Eng. Ali H. Elaywe
Continue
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
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
0
1
24
7
25
24
23
7
20
20
25
16
1
16
23
23
16
1
16
25
20
20
7
23
24
25
7
24
1
W
F
X
W
V
F
S
S
X
O
O
V
V
O
O
X
S
S
F
V
W
X
F
W
Table 2 An encryption table for exponentiation process with a key
of 8 working modulo 29
24
Prepared by: Eng. Ali H. Elaywe
Continue

Choice of Keys:
–
–

Discrete logarithms:
–
–
25
These ambiguities can only be avoided by avoiding certain
keys
A part of making exponentiation a practical method for
encryption involves finding simple rules for the choice of suitable
keys (see Topic 4)
Given the ciphertext c and plaintext p, find K (in the case of
exponentiation based cipher)
The operation is the inverse of exponentiation and is called
the logarithm
Prepared by: Eng. Ali H. Elaywe
Continue
–
–
–
26
With modular arithmetic, finding logarithms is
surprisingly hard and time-consuming and this
helps to add another layer of security to this method
of encryption
With a suitably large modulus it becomes totally
impracticable to work out the logarithm in a
reasonable time
Logarithms sometimes lend their name to encryption
using exponentiation so, sometimes, encryption
using exponentiation is referred to under the
heading of the discrete logarithm
Prepared by: Eng. Ali H. Elaywe
Sub-Topic 3.2: (M.3.2.2) Finding Powers


27
By exploiting the properties of exponents the
calculation is reduced to a series of simple calculations
to obtain the result of encryption
Although the calculation is reduced to a series of
simple steps there is still a lot of work involved.
However, this form of staged calculation makes it ideal
for incorporating into a computer program.
Exponentiation is therefore a practical form of
encryption when computers are available to perform
the calculations
Prepared by: Eng. Ali H. Elaywe
Continue

Back to Example 2:
–
–
–
Lets encrypt T using exponentiation
It is first encoded as 21 according to Table 1
Suppose the modulus is the prime number 29 and the
key is 11 (this key does not produce ambiguous
results), then the encrypted message is:

–
28
pK = 2111 mod 29
Raising 21 to the power 11, multiplying 11 copies of 21
together, looks like a lengthy and error prone task
which will result in calculations involving numbers with
many digits (in fact 2111 = 350 277 500 542 221)??
Prepared by: Eng. Ali H. Elaywe
Continue
–
However, to work out the result we can take
advantage of two things:


–
2111 means multiplying eleven copies of twenty-one
together. A clue as to how this calculation might be
broken down is given by writing the exponent of 11
as a sum of, for instance, three components 8 + 2 + 1
then:

29
1- We only need to work with numbers up to 29
2- We can break down the operation of raising 21 to the
power of 11 into a number of stages
2111
218 + 2 + 1
Prepared by: Eng. Ali H. Elaywe
Continue
–
–
–
–
30
This shows that multiplying 11 copies of 21 together is the same
as first multiplying eight copies of 21 together and then multiplying
the result by the product of a further two copies of 21, giving a
total of 10 copies. Next, to make the total number of copies 11 the
result would need to be multiplied by another copy of 21. 2111 can
therefore be written as 218 × 212 × 211
A second observation can also be valuable. It is that, for
instance, 218 = 214 + 4 = 214 × 214
That is, 218 is the same as multiplying two copies of 214 together.
This can be summarized in the notation of exponentiation as
Note also that 214 can be found by multiplying two copies of 212
together so that
and
Prepared by: Eng. Ali H. Elaywe
Continue
–
31
Now, exploiting the advantage of working modulo 29:
–
Using the result for 212 and taking a further step gives 214as:
–
and then utilizing the result for 214 to obtain 218 gives:
Prepared by: Eng. Ali H. Elaywe
Continue
32
–
With these results the encryption calculation can be
completed without the need to perform arithmetic on very
large numbers:
–
So the result of encryption the letter T (21) by using the
encryption key 11 is letter Y (26)
Prepared by: Eng. Ali H. Elaywe
Sub-Topic 3.3: (M.3.2.3) Decryption



33
This is not the problem of finding the key, we
assume the key is known
The decryption procedure for exponentiation is
similar to the encryption procedure
If the decryption key is
and the encrypted
message is c then we would expect the
decrypted message to be:
Prepared by: Eng. Ali H. Elaywe
Continue
34

The person decrypting then needs to know the modulus n and
a suitable value for the decryption key
that uncovers the
original plaintext p. Writing out the whole encryption and
decryption process we get:

If the decryption is successful then the result must be the
original plaintext p and therefore it is to be expected that:
Prepared by: Eng. Ali H. Elaywe
Continue


35
Unfortunately, given the encryption key K it is not immediately
obvious what the value of
should be to regenerate the
plaintext message
There is a well-known and useful mathematical finding, a
theorem, that offers a clue as to how the decryption key can be
found. The result of using the Euler–Fermat Theorem
(Fermat's last theorem is also famous but perhaps not for
cryptography http://www-groups.dcs.stand.ac.uk/~history/HistTopics/Fermat's_last_theorem.html), a
theorem of Number Theory named after two mathematicians,
implies that:
Prepared by: Eng. Ali H. Elaywe
Continue

Works as a decryption operation provided

Where ø(n) is the Euler Totient Function that was described in
subsection M.3.1.5. For a prime number n, the Euler Totient
Function ø(n) is n – 1
Example 3:

36
–
For an encryption operation using exponentiation with a modulus of 29,
decryption keys can be derived from the congruence:
–
For a key of 11 and knowing that, because 29 is a prime number,
ø(29) = 29 – 1 = 28, the decryption key is found using the congruence:
Prepared by: Eng. Ali H. Elaywe
Continue
–
Without a computer this task is not straightforward,
but the successive multiplications recorded in Table
3 reveal that:

–
37
11 × 23
1 mod 28
Hence the decryption key has been found to be 23
Prepared by: Eng. Ali H. Elaywe
Continue
n
11 × n
mod 28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
11
22
5
16
27
10
21
4
15
26
9
20
3
14
25
8
19
2
13
24
7
18
1
12
23
6
17
Table 3 Multiplication table for 11 mod 28
38
Prepared by: Eng. Ali H. Elaywe

Back to Example 2:
–
Lets decrypt Y (26) using the decryption key
P
2623 mod 29
39
Prepared by: Eng. Ali H. Elaywe
Continue
= 23
–
40
So the result of decryption Y (26) by using the
decryption key
= 23 is the original letter T(21)
Prepared by: Eng. Ali H. Elaywe
Topic 4: Back to (S.2.3.4) Encryption using
modular exponentiation

Activity 2.21(self – assessment)
–
–
(b) Express the following with the exponent
broken into appropriate component parts:
(i) 621

–
(ii) 915

–
915 = 98 + 4 + 2 + 1
(iii) 428

41
621 = 616 + 4 + 1
428 = 416 + 8 + 4
Prepared by: Eng. Ali H. Elaywe
Continue

Activity 2.22 (self – assessment)
–
Using the method outlined by Monk in Section
3.2.2 of the Monograph, calculate 49 mod 11






42
49 mod 11
48 + 1 mod 11 ((42)2)2 × 41 mod 11
41 mod 11
4 mod 11
42 16 mod 11
5 mod 11
(42)2 52 mod 11 25 mod 11
3 mod 11
((42)2)2
32 mod 11 9 mod 11
So 49 mod 11
9 × 4 mod 11
36 mod 11
3 mod 11
Prepared by: Eng. Ali H. Elaywe
Continue

Conditions for a workable exponentiation algorithm
–
–
–
43
In Section 3.2.1 of the Monograph Monk says that certain
combinations of plaintext coding, key and modulus produce
ambiguous results
We discovered that modular multiplication doesn’t always yield
a unique solution to the congruence ax
b mod n
Certain conditions have to be met before a unique solution can
be assured, and thus it is with the congruence aX b mod n
Prepared by: Eng. Ali H. Elaywe
Continue

Conditions for coding:
–
The first conditions Monk discusses are in the choice
of coding scheme to convert letters to numbers prior
to encryption. He states that the following codes
should be avoided:
a b c
44
0
1
n – 1 (where n is the modulus)
Prepared by: Eng. Ali H. Elaywe
Continue

Activity 2.23 (self – assessment)
–
Explain why the codes 0 and 1 should be avoided



45
Modular exponentiation is performed by the operation pK mod n
(a) If zero is used to encode p then the operation becomes 0K
mod n. Raising 0 to any power will always give the result 0.
Even after reduction by the modulus the result will still be 0. This
means that p would remain unaltered following the encryption
process
(b) If 1 is used to encode p then the operation becomes 1K mod
n. Raising 1 to any power will always give the result 1. Even
after reduction by the modulus the result will still be 1. This
means that p would remain unaltered following the encryption
process
Prepared by: Eng. Ali H. Elaywe
Continue

Conditions to ensure complementary keys
–
–
Monk presents a mathematical argument for
deducing a set of conditions which, if satisfied, will
result in a workable algorithm for using modular
exponentiation as an encryption method
The core of this is that

–
p mod n
will work as a decryption method provided that

46
pK×
K×
1 mod ø (n)
Prepared by: Eng. Ali H. Elaywe
Continue

And particular relationships exist between the
various components. These will occur under the
following conditions:
–
–
–
47
1. The number corresponding to the plaintext is less
than the modulus n
2. The modulus n is prime
3. K and ø (n) are coprime
Prepared by: Eng. Ali H. Elaywe
Continue

Notes 1:
–
–
ø(n) is the Euler Totient Function of n: that is, it is the quantity of
smaller numbers that are coprime with n. Monk explains that when
n itself is prime then every number smaller than n must be coprime
since a prime number has only 1 and itself as factors
Thus, when n is prime ø (n) is equal to (n – 1). All primes except 2
are odd, but since we can discount the use of 2 as a modulus for
practical purposes (n – 1) will always be even and therefore will
have a factor of 2. This means:


48
1- firstly that, to satisfy the third condition shown above K itself must
be an odd number
and 2- secondly, that when n is prime the possible number of keys
available will never be greater than n/2
Prepared by: Eng. Ali H. Elaywe
Continue
–
Example 4: in case of n = 29
Because n = 29 is a prime number, then ø(29) = 29 – 1 =
28
 The valid keys the coprime with 28 are: 1, 3, 5, 9, 11, 13,
15, 17, 19, 23, 25 and 27
 Though a key of 1 makes the ciphertext the same as the
plaintext and is therefore not useful for encryption


49
So the number of valid keys available for modulus 29 =
ø(ø(n) less 1 if a key 1 is to be discounted = ø(ø(n) –1 = ø(n-1)1 = ø(28) – 1 = 12 – 1 = 11 keys
Prepared by: Eng. Ali H. Elaywe
Continue

Notes 2:
–
–
–
50
An encryption scheme that has only a small number
of encryption keys to choose from is relatively easy to
break
The ideal is an encryption scheme that has many
possible keys so that it is not feasible to mount a
brute force attack because of the computing power
needed and the length of time it would take
Higher the prime modulos the greater is the number
of keys
Prepared by: Eng. Ali H. Elaywe
Topic 5: (S.2.3.5) Encryption and decryption


This involves some practical activities using
some software tools for encrypting and
decrypting text
Book E: ExperimentsExperiments
–
51
You should work through all of Part 4 and Part 5 of
Book E. These introduce you to some software
tools that will give you the opportunity to investigate
and experiment with encryption and decryption
Prepared by: Eng. Ali H. Elaywe
Topic 6: Preparation for next session
–
–
52
Continue reading about Module 5
The due date of TMA05 is May. 21
Prepared by: Eng. Ali H. Elaywe