CB Crypto
CB Crypto
NETWORK SECURITY
UNIT – I
UNIT - I
2
BACKGROUND
3
DEFINITIONS
4
SECURITY TRENDS
•protection afforded to an automated information system
in order to attain the applicable objectives of preserving
the
•Integrity
•Availability
•Confidentiality of information system resources
(hardware, software, firmware, information/ data, and
telecommunications)
•three key objectives that are at the heart of computer
security:
❖ Confidentiality: This term covers two related concepts:
➢Data confidentiality: Assures that private or confidential
information is not made available or disclosed to
unauthorized individuals.
➢Privacy: Assures that individuals control or influence what
information related to them may be collected and stored and
by whom and to whom that information may be disclosed.
❖Integrity: This term covers two related concepts:
➢ Data integrity: Assures that information and programs
are changed only in a specified and authorized manner
➢System integrity: Assures that a system performs its
intended function in an unimpaired manner, free from
deliberate or unintended unauthorized manipulation of
the system
❖Availability: Assures that systems work promptly and
service is not denied to authorized users
• Three concepts form what is often referred to as
the CIA triad
•Three concepts embody the fundamental
security objectives for both data and for
information and computing services
AIM OF COURSE
• our focus is on Internet Security
• which consists of measures to deter,
prevent, detect, and correct security
violations that involve the transmission &
storage of information
9
Model for Network Security
•Message to be transferred from one party to another
across some sort of Internet service
•Two parties, who are the principals in this transaction,
must cooperate for the exchange to take place.
•A logical information channel is established by defining a
route through the Internet from source to destination
• cooperative use of communication protocols (e.g.,
TCP/IP) by the two principals
•A security-related transformation on the information to be
sent
•Examples include the encryption of the message, which
scrambles the message so that it is unreadable by the
opponent,
•Some secret information shared by the two principals and,
it is hoped, unknown to the opponent.
•example is an encryption key used in conjunction with the
transformation to scramble the message before
transmission and unscramble it on reception.
•A trusted third party may be needed to achieve
secure transmission:
•for distributing the secret information to the two
principals
•to arbitrate disputes between the two principals
concerning the authenticity of a message
transmission
Four basic tasks in designing a particular
security service:
1. Design an algorithm for performing the security-
related transformation such that an opponent cannot
defeat its purpose.
2. Generate the secret information to be used with
the algorithm.
3. Develop methods for the distribution and sharing
of the secret information.
4. Specify a protocol to be used by the two
principals that makes use of the security algorithm
and the secret information to achieve a particular
security service
Network Access Security Model
•Protecting an information system from unwanted
access from hacker, intruder
•hacker who, with no harmful target, simply gets
satisfaction from breaking and entering a
computer system
•Intruder can be a disgruntled employee who
wishes to do damage or a Criminal who seeks to
exploit computer assets for financial gain
Two kinds of threats:
•Information access threats: Intercept or modify
data on behalf of users who should not have
access
•Service threats: Exploit service flaws in
computers to inhibit use by legitimate users
•Examples: Viruses and worms, spread using
disks & inserted over network
OSI SECURITYARCHITECTURE
1
SECURITYATTACK
• any action that compromises the security of
information owned by an organization
• information security is about how to prevent
attacks, or failing that, to detect attacks on
information-based systems
• often threat & attack used to mean same thing
• have a wide range of attacks
• can focus of generic types of attacks
– passive
– active
2
• Have “passive attacks” which attempt to learn
or make use of information from the system but
does not affect system resources.
• By eavesdropping on, or monitoring of,
transmissions to:
+ obtain message contents
+ monitor traffic flows
• Are difficult to detect because they do not
involve any alteration of the data.
• emphasis in dealing with passive attacks is on
prevention rather than detection
Two types of passive attacks:
▪Traffic analysis.
Release of Message Contents
36
SECURITYSERVICES
• X.800:
“a service provided by a protocol layer of communicating
open systems, which ensures adequate security of the
systemsor of datatransfers”
• RFC2828:
“a processing or communication service provided by a
system to give a specific kind of protection to system
resources”
37
X.800
• divides these services into five categories and
fourteen specific services
Authentication
•The assurance that the communicating entity is the
one that it claims to be
•Two types
o Peer Entity Authentication:
✓Used in association with a logical connection to
provide confidence in the identity of the entities
connected
o Data-Origin Authentication
✓In a connectionless transfer, provides assurance
that the source of received data is as claimed
Access control
▪The prevention of unauthorized use of a resource
▪This service controls who can access to a resource
▪What conditions access can occur
▪What those accessing the resource are allowed to do
Data confidentiality
•The protection of data from unauthorized disclosure.
•Four Types
o Connection Confidentiality
✓Protection of all user data on a connection
o Connectionless Confidentiality
✓ Protection of all user data in a single data block
Selective-Field Confidentiality
✓Confidentiality of selected fields within the user
data on a connection or in a single data block
o Traffic-Flow Confidentiality
✓Protection of the information that might be
derived from observation of traffic
• Data Integrity:
• Assurance that data received are exactly as sent
by an authorized entity
• Contain no modification, insertion, deletion,
replay
➢ Connection Integrity with Recovery
✓ Provides integrity of all user date on connection
• Detects any modification, insertion of data
within entire data sequence with recovery
➢ Connection Integrity without Recovery
• Provide only detection without Recovery
➢ Selective Field connection Integrity
✓ Provide integrity only selected field of user data
➢ Connectionless Integrity
✓ Provide integrity of single connectionless data
block
➢ Selective Field Connectionless Integrity
✓ Provide integrity only selected field within single
connectionless data block
• Non Repudiation
❖ Provide protection against denial by one of the
entities involved in a communication
➢ Nonrepudiation, Origin
✓ Proof that message was sent by the specified
party
➢ Nonrepudiation, Destination
✓ Proof that message was received by the
specified party
SECURITYMECHANISM
• Feature designed to detect, prevent, or recover
from asecurityattack
• no single mechanism that will support all services
required
• however one particular element underlies many of the
security mechanisms
• Mechanisms are divided into:
✓ those implemented in a specific protocol layer,
such as TCP or application-layer protocol
✓ those are not specific to any particular protocol
layer or security service
44
Security Mechanisms: X.800
• Specific Security Mechanisms:
▪ May incorporated into appropriate protocol
layer in order to provide some OSI security
services
➢ Encipherment
✓ Use of mathematical algorithms to transform
data into a form that is not readily intelligible
✓ transformation and subsequent recovery of the
data depend on algorithm and zero or more
encryption keys
➢ Digital Signature
✓ Data appended to, or a cryptographic
transformation of, a data unit that allows a
recipient of the data unit to prove the source
✓ integrity of the data unit and protect against
forgery
➢ Access Control
✓ A variety of mechanisms that enforce access
rights to resources.
➢ Data Integrity
✓ A variety of mechanisms used to assure the
integrity of a data unit or stream of data units.
➢ Authentication Exchange
✓ mechanism intended to ensure the identity of an
entity by means of information exchange.
➢ Traffic Padding
✓ insertion of bits into gaps in a data stream to
frustrate traffic analysis attempts
➢ Routing Control
✓ Enables selection of particular physically secure
routes for certain data and allows routing changes,
especially when a crack of security is suspected
➢ Notarization
✓ use of a trusted third party to assure certain
properties of a data exchange
➢ Pervasive Security Mechanisms
• Mechanisms that are not specific to any
particular OSI security service or protocol layer.
➢ Trusted Functionality
✓ which is perceived to be correct with respect to
some criteria (e.g., as established by a security
policy)
➢ Security Label
✓ marking bound to a resource (which may be a
data unit) that names or designates the security
attributes of resource
➢ Event Detection
✓ Detection of security-relevant events
➢ Security Audit Trail
✓ Data collected and potentially used to facilitate
a security audit
✓ which is an independent review and
examination of system records and activities
➢ Security Recovery
✓ Deals with requests from mechanisms, such as
event handling and management functions
✓ takes recovery actions.
Classical Encryption
Techniques
50
CRYPTOGRAPHY
• Cryptography is the study of secret (crypto-)
writing (-graphy)
• Concerned with developing algorithms which may be used
to:
– Conceal the context of some message from all
except the sender and recipient (privacy or
secrecy)
– Verify the correctness of a message to the recipient
(authentication or integrity)
• Basis of many technological solutions to computer and
communications security problems
51
BASICTERMINOLOGY
• Cryptography - The art or science encompassing the
principles and methods of transforming message an
intelligible into one that is unintelligible, and then
retransforming that messageback to its originalform
• Plaintext - The original intelligible message
• Ciphertext - The transformed message (unintelligible)
• Cipher - An algorithm for transforming an intelligible
message into one that is unintelligible by transposition
and/or substitution methods
• Key - Some critical information used by the cipher, known
only to the sender &receiver
52
BASIC TERMINOLOGY
53
BASIC TERMINOLOGY
• Encryption
– The mathematical function mapping plaintext to
ciphertext using the specified key:
Y= EK(X) or E(K, X)
• Decryption
– The mathematical function mapping ciphertext to
plaintext using the specified key:
X= DK(Y) or D (K, Y) = E-1 K(Y)
54
BASIC TERMINOLOGY
• Cryptographic system (Cryptosystem)
A cryptosystem is a five-tuple (P, C, K, E, D), where
following conditions are satisfied :
1. P is a finite set of possibleplaintexts
2. C is a finite set of possibleciphertexts
3. K,the keyspace, is a finite set of possible keys
4. For each K K, there is an encryption algorithm
EK Eand a corresponding decryption
algorithm DK D. Each EK : P Cand DK: C
P are functions such that DK(EK(X)) = X for
every plaintext X P.
55
Symmetric Encryption
➢ conventional / private-key / single-key
➢ sender and recipient share a common key
➢ all classical encryption algorithms are private-
key
➢ was only type prior to invention of public-key
in 1970’s
➢ by far most widely used
SIMPLIFIED CONVENTIONAL ENCRYPTIONMODEL
Kerchhoff’s Principle
“Encryption algorithms being used should be assumed
to be publicly known and the security of the algorithm
should reside only in the key chosen”
CONVENTIONAL CRYPTOSYSTEMMODEL
29
Requirements
61
EXHAUSTIVEKEYSEARCH
• Brute-force attack
• Always theoretically possible to simply try everykey
• Most basic attack, directly proportional to keysize
• Assume either know or can recognize when plaintext is found
62
UNCONDITIONAL AND COMPUTATIONAL SECURITY
63
CLASSICALENCRYPTIONTECHNIQUES
• Substitution Techniques
–Caesar Cipher
–Monoalphabetic Ciphers
–Playfair Cipher
–Hill Cipher
–Polyalphabetic Ciphers
–One-Time Pad
64
CLASSICALENCRYPTIONTECHNIQUES
67
• No key, just one mapping (translation)
0123456...
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DEFGHIJKLMNOPQRSTUVWXYZABC
3456789...
• ci=E(3,pi)=(pi+3) mod 26;
pi=D(3,ci)=(ci-3) mod 26
68
GENERALIZED CAESARCIPHER
69
• Key letter: the letter a plaintextA
maps to
–e.g. a key letter of Fmeans Amaps to F,B
to G, …,Yto D, Zto E
• Hence have 26 (25 useful) ciphers
–Key space = 26
70
BRUTE-FORCE CRYPTANALYSIS OF CAESAR CIPHER
73
Monoalphabetic Cipher
➢ rather than just shifting the alphabet
➢ could shuffle (jumble) the letters arbitrarily
➢ each plaintext letter maps to a different random
cipher text letter
➢ hence key is 26 letters long
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
Monoalphabetic Cipher Security
77
FREQUENCYSTATISTICSOFLANGUAGE
• In addition to the frequency info of single letters, the
frequency info of two-letter (digram) or three-letter
(trigram) combinations can be used for the
cryptanalysis
• Most frequent digrams
– TH, HE, IN, ER,AN, RE,ED,ON, ES,ST,EN, AT,TO, NT,
HA, ND, OU, EA, NG, AS, OR, TI, IS, ET,IT, AR, TE, SE,
HI, OF
• Most frequent trigrams
– THE,ING, AND, HER,ERE,ENT,THA, NTH, WAS, ETH,
FOR, DTH
44
HOMOPHONES
• C = EK(P) = KP;
• P= DK(C) = K-1C = K-1KP = P
88
Hill Cipher
• We now take the first 3 characters from our
plaintext, ATT and create a vector that corresponds to the
letters (replace A with 0, B with 1 ... Z with 25 etc.) to
get: [0 19 19] (this is ['A' 'T' 'T']).
93
Example of Vigenère Cipher
• To encrypt a message, a key is needed that is as long
as the message
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
10
Product Ciphers
➢ ciphers using substitutions or transpositions are not
secure because of language characteristics
➢ hence consider using several ciphers in succession to
make harder, but:
➢ two substitutions make a more complex substitution
➢ two transpositions make more complex transposition
➢ but a substitution followed by a transposition makes a new
much harder cipher
10
Various other techniques
• Character marking:
➢ Selected letters of printed or typewritten text are
overwritten in pencil.
➢ The marks are ordinarily not visible unless the paper is
held at an angle to bright light.
• Invisible ink:
➢ A number of substances can be used for writing but leave
no visible trace until heat or some chemical is applied to
the paper.
• Pin punctures:
➢ Small pin punctures on selected letters are ordinarily not
visible unless the paper is held up in front of a light.
• Typewriter correction ribbon:
➢ Used between lines typed with a black ribbon, the results
of typing with the correction tape are visible only under a
strong light.
Foundations of modern cryptography
➢Modern encryption is key to advanced computer and
communication security
12
Group
• a set of elements or “numbers”
• with some operation whose result isalso
in the set(closure)
• obeys:
– associative law: (a.b).c = a.(b.c)
– has identity e: e.a = a.e = a
– has inversesa-1: a.a-1 = e
• if commutative a.b = b.a
–then forms an abelian group
12
Cyclic Group
• define exponentiation as repeated
application of operator
– example: a-3 = a.a.a
• and let identity be: e=a0
• a group is cyclic if every element is apower
of some fixed element
– ie b = ak for some a and every b in group
• a is said to be a generator of the group
12
Ring
• a set of “numbers”
• with two operations (additionand multiplication)
which form:
• an abelian group with addition operation
• and multiplication:
– has closure
– is associative
– distributive over addition: a(b+c) = ab + ac
• if multiplication operation is commutative,it
forms a commutative ring
• if multiplication operation has an identity andno
zero divisors, it forms an integral domain
71
Field
• a set of numbers
• with two operations whichform:
–abelian group for addition
–abelian group for multiplication(ignoring
0)
–ring
• have hierarchy with more axioms/laws
–group -> ring ->field
12
Modular Arithmetic
• define modulo operator “a mod n” to be
remainder when a is divided by n
• use the term congruence for: a = b mod n
– when divided by n, a & b have sameremainder
– eg. 100 = 34 mod 11
• b is called a residue of a mod n
– since with integers can always write: a = qn + b
– usually chose smallest positive remainder as residue
• ie. 0 <= b <= n-1
– process is known as modulo reduction
eg. -12 mod 7 = -5 mod 7 = 2 mod 7 = 9 mod 7
12
Divisors
12
Modular Arithmetic Operations
• is 'clock arithmetic'
• uses a finite number of values, andloops
back from either end
• modular arithmetic is when do addition&
multiplication and modulo reduceanswer
• can do reduction at any point, ie
– a+b mod n = [a mod n + b mod n] mod n
12
Modular Arithmetic
• can do modular arithmetic with any groupof
integers: Zn = {0, 1, … , n-1}
• form a commutative ring for addition
• with a multiplicative identity
• note some peculiarities
– if (a+b)=(a+c) mod n
then b=c mod n
– but if (a.b)=(a.c) mod n
then b=c mod n only if a is relatively prime to n
12
Modulo 8 Addition Example
+ 0 1 2 3 4 5 6 7
0 0 1 2 3 4 5 6 7
1 1 2 3 4 5 6 7 0
2 2 3 4 5 6 7 0 1
3 3 4 5 6 7 0 1 2
4 4 5 6 7 0 1 2 3
5 5 6 7 0 1 2 3 4
6 6 7 0 1 2 3 4 5
7 7 0 1 2 3 4 5 6 77
Greatest Common Divisor (GCD)
78
Euclidean Algorithm
• an efficient way to findthe GCD(a,b)
• uses theorem that:
– GCD(a,b) = GCD(b, a mod b)
• Euclidean Algorithm to compute GCD(a,b)is:
EUCLID(a,b)
1. A = a; B = b
2. if B = 0 return A = gcd(a, b)
3. R = A mod B
4. A = B
5. B = R
6. goto 2 79
Example GCD(1970,1066)
1970 = 1 x 1066 + 904 gcd(1066, 904)
1066 = 1 x 904 + 162 gcd(904, 162)
904 = 5 x 162 + 94 gcd(162, 94)
162 = 1 x 94 + 68 gcd(94, 68)
94 = 1 x 68 + 26 gcd(68, 26)
68 = 2 x 26 + 16 gcd(26, 16)
26 = 1 x 16 + 10 gcd(16, 10)
16 = 1 x 10 + 6 gcd(10, 6)
10 = 1 x 6 + 4 gcd(6, 4)
6 = 1 x 4 + 2 gcd(4, 2)
4 = 2 x 2 + 0 gcd(2, 0)
13
Modular exponentiation
13
Exponential Notation
• Recall that exponential notation represents an expression
of the form
k ,
a
where a represents the base of the expression and k
represents the exponent. If the exponent k is apositive
integer, then
ak a a a
a
a multiplied k times
13
71MOD 41 7
72 MOD 41 49 MOD 41 8
13
Hence,
785 MOD 41 71 4 16 64 MOD 41
(71 74 716 764 ) MOD 41
(7 23 16 18) MOD 41 Substituting from 's above
13
Exponentiation
• can use the Square and Multiply Algorithm
• a fast, efficient algorithm for exponentiation
• concept is based on repeatedly squaringbase
• and multiplying in the ones that are needed to
compute the result
• look at binary representation ofexponent
• only takes O(log2 n) multiples for number n
– eg. 75 = 74.71 = 3.7 = 10 mod 11
– eg. 3129 = 3128.31 = 5.3 = 4 mod 11
13
Exponentiation
13
Modular Exponentiation
• An efficient way to compute ab mod n
• Repeated squaring
• Computes ac mod n as c is Modular-Exponentiation(a, b, n)
1. c 0
increased from 0 to b 2. d 1
• Each exponent computed 3. let bkbk-1…b0 be the binary representation of
in a sequence is either twice 4. for i k downto 0
the previous exponent or 5. do c 2c
6. d (d d) mod n
one more than the previous 7. if bi = 1
exponent 8. then c c+1
• Each iteration of the loop 9. d (d a) mod n
uses one of the identities 10. return d
a2c mod n = (ac)2 modn,
a2c+1 mod n = a (ac)2 mod n
depending on whether bi = 0 or 1
• Just after bit bi is read and processed, the value of c is the same as the prefix
bkbk-1…bi of the binary representation of b
• Variable c is not needed (included just for explanation)
13
Modular Exponentiation - Example
Modular-Exponentiation(a, b, n)
1. c 0
2. d 1
3. let bkbk-1…b0 be the binary representation of b
4. for i k downto 0
5. do c 2c
6. d (d d) mod n
7. if bi = 1
8. then c c+1
9. d (d a) mod n
10. return d
• Example
– Result of Modular-Exponentiation algorithm for ab mod n, where a =
7, b = 560 = 1000110000, n = 561. The values are shown after
each execution of the for loop
88
Finite fields
89
Fields
• Definition 3.1.1: A field is a nonempty set Fof elements with two
operations “+” and “‧” satisfying the following axioms.
a,b,c F
– (i) Fis closed under + and ‧; i.e., a+b and a‧b are in F.
– (ii) Commutative laws: a+b=b+a,a‧b=b‧a
– (iii) Associative laws: (a+b)+c=a+(b+c) , (a‧b)‧c=a‧(b‧c)
– (iv) Distributive law: a‧(b+c) = a‧b +a‧c
– (v) (vi) Identity: a+0 = a , a‧1 = a for all a F. 0‧a = 0.
– (vii) Additive inverse: for alla F,there exists an additive inverse
(-a) such that a+(-a)=0
– (viii) Multiplicative inverse: for alla F,a≠0, there existsa
multiplicative inverse a-1 such that a‧a-1=1 90
Fields
14
Fields
• Definition:
– A field containing only finitely many elements is
called a finite field.
– A set F satisfying axioms (i)-(vii) in Definition3.1.1 is
called a (commutative) ring.
• Example 3.1.4:
– Integer ring: The set of all integers Z={0, ±1, ±2, …}
forms a ring under the normal addition and
multiplication.
– The set of all polynomials over a field F, F[x] =
{a0+a1x+…+anxn | ai F, n≧0} forms a ring under the
normal addition and multiplication of polynomials.
14
Fields
• Definition 3.1.5: Let a, b and m>1 be integers. Wesay
that a is congruent to b modulo m, written as
if m| (a - b); i.e., m divides a - b.
a b(mod m)
• Remark 3.1.7: a = mq + b ,where b is uniquely
determined by a and m. The integer b is called the
(principal) remainder of adivided by m, denoted by
(a (mod m))
14
5
Fields
14
6
Fields
• Theorem 3.1.9 Zmis a field if and only if m is aprime.
Proof:
– (➔)Suppose that m is a composite number and let m = ab for
two integers 1< a, b< m. Thus, a≠0, b≠0. 0=m=ab in Zm. This isa
contradiction to Lemma 3.1.3. Hence Zm is not afield.
• Definition 3.1.10:
Let F be a field. The characteristic of Fis the least positive
integer p such that p*1=0, where 1 is the multiplicative identity
of F.
If no such p exists, we define the characteristic to be 0.
• Example 3.1.11
– The characteristics of Q, R, Care 0.
– The characteristic of the field Zp is p for any primep.
96
Fields
• Theorem 3.1.12: The characteristics of a field is
either 0 or a prime number.
• Proof: 1 is not the characteristic as 1*1≠0.
Suppose that the characteristic p of a fieldFis
composite. Let p = m*n for 1<n, m <p.
p 1 0
(mn) 1 0
m n
1 1 0
i1 i1
(m 1)(n 1) 0
(m 1) 0 or (n 1) 0(lemma3.1.3)
This contradicts the definition of thecharacteristic.
97
Fields
• In abstract algebra a subfield is a subset of a field
which, together with the additive and multiplicative
operators restricted to it, is a field in its own right.
• If K is a subfield of L, then L is said to be a field
extension of K.
• Example:
– Qis a subfield of both Rand C.
– Ris a subfield of C.
– Let F be a field of characteristic p; then Zp can be
naturally viewed asa subfield of F.
98
Fields
• Theorem 3.1.14: A finite field F of characteristic p contains
pn elements for some integern≧1.
• Proof:
– Choose an element α1 F*. We claim that 0‧α1, 1‧α1,…,(p-1)‧α1 are
pairwise distinct. If i‧α1= j‧α1 for some 0≦i ≦j ≦p-1, then (j - i) α1=
0. Hence i = j .(∵characteristic of F is p) If F={0‧α1, 1‧α1,…,(p-
1)‧α1}, we are done.
– Otherwise, we choose an element α2 in F\{0‧α1, 1‧α1,…,(p-1)‧α1}.
We claim that a1α1+a2α2 are pairwise distinct. If a1α1+a2α2=
b1α1+b2α2 for some 0≦a1, a2, b1, b2 ≦p-1, then a2=b2. Otherwise,
α2=(b2-a2)-1(a1-b1)α1 contradict our choice of α2. Since a2=b2, then
a1=b1.
– In the same manner, we can show that a1α1+…+anαn are pairwise
distinct for all ai Zp. This implies |F| = pn.
Polynomial rings
• Definition 3.2.1:
n
– F[x] ai xi : a i F,n 0 is called the polynomial
i 0
– deg(0) =-∞ n
– A nonzeropolynomial f ( x )
i
ai x is said to be
monic if an = 1.
i 0
101
Finite Fields
184
PRIME FACTORIZATION
185
FERMAT’S LITTLETHEOREM
• Theorem If p is prime and a is a positive integer not
divisible by p, then ap-1 1 mod p
• Proof
Start by listing the first p – 1 positive multiples ofa:
a, 2a, 3a, …,(p-1)a
Suppose that ja and ka are the same modulo p,
then we have
j k mod p, so the p-1 multiples of a above are
distinct and nonzero; that is, they must be
congruent to 1, 2, 3, …,p-1 in some order.Multiply
all these congruences together and we find
a 2a 3a (p-1)a 1 2 3 (p-1)
mod p
or better, ap-1(p-1)! (p-1)! mod p. Divide both side
by (p-1)! to complete the proof.
FERMAT’S LITTLETHEOREM
187
EULER’S PHI-FUNCTION
188
EULER’S PHI-FUNCTION
• Properties
(1) (1) = 1 (by convention)
(2) p is prime , (p) = p-1
(3) Let p be a prime and a is a positive integer.
Then (pa) = pa – pa-1 = pa(1 - 1/p)
(4) Let m and n be relatively prime positiveintegers.
Then (mn) = (m) (n)
(5) Let n = p1a1 p 2a2 …p tat be the prime-power
factorization of the positive integer n. Then
(n) = n(1-1/p1)(1-1/p2) (1-1/pt)
189
EULER’S THEOREM
190
• Proof
– The proof is completely analogous to that of the
Fermat's Theorem except that instead of theset of
residues {1,2,...,n-1} we now consider the set of
residues {x1,x2,...,x (n)} which are relatively prime
to n. In exactly the same manner as before,
multiplication by a modulo n results in a
permutation of the set {x1, x2, ..., x (n)}. Therefore,
two products are congruent:
x1x2 ... x (n) (ax1)(ax2) ... (ax (n)) mod n
dividing by the left-hand side proves the theorem.
• Corollary
(1) a (n)+1 a mod n
(2) If gcd(a,n) = 1, then a (n)-1 is an inverse of a
139
modulo n
Primality Testing
192
CHINESEREMAINDERTHEOREM
193
CHINESEREMAINDERTHEOREM
Proof
• Let M =m1 m2 … mk, where mi’s are pairwise
relatively prime, i.e., gcd(mi , mj) = 1, 1 ≤ i ≠ j ≤ k
• A (a1, a2, …,ak), where A ZM, ai Zmi, and ai = A
mod mi for 1 ≤ i ≤k
• One to one correspondence (bijection) between ZM
and the Cartesian product Zm1 Zm2 … Zmk
– For every integer A such that 0 ≤ A < M, there is a
unique k-tuple (a1, a2, …,ak) with 0 ≤ ai <mi
– For every such k-tuple (a1, a2, …,ak), there is a
unique A in ZM
194
CHINESEREMAINDERTHEOREM
• Computing A from (a1, a2, …,ak) is done asfollows:
• Let Mi = M/mi for 1 ≤ i ≤ k, i.e., Mi = m1 m2 …
mi-1 mi+1 … mk
• Note that Mi ≡ 0 (mod mj) for all j ≠ i and gcd (Mi,
mi) = 1
• Let ci = Mi x (Mi-1 mod mi) for 1 ≤ i ≤k
• Then A ≡ (a1c1+ a2c2 + + akck) mod M
ai = A mod mi, since cj ≡ Mj ≡ 0 (mod mi) if j≠ i
and ci ≡ 1 (modmi)
195
CHINESEREMAINDERTHEOREM
• Operations performed on the elements of ZM can be
equivalently performed on the correspondingk-tuples
by performing the operation independently in each
coordinate position
– ex) A ↔ (a1, a2, ... ,ak), B↔ (b1, b2, …,bk)
(A B) mod M ↔ ((a1 b1) mod m1, …,(ak bk)
mod mk)
(A B) mod M ↔ ((a1 b1) mod m1, …,(ak bk)
mod mk)
(A B) mod M ↔ ((a1 b1) mod m1, …,(ak bk)
mod mk)
• CRTprovides a way to manipulate (potentially large)
numbers mod M in term of tuples of smaller numbers
196
CHINESEREMAINDERTHEOREM
• Example
– Let m1 = 37, m2 = 49, M = m1 m2 = 1813, A = 973, B
= 678
– M1 = 49, M2 = 37
– Using the extended Euclid’s algorithm
• M1-1 mod m1 = 34, and M2-1 mod m2 = 4
197
–To verify, we compute
• (23, 34) (a1c1+ a2c2) mod M =
(a1M1M1-1 + a2M2M2-1 ) mod M
= [(23)(49)(34) +
(34)(37)(4)] mod 1813 =1651
• which is equal to (678 + 973)mod
1813 = 1651
198
199
200
201
202
203
204
205
Discrete Logarithm(s) (DLs)
206
Discrete Logarithms
208
Primitive Roots mod 13
• a is a primitive root mod pif
{ak | 1≦k≦p-1} = {1,2, …,p-1}
♪2, 6,7,11 are primitive roots mod 13
• p-1=41-1=40 =23 5
• b0 =12
• For q=2: b0 =12, b1 =31, b2=31, and
x = x0 +2x1+4x2 ≡1+2·0+4·1≡ 5 (mod 8)
• For q=5: b0 =12, b1 =18, and
x = x0 ≡ 3 (mod 5)
Solving x ≡ 5 (mod 8) and x≡ 3 (mod 5),
We have x≡13 (mod 40)
212
Solve ax ≡ b (mod p) by IndexCalculus
213
Solve 2x ≡37 (mod 131)
216
A La(b) (mod 4) Machine
217
The ElGamal Public Key Cryptosystem
218
Encryption and Decryption
1. Downloads (p,a,b)
2. Chooses a secret random k and computes
r≡ak (mod p)
3. Computes t≡bkm (mod p)
4. Sends the pair (t,r) to Bob
219
Questions ?