0% found this document useful (0 votes)
5 views86 pages

CNS U2&3

The Data Encryption Standard (DES) is a symmetric-key block cipher that operates on 64-bit blocks using a 56-bit key for both encryption and decryption, involving initial and final permutations and 16 Feistel rounds. While DES exhibits strengths like the avalanche effect and completeness effect, it also has weaknesses such as a small key size and the existence of weak keys. The Advanced Encryption Standard (AES), introduced later, improves upon DES with a block size of 128 bits and key sizes of 128, 192, or 256 bits, and employs a non-Feistel structure with multiple rounds for enhanced security.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views86 pages

CNS U2&3

The Data Encryption Standard (DES) is a symmetric-key block cipher that operates on 64-bit blocks using a 56-bit key for both encryption and decryption, involving initial and final permutations and 16 Feistel rounds. While DES exhibits strengths like the avalanche effect and completeness effect, it also has weaknesses such as a small key size and the existence of weak keys. The Advanced Encryption Standard (AES), introduced later, improves upon DES with a block size of 128 bits and key sizes of 128, 192, or 256 bits, and employs a non-Feistel structure with multiple rounds for enhanced security.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 86

DATA ENCRYPTION STANDARD

• The Data Encryption Standard (DES) is a symmetric-


key
block cipher published by National Institute of
the Standards and Technology
(NIST).
• D E S is a block cipher.

• 64 bit plaintext.
• 64 bit ciphertext.
• The same 56- key is used for both
bit
encryption and decryption.
STRU C TU RE O F D E S
DES
• The encryption process is made of two permutations
(P-boxes), which we call initial and
final permutations, and sixteen Feistel rounds.
• Each round uses a different 48-bit round key
generated from the cipher key according to a
predefined algorithm.

Initial and Final Permutations:


• Figure 6.3 shows the initial and final permutations (P-
boxes).
• Each of these permutations takes a 64-bit input
and permutes them according to a predefined rule
DES- INITIAL AND FINAL PERMUTATION ST EPS
DES- INITIAL AND FINAL PERMUTATION ST EPS
• The permutation rules for these P-boxes are
shown in Table 6.1. E a c h side of the table can be
thought of as a 64-element array.

• Both permutations are keyless


and predetermined.
DES- ROUNDS
• DES uses 16 rounds. Each round of D E S is a
Feistel cipher, as shown in Figure 6.4.

The round takes L I − 1 and R I − 1 from previous round and


creates L I and R I , which go to the next round (or final
permutation box).
DES- FUNCTION
• The heart of D E S is the D E S function. The D E S
function applies a 48-bit key to the rightmost 32
bits (RI−1) to produce a 32-bit output. This
Function is made up of four sections:
• An expansion P-box, a XO R , group of S-boxes,
and a straight P-box as shown in Figure 6.5.
DES- FUNCTION
DES- FUNCTION
• Expansion P-box Since R I − 1 is a 32-bit input and K I is a
48-bit key, we first need to expand R I − 1 to 48 bits.
R I −1 is divided into Eight 4-bit sections. Ea ch 4-bit
section is then expanded to 6 bits. This expansion
permutation follows a predetermined rule.
DES- FUNCTION
• (XOR): After the expansion permutation, D E S uses
the X O R operation on the expanded right section
and the round key. Note that both the right section
and the key are 48-bits in length.
• S-Boxes The S - boxes do the real mixing
(confusion). D E S uses 8 S - boxes, each with a 6-bit
input and a 4-bit output.
• The 48-bit data from the second operation is
divided into eight 6-bit chunks, and each chunk is
fed into a box. The result of each box is a 4-bit
chunk; when these are combined the result is a
32-bit text.
• The substitution in each box follows a pre-
determined rule based on a 4-row by 16-column
table. The combination of bits 1 and 6 of the input
defines one of four rows; the combination of bits 2
through 5 defines one of the sixteen columns as
shown in Figure 6.8.
DES- S-B OX
DES- S-BOX
DES- S-BOX
DES- S-BOX

Problem:
The input to S - box 1 is 100011. What is the output?
Solution
If we write the first and the sixth bits together, we get
11 in binary, which is 3 in decimal. The remaining bits
are 0001 in binary, which is 1 in decimal. We look for
the value in row 3, column 1, in (S-box 1). The result
is 12 in decimal, which in binary is 1100. So the input
100011 yields the output 1100.
DES- STRAIGHT PERMUTATION
• Straight Permutation The last operation in
the DES function is a straight
permutation with a 32-bit input and a
32-bit output. The input/output
relationship for this operation is shown
in Table 6.11 and follows the same
general rule as previous permutation
tables.
DES-K E Y GENERATION
• The round-key generator creates sixteen 48-bit
keys out of a 56-bit cipher key.
• However, the cipher key is normally given as a
64-bit key in which 8 extra bits are the
parity bits, which are dropped before the
actual key- generation process, as shown in
Figure 6.10.
D E S - K E Y GENERATION
D E S - K E Y GENERATION

Shift Left
After the straight permutation, the key is
divided into two 28-bit parts. Each part is
shifted left (circular shift) one or two bits. In
rounds 1, 2, 9, and 16, shifting is one bit; in
the other rounds, it is two bits. The two parts
are then combined to form a 56-bit part.
D E S - K E Y GENERATION
D E S ANALYSIS
STRENGTHS:
i. Avalanche Effect: means a small change in the
plaintext (or key) should create a
significant change in the ciphertext. D E S has
been proved to be strong with regard to this
property.
ii. Completeness Effect: means that each bit of the
ciphertext needs to depend on many bits on
the plaintext. The diffusion and confusion
produced by P-boxes and S - boxes in D E S ,
show a very strong completeness effect.
iii. Number of Rounds: D E S uses sixteen rounds of
Feistel ciphers. It has been proved that after
eight rounds, each ciphertext is a function of
every plaintext bit and every key bit; the
ciphertext is thoroughly a random function
D E S ANALYSIS
WEAKNESSES:
i. S-boxes- Two specifically chosen inputs to an S - box array
can create the same output.
ii. P-boxes- It is not clear why the designers of D E S used the
initial and final permutations; these have no
security benefits. In the expansion permutation
(inside the function), the first and fourth bits of every 4-
bit series are repeated.
iii. Key Size: Critics believe that the most serious weakness of
D E S is in its key size (56 bits). To do a brute-force
attack on a given ciphertext block, the adversary
needs to check 2 5 6 keys. With available technology, it
is possible to check one million keys per second.
This means that we need more than two thousand
years to do brute-force attacks on D E S using only a
computer with one processor. If we can make a
computer with one million chips (parallel
processing), then we can test the whole key domain in
D E S ANALYSIS
WEAKNESSES:
iv. Weak Keys: Four out of 2 5 6 possible keys are called
weak keys. A weak key is the one that, after parity
drop operation, consists either of all 0s, all 1s, or
half 0s and half 1s.

• What is the disadvantage of using a weak key? If we


encrypt a block with a weak key and
subsequently encrypt the result we get the
original block. The process creates the same
original block if we decrypt the block twice. with the
DOUBLE D E S
• In this approach, we use two instances of
DES ciphers for encryption and
two instances of reverse ciphers for
decryption. Each instance uses a
different key, which means that the
size of the key is now doubled (112
bits).
DOUBLE D E S
• Meet-in-the-Middle Attack
• It is based on the observation that, if we have

Given a known pair, (P, C), the attack proceeds as


follows. First, encrypt P for all 2 5 6 possible values of K 1 .
Store these results in a table and then sort the table by
the values of X .
Next, decrypt C using all 2 5 6 possible values of K 2 . As
each decryption is produced, check the result against
the table for a match. If a match occurs, then test the
two resulting keys against a new known plaintext–
ciphertext pair.
DOUBLE D E S
The simplest form of multiple encryption has two
encryption stages and two keys. Given a plaintext P and
two encryption keys K1 and K2, ciphertext C is generated
as
TRIPLE D E S
There are two versions of 3 D E S
1. 3 D E S with 2-Keys
2. 3 D E S with 3-Keys
TRIPLE D E S
There are two versions of 3 D E S
1. 3 D E S with 2-Keys

• There is no cryptographic significance to the use


of decryption for the second stage. Its only
advantage is that it allows users of 3 D E S to
decrypt data encrypted by users of the older
single D E S :

• Currently, there are no practical cryptanalytic attacks


on 3 D E S .
TRIPLE D E S
There are two versions of 3 D E S
1. 3 D E S with 3-Keys
CRYPTOGRAPHY
&
NETWORK SECURITY
UNIT-II
ADVANCED ENCRYPTION
STA N DA R D

Dr.MD.Sirajuddin,
Professor & Head,
Department of Information Technology
ADVANCED ENCRYPTION STANDARD (AES)
• The Advanced Encryption Standard (AES) is a
symmetric-key block cipher published by the
National Institute of Standards and Technology
(NIST) in December 2001.
• The NIST specifications required a block size of 128 bits
and three different key sizes of 128, 192, and 256
bits.
• Criteria: The criteria defined by NIST for selecting A E S
fall into three areas: security, cost,
and implementation.
i. Security
The main emphasis was on security
TheCost
ii. second criterion was cost, which covers the
computational efficiency and storage requirement for
different implementations such as hardware, software, or
smart cards.
ADVANCED ENCRYPTION STANDARD (AES)
iii. Implementation
This criterion included the requirement that the algorithm
must have flexibility (be implementable on any platform)
and simplicity.
Rounds
A E S is a non-Feistel cipher that encrypts and decrypts a
data block of 128 bits. It uses 10, 12, or 14 rounds. The
key size, which can be 128, 192, or 256 bits, depends on
the number of rounds.
ADVANCED ENCRYPTION STANDARD (AES)
Design of A E S Encryption Cipher
ADVANCED ENCRYPTION STANDARD (AES)
Design of A E S Encryption Cipher
• The number of round keys generated by the key-
expansion algorithm is always one more than
the number of rounds. In other words, we have
Number of round keys = Nr + 1
We refer to the round keys as K 0 , K 1 , K 2 … , K N r .
ADVANCED ENCRYPTION STANDARD (AES)
Data Units in AE S
ADVANCED ENCRYPTION STANDARD (AES)
ADVANCED ENCRYPTION STANDARD (AES)
• Let us see how a 16-character block can be shown as
a 4 × 4 matrix. Assume that the text block is
“A E S uses a matrix”. We add two bogus characters
at the end to get “AESUSESAMATRIXZZ.
ADVANCED ENCRYPTION STANDARD (AES)
• ST RU C T U R E O F E A C H RO U N D
ADVANCED ENCRYPTION STANDARD (AES)
SUB BYTES TRANSFORMATION
• The first transformation, SubBytes, is used at the
encryption site. To substitute a byte, we interpret
the byte as two hexadecimal digits. The left
digit defines the row and the right digit defines
the column of the substitution table. The two
hexadecimal digits at the junction of the row and
the column are the new byte. Figure 7.6 shows
the idea.
• In the this transformation, the state is treated as
a 4 × 4 matrix of bytes. Transformation is done
one byte at a time. The contents of each byte is
changed, but the arrangement of the bytes in the
matrix remains the same. In the process, each
byte is transformed independently.
ADVANCED ENCRYPTION STANDARD (AES)
• SUB BYTES TRANSFORMATION
• The SubBytes operation involves 16
independent byte-to-byte transformations.
AES- SUB-BYTES TRANSFORMATION TABLE
ADVANCED ENCRYPTION STANDARD
INVERSE- SUB-BYTES TRANSFORMATION
• Inverse SubBytes is the inverse of
SubBytes.
PERMUTATION
• Another transformation found in a round
is shifting, which permutes the bytes.

• Byte Level Shifting.
ShiftRows: In the
transformation encryption, the is
shifting is to the called
left. ShiftRows and the
• The number of shifts depends on the
row number (0, 1, 2, or 3) of the state matrix.
ADVANCED ENCRYPTION STANDARD
ADVANCED ENCRYPTION STANDARD
• Inverse ShiftRows
• In the decryption, the transformation is called
InvShiftRows and the shifting is to the right. The
number of shifts is the same as the row number (0,
1, 2, and 3) of the state matrix.
• The ShiftRows and InvShiftRows transformations
are inverses of each other.
• MixColumns
• The MixColumns transformation operates at
the column level; it transforms each column
of the state to a new column.
• The transformation is actually the matrix
multiplication of a state column by a
constant square matrix.
ADVANCED ENCRYPTION STANDARD
• MixColumns
ADVANCED ENCRYPTION STANDARD
InvMixColumns
• TheInvMixColumns transformation
is
basically the same as the MixColumns
transformation.
• TheMixColumns and
InvMixColumns transformations are inverses
of each other.
AddRoundKey
• AddRoundKey also proceeds one column at a
time.
• AddRoundKey adds a round key word with
each state column matrix.
• The AddRoundKey transformation can be
ADVANCED ENCRYPTION STANDARD
AddRoundKey
ADVANCED ENCRYPTION STANDARD
K E Y EXPANSION
• To create round key for each round, A E S uses
a key-expansion process. If the number
of rounds is Nr , the key-expansion
routine
creates Nr + 1 128-bit round keys from one
single 128-bit cipher key.
• The key-expansion routine creates round keys
word by word, where a word is an array of
four
bytes. The routine creates 4 × (Nr +1) words
that are called w 0 , w 1 , w 2 , … , w4(Nr+1)-1
ADVANCED ENCRYPTION STANDARD
K E Y EXPANSION
ADVANCED ENCRYPTION STANDARD
K E Y EXPANSION
K E Y EXPANSION
The process is as follows:
1. The first four words (w0, w1, w2, w3) are made from
the cipher key. The cipher key is thought of as
an array of 16 bytes (k0 to k15). The first four bytes
(k0 to k3) become w0; the next four bytes (k4 to
k7) become w1; and so on. In other words, the
concatenation of the words in this group replicates
the cipher key.
2. The rest of the words (wi for i = 4 to 43) are made as

a) If (i mod 4) ≠ 0, wi = wi−1 ⊕ wi−4. This means each


follows:

word is made from the one at the left and the one

b) If (i mod 4) = 0, wi = t ⊕ wi−4. Here t, a temporary


at the top.

word, is the result of applying two routines, SubWord


and RotWord, on wi−1 and XORing the result with a
round constants, RCon.
K E Y EXPANSION

• RotWord
The RotWord (rotate word) routine is similar to the
ShiftRows transformation, but it is applied to only
one row.
• SubWord
The SubWord (substitute word) routine is similar to
the SubBytes transformation, but it is applied only to
four bytes. The routine takes each byte in the word
and substitutes another byte for it.
• Round Constants
E a c h round constant, RC o n , is a 4-byte value in
which the rightmost three bytes are always zero.
CRYPTOGRAPHY
&
NETWORK SECURITY

UNIT-II
B LOWF ISH & IDEA ALGORITHMS

Dr.MD.Sirajuddin,
Professor & Head,
Department of Information Technology
BLOWFISH ALGORITHM
• Designed by Bruce Schneier in 1993.
• Proposed as an alternative to D E S and
IDEA algorithm.
• Faster than D E S .
• Unpatented and available for free.
• It is symmetric block cipher technique.
• It uses Feistel Cipher Structure.
• It divides plaintext into equal size blocks.
• It encrypts 64-bit plaintext block to produce 64-
bit block ciphertext.
• Key size varies from 32 bits to 448 bits. (default
key size is 128 bits).
• Encryption and decryption is performed by using
16 Rounds.
• Each Round consists of key dependent
permutation and key and data-dependent
BLOWFISH ALGORITHM
• Key Expansion: From original key around 18 sub-keys
each of size 32bits are generated and stored in
P- Arrays. Example: P[0], P[1], P[2],……P[17].
• This algorithm uses Four S-Boxes. Ea ch with 256
entries.
• Ea ch S - Box takes 8-bit input and produce 32 bits
output.
• Key expansion begins by initializing the P-Array and
S - Boxes with hexadecimal digits.
BLOWFISH ALGORITHM- Encryption Process
• BLOWFISH ALGORITHM- Encryption Process
1. Divide the plaintext block of 64-bits into two equal size
portions each of size 32 bits.
Round 1:
2. Left portion is XORed with Subkey P 1 .
3. The result of step-2 is given as input to F-function.
4. The result of step-3 is XORed with right portion.
5. Swap the left portion and right portion to
perform Round 2.
• Repeat above steps for remaining 15 Rounds.
• After Round-16, the left portion is XORed with P 1 7 and
right portion is XORed with P 1 8 .
• The result is the 64-bit ciphertext.
BLOWFISH ALGORITHM- FUNCTION

• Function consists of 4-S-Boxes. 32 bit input to F is


divided into four 8-bit blocks. Ea c h S - Box takes 8-
bit input to produce 32-bits output.
• The result of S - Box 1 and S - Box 2 are added.
• The result of addition is XORed with S - Box 3.
• The result of X O R is added with the output of S - Box 4.
•BLOWFISH
ALGORITHM
ADVANTAGES
• It is very fast compared to
D E S and IDEA.
• Highly secured.
• Best in terms of execution time, avalanche effect
and memory usage.

APPLICATIONS
• Password Management (encrypt userid and password).
• Linux uses Blowfish algorithm to keep its file secure.
INTERNATIONAL DATA ENCRYPTION ALGORITHM-
IDEA
• Symmetric Block Cipher.
• It uses Fiestel Cipher Structure.
• Plaintext size of 64 bits is divided into 4
blocks each of size 16 bits.
• Encrypts plaintext of 16-bits blocks to
produce ciphertext of block of 16-bits.
• Key size is 128 bits.
• 128 bit keys divided into subkeys based on number
of rounds.
• IDEA performs 8 identical rounds in which
6 different subkeys are used in each round.
• 128 bit key expanded to 52-Subkeys.
• Six S u b- keys are generated for each round.
IDEA
IDEA
IDEA
• 64 bit plaintext is divided into 4 blocks each of size 16
bits. Plaintext blocks referred as PT1, PT2, PT3 and
PT4. The following operations are performed in each
round.
1) Multiply PT1 and Key1
2) Add PT2 and Key 2
3) Add PT3 and Key 3
4) Multiply PT4 and Key K4
5) result of Step 1 X O R result of step 3
6) result of Step 2 X O R result of step 4
7) Multiply step 5 with Key 5
8) Add result of step 6 and step 7
9) Multiply result of step 8 with Key 6.
10) Add result of step 7 and step 9.
11) result of steps 1 X O R result of step 9.
12) result of steps 3 X O R result of step 9.
13) result of steps 2 X O R result of step 10.
14) result of steps 4 X O R result of step 10.
IDEA
IDEA
IDEA
OUTPUT TRANSFORMATION
Result of last round is referred as R1, R2, R3 and
R4 are given as input to Output Transformation.
The following operations are performed to produce
Ciphertext.
1. Multiply R1 with Key 49.
2. Add R2 and Key 50.
3. Add R3 and Key 51.
4. Multiply R4 and Key 52.
(RI, R2, R3 AND R4 are the four blocks (part) Plain
text after the complete 8 rounds , which are the
inputs for the output transformation resulting in
cipher text.)
IDEA
SUB K E Y GENERATION
• In the first round bit position 1-96 of the key
are
utilized. Bits 97-128 remain unutilized. They are
given to round 2.
• In round second bits 97-128 are first used,
thus circular left shift of 25 bit appears and new
bits from 26-89 are used. Bits position 90-128 and
1-25 remains unused.
• In round third unused bit 90-128 and 1-25 are
first used again, circular leftshift of 25 bit appears
and bit position 51-82 are used. Bit position 83-128
and 1-50 remains unused.
• In the fourth round bit 83-128 and 1-50 are used.
IDEA
SUB K E Y GENERATION
• In the fifth round circular left-shift of 25 bit
appears
and bit position 76-128 and 1-43 are used. Bit
position 44-75 remains unused.
• In the sixth round unused bit of fifth round is
used and left circular shift of 25 bit occur thus
making bit position 37-100 unused.
• In the seventh round unused bit of sixth round
i.e., 37-100 are first used and circular left shift of
25 bit appear bit position 126-128 and 1-29 are
used. Bit 30-125 remain unused.
• Unused bit position 30-125 from round seven
is used and key is disabled.
UNIT-III
PRIME & RELATIVE PRIME NUMBERS
Definition: The positive integers can be divided into three
groups: the number 1, primes, and composites as shown
in Figure 9.1.

A positive integer is a prime if and only if it is exactly


divisible by two integers, 1 and itself. A composite is a
positive integer with more than two divisors
PRIME & RELATIVE PRIME NUMBERS
Example 9.1: What is the smallest prime?
Solution: The smallest prime is 2, which is divisible by 2
(itself) and 1. Note that the integer 1 is not a prime
according to the definition, because a prime must be
divisible by two different integers, no more, no less. The
integer 1 is divisible only by itself; it is not a prime.

Coprimes:
• Two positive integers, a and b, are relatively prime, or
coprime, if gcd (a, b) = 1. Note that the number
1 is relatively prime with any integer. If p is a
prime, then
all integers 1 to p − 1 are relatively prime to p.
• The number of primes in infinite.
Euler’s Phi-function:
• Euler’s phi-function, It is also called the Euler’s
totient
φ (n): function plays a very important role in
cryptography.
• The function finds the number of integers that are both
smaller than n and relatively prime to n.
• The set Z n * contains the numbers that are smaller than
n and relatively prime to n.
• The function φ(n) calculates the number of elements in
this set. The following helps to find the value of φ(n).
1. φ(1) = 0.
2. φ(p) = p − 1 if p is a prime.
3. φ(m × n) = φ(m) × φ(n) if m and n are
relatively prime.
4. φ(pe ) = p e − p e-1 if p is a prime.
5. φ(n) = (p1e1 − p 1 e 1 - 1) × (p2e2 − p 2 e 2 - 1) × … × (pkek − p 2 e k - 1)
Euler’s Phi-Function
Q1: What is the value of φ(13)?
Solution: Because 13 is a prime, φ(13) = (13 −1) = 12
Q2: What is the value of φ(10)?
Solution: We can use the third rule:
φ(10) = φ(2) × φ(5) = 1 × 4 = 4, because 2 and 5
are primes.
Q3: What is the value of φ (240)?
Solution: We can write 240 = 2 4 × 3 1 × 5 1 .
Then φ(240) = (24 −2 3 ) × (31 − 3 0 ) × (51 − 5 0 ) =
64
Q4: C a n we say that φ(49) = φ(7) × φ(7) = 6 × 6 =
36?
Solution: No.
The third rule applies when m and n are relatively prime.
Here 49 = 7 2 . We need to use the fourth rule:
φ(49) = 7 2 − 7 1 = 42.
Euler’s Phi-Function
Q5: What is the number of elements in Z 1 4 *?
Solution: The answer is φ(14) = φ(7) × φ(2) = 6 × 1 =
6. The members are 1, 3, 5, 9, 11, and 13.
EUCLIDEAN ALGORITHM TO COMPUTE G . C . D
Algorithm
The Euclidean Algorithm for calculating G C D of two
numbers A and B can be given as follows:
1. If A=0 then GCD(A, B)=B since the
Greatest
Common Divisor of 0 and B is B .
2. If B=0 then GCD(A,B)=A since the Greatest Common
Divisor of 0 and A is A.
3. Let R be the remainder of dividing A by B assuming
A > B. (R = A % B)
(A = B⋅Q + R)
Find G C D ( B , R )
because GC D( A,
B ) = GC D( B , R ).
Use the above
steps again.
EUCLIDEAN ALGORITHM TO COMPUTE G . C . D
Show how Euclidean’s algorithm is used to find G C D
for the following.
• Find the GCD(7,4)?
• Find the GCD(270,192)?
E XTENDED EUCLIDEAN ALGORITHM
• To compute Multiplicative Inverse.
If a and b are relatively prime and x and y are integers
then,
ax+by= gcd(a,b)
x is modular multiplicative inverse of a modulo b
y is modular multiplicative inverse of b modulo a.
Problem : Compute Multiplicative Inverse of 3 mod 5
Solution: Compute T=T1-T2*Q
Q A B R T1 T2 T
1 5 3 2 0 1 -1
1 3 2 1 1 -1 2
2 2 1 0 -1 2 -5
X 1 0 X 2 -5 X
FERMAT’S LITTLE THEOREM
• Fermat’s little theorem plays a very important role
in
number theory and cryptography.
• We introduce two versions of the theorem here.

First Version:
The first version says that if p is a
prime and a is an integer such that p does
not divide a , then
ap−1 ≡ 1 mod p.
Second Version:
The second version removes the condition
on a. It says that if p is a prime and a is
an integer, then
a p ≡ a mod p.
FERMAT’S LITTLE THEOREM
Example 1: Find the result of 6 1 0 mod 11.
Solution:
We have 6 10 mod 11 = 1. This is the first version of
Fermat’s little theorem where p = 11.

Example 2: Find the result of 5 1 9 mod 19.


Solution: 5 1 9 mod 19= 5

Example 3: Find the result of 3 1 2 mod 11.


Solution:
Here the exponent (12) and the modulus (11) are not the
same. With substitution this can be solved using Fermat’s
little theorem.
3 12 mod 11 = (311 × 3) mod 11 = (311 mod 11) (3 mod

11) = (3 × 3) mod 11 = 9
FERMAT’S LITTLE THEOREM
Multiplicative Inverse
a-1 mod p = ap-2 mod p = 1 mod p
a. 8 −1 mod 17 = 8 17−2 mod 17 = 8 1 5 mod 17=1
b. 5 −1 mod 23 = 5 23−2 mod 23 = 5 2 1 mod 23=1

Compute 88 7 mod 187


88 1 mod 187=88
88 2 mod 187= 88 * 88 mod 187 = 7744 mod 187=77
88 4 mod 187= 88 2 mod 187 * 88 2 mod 187
=77 *77 mod 187= 5929 mod 187 =132
88 7 mod 187= 88 4 * 88 2 * 88 1 mod 187
=132*77*88 mod 187
=894432 mod 187
=11
PROBLEM SOLVING
Problem 1: Compute 3 1 3 3 mod 7
Solution: Represent 133 in binary format 10000101
3 128 + 4 + 1 mo d 7
3 1 2 8 mod 7 =2
3 4 mod 7= 4
3 1 mod 7=3
3 133
= 2 * 4 * 3 mod 7 = 24 mod 7 = 3

Problem 2: Compute 242 3 2 9 mod 243


Solution: -1 3 2 9 mod 243
= -1 mod 243
= 242

Problem 3: Compute 11 7 mod 13 (Ans. 2)


E U L E R’ S THEOREM
Euler’s theorem can be thought of as a generalization of
Fermat’s little theorem. The modulus in the Fermat
theorem is a prime, the modulus in Euler’s theorem is an
integer.
First Version:
The first version of Euler’s theorem is similar to the first
version of the Fermat’s little theorem.
If a and n are coprime, then aφ(n) ≡ 1 (mod n).
Second Version:
The second version of Euler’s theorem (as we call it for the
lack of anyname) is similar to the second version of
Fermat’s little theorem; it removes the condition that a
and n should be coprime.
If n = p × q, a < n , and k an integer, then
a k × φ(n) + 1 ≡ a (mod n).
E U L E R’ S THEOREM
Problem 1: Prove that Euler’s Theorem holds good for
a=3 and n=10?
Solution
Euler’s
Theorem holds
good for above
equation.

Problem 2:
Does Euler’s
Theorem holds
good for a=2
and
n=10?

Multiplicative
Inverse:
MODULAR ARITHMETIC OPERATIONS
1. (a + b) mod n = [ (a mod n) + (b mod n) ] mod n
2. (a - b) mod n = [ (a mod n) - (b mod n) ] mod n
3. (a * b) mod n = [ (a mod n) * (b mod n) ] mod n
C H I N E S E REMAINDER THEOREM (CRT)
If m 1 , m 2 ,.... m k are pairwise
relatively prime positive integers and if
are a any integers,
1 , a 2 ,.... a k then the simultaneous
congruences
x ≡ a 1 (mod m 1 ),
x ≡ a 2 (mod m 2 ),
.......
.......
x ≡ a k (mod mk)
Have a solution and the solution is
unique modulo m where
M= m 1 m 2 ,.... m k
C H I N E S E REMAINDER THEOREM (CRT)
x ≡ 2 (mod 3)
x ≡ 3 (mod 5)
x ≡ 2 (mod 7) Find value of x
• X= (a1*M1* M1 — 1)+ (a2*M2* M2 — 1)+ (a3*M3* M3
— 1)

mod M
• M= m1*m2*m3
• M1= M/m1
• M2= M/M2
• M3= M/m3

•M1* M1 — 1 = 1 mod m1
(Multiplicative Inverse of M1)
C H I N E S E REMAINDER THEOREM (CRT)

a1=2 m1=3 M1=35 M1 — 1 =2

a2=3 m2=5 M2=21 M2 — 1 =1 M=105

a3=2 m3=7 M3=15 M3 — 1 =1

X= (a1*M1* M1 — 1)+ (a2*M2* M2 — 1)+ (a3*M3* M3 — 1)


mod M
X= (2*35*2)+(3*21*1)+(2*15*1) mod 105
X=233 mod 105
X= 23

You might also like