Module 1
Module 1
Guidelines to be followed
CSI3002
Applied Cryptography and Network Security 1. Be on time for class.
2. Be attentive and clarify your doubts immediately.
3. Don’t indulge in other actives when the class is in progress.
By,
Dr.Swetha.N.G., 4. Complete the Assignments/Quiz within the deadline provided.
Assistant Professor Senior, 5. Maintain a dedicated notebook in class.
Department of Analytics,
School of Computer Science and Engineering,
Vellore Institute of Technology, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 1 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Modules Books
Module 1: Introduction to Cryptography Recommended Text Book
1. W. Stallings, Cryptography and Network Security: Principles and Practice, 7th
Module 2: Symmetric Key Cryptography Ed.Pearson Publishers, 2017.
Module 3: Asymmetric Key Cryptography 2. Behrouz A. Forouzan, Cryptography and Network Security:6th Ed. McGraw-
Hill, 2017.
Module 4: Hash Functions and Authentication Reference Books
Module 5: Basic Applied Cryptography 1. Kaufman, Perlman and Speciner. Network Security: Private Communication in a
Public World., 2nd edition, Pearson Publishers, 2002.
Module 6: Advanced Applied cryptography 2. Menezes, van Oorschot, and Vanstone, The Handbook of Applied Cryptography,
20th Edition, WILEY, 2015
Module 7: Web and Wireless Security 3. H. Silverman, A Friendly Introduction to Number Theory, 4th Ed. Boston:
Pearson, 2012.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 2 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
• Security Consultant • IBM Quiz 1 (Before CAT 1) 10 10 Offline (During theory class)
• Cryptographic Software Developer • Microsoft Quiz 2 (Before CAT 2) 10 10 Offline (During theory class)
• Research Scientist in Quantum or • Banking Sectors under IT Wing CAT 1 50 15 Offline Mode by COE
DNA Cryptography • Research Lab CAT 2 50 15 Offline Mode by COE
• Cybersecurity Firms (Palo Alto, Total Internal Marks 60
Certification Details FireEye, CrowdStrike)
•Certified Information Systems Security Professional (CISSP)
•Certified Ethical Hacker (CEH)
•GIAC Security Essentials (GSEC)
•CompTIA Security+
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 3 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Confidentiality Integrity
• Preserving authorized restrictions on information access and • Guarding against improper information modification or destruction,
disclosure, including means for protecting personal privacy and including ensuring information nonrepudiation and authenticity.
proprietary information. • Non-repudiation is the assurance that someone cannot deny the validity of
something.
• A loss of confidentiality is the unauthorized disclosure of information. • Eg: Signing a document
• Two Concepts • Authenticity is the quality of being true.
• Data Confidentiality • A loss of integrity is the unauthorized modification or destruction of
• Assures that private or confidential information is not made available or information.
disclosed to unauthorized individuals. • Two Concepts
• Privacy • Data Integrity
• Assures that individuals control or influence what information related to • Assures that information and programs are changed only in a specified and authorized
manner.
them may be collected and stored and by whom and to whom that • System Integrity
information may be disclosed. • Assures that a system performs its intended function in an unimpaired manner, free
from deliberate or inadvertent unauthorized manipulation of the system.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 4 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Levels of impact
Low Medium High
The loss could be expected to The loss could be expected to The loss could be expected to
have a limited adverse effect. have a serious adverse effect. have a severe or catastrophic
adverse effect.
Examples for CIA Triad Cause a degradation in mission
capability.
Cause a significant degradation
in mission capability
Cause a severe degradation in or
loss of mission capability
Result in minor damage to Result in significant damage to Result in major damage to
organizational assets organizational assets organizational assets
Result in minor financial loss Result in significant financial loss Result in major financial loss
Result in minor Result in significant harm Result in severe or catastrophic
harm to individuals. to individuals that does not harm to individuals involving
involve loss of life or serious, loss of life or serious life-
life-threatening injuries. threatening injuries.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 5 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 6 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 7 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Threats and Attacks Homework – Match the given Attack with its
appropriate Threat
Threat Consequences Attack
Attack Meaning Threat
Usurpation 1.Misappropriation Eavesdropping Unauthorized interception of information 1. Unauthorized Disclosure
• Unauthorized entity • This can include theft of service. 2. Deception
Passive wiretapping Snooping in which a network is monitored
controls the system • The malicious software makes unauthorized use of 3. Disruption
functionality processor and operating system resources. Modification or Unauthorized change of information 4. Usurpation
alteration
• Threat to system 2. Misuse
Active wiretapping Data moving across a network is altered
integrity • Misuse can occur by means of either malicious logic
or a hacker that has gained unauthorized access to a Repudiation of origin False denial that an entity sent (or created) something
system. Denial of receipt False denial that an entity received some information
• In either case, security functions can be disabled or or message
thwarted. Delay A temporary inhibition of a service
Denial of service A long-term inhibition of service
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 8 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Types of Attack
• Active Attack Active Attacks - Illustration
• Modification in the Data Stream
• Types
• Replay
• Passive capture of a data unit and its subsequent retransmission to produce an unauthorized effect.
• Masquerade
• One entity pretends to be a different entity (Impersonation)
• Modification of messages
• Some portion of a legitimate message is altered.
• Denial of service
• Inhibits the normal use or management of communication facilities.
• Disabling the network or by overloading it with messages so as to degrade performance.
• Passive Attack
• Eavesdropping on, or monitoring of, transmissions.
• Goal: Obtain the information that is being transmitted
• Types:
• Release of message contents
• Traffic analysis
• Gathering the data from the packet
• Very difficult to detect the attack.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 9 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
1.Malware
Common Types of Attacks • Malware uses a vulnerability to breach a network -> install malicious software
• Deny access to the critical components of the network
• Obtain information by retrieving data from the hard drive
1. Malware • Disrupt the system or even render it inoperable
2. Phishing • Common Types of Malware
• Viruses
3. Man-in-the-Middle (MitM) Attacks • Infect applications attaching themselves to the initialization sequence
4. Denial-of-Service (DOS) Attack • Replicates itself, infecting other code in the computer system
• Trojans
5. SQL Injections • Program hiding inside a useful program with malicious purposes
6. Zero-day Exploit • Trojan doesn’t replicate itself and it is commonly used to establish a backdoor to be exploited
• Worms
7. Password Attack • Self-contained programs that propagate across networks and computers
8. Cross-site Scripting • installed through email attachments, sending a copy of themselves to every contact in the infected computer email
list
9. Rootkits • DoS Attack
• Ransomware
10. Internet of Things (IoT) Attacks • Denies access to the victim data, threatening to publish or delete it unless a ransom is paid.
11. DNS Tunneling • Spyware
• Program installed to collect information about users, their systems or browsing habits, sending the data to a remote
user.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 10 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
2. Phishing
• Phishing is the practice of sending fraudulent communications that appear
to come from a reputable source, usually through email.
• Link -> appears to be legit -> once clicked, the personal data
(Authentication information is extracted)
• Types
• Email Phishing
• Register a fake domain that mimics a genuine organization and sends thousands of generic
requests.
• Spear phishing
• Targeted attacks directed at specific companies and/or individuals. (Some information about
the victim is already with them)
• Whaling
• Attacks targeting senior executives and stakeholders within an organization.
• Smishing and vishing
• Smishing involves criminals sending text messages
• Vishing involves telephonic conversations
• Angler phishing
• Fake URLs; cloned websites, posts, and tweets; and instant messaging
• Pharming
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of • Capture user credentials through a fake login landing page
Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 11 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
5. SQL Injections
• Attacker inserts malicious code into a 7. Password Attack
server using server query language
(SQL) forcing the server to deliver
protected information. • By accessing a person’s password, an attacker
• An attacker could carry out a SQL can gain entry to confidential or critical data
injection simply by submitting and systems, including the ability to
malicious code into a vulnerable manipulate and control said data/systems.
website search box. • Password attackers use a myriad of methods to
identify an individual password,
6.Zero-day exploit • Social engineering
• Gaining access to a password database
• Testing the network connection to obtain
• A zero-day exploit hits after a network unencrypted passwords
vulnerability is announced but before • Simply by guessing
a patch or solution is implemented. • Brute-force attack – All possible combinations
• Dictionary attack - When the attacker uses a list of
• Attackers target the disclosed common passwords to attempt to gain access to a
vulnerability during this window of user’s computer and network.
time.
9.Rootkits
8. Cross-site Scripting
• Rootkits are installed inside legitimate software, where they can gain
remote control and administration-level access over a system.
• A cross-site scripting
attack sends malicious • The attacker then uses the rootkit to steal passwords, keys,
scripts into content from credentials, and retrieve critical data.
reliable websites.
• The malicious code joins
the dynamic content that 10. IOT Attacks
is sent to the victim’s
browser. • The interconnectedness of things makes it possible for attackers to
• Usually, this malicious breach an entry point and use it as a gate to exploit other devices in
code consists of Javascript
code executed by the the network.
victim’s browser, but can
include Flash, HTML, and
XSS.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 12 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 13 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Security Mechanism
Incorporated into the appropriate protocol layer in order to Mechanisms that are not specific to any particular
Relationship between Security Services and
provide some of the OSI security services. Security Mechanism OSI security service or protocol layer.
Security Mechanism
Specific Security Mechanism Pervasive Security Mechanism
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 14 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 15 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 16 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 17 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 18 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 19 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
a=q×n+r
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 20 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
-
+
-
-
-
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 21 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Integer Division
Integer Division
• Assume that a = -255 and n = 11.
• We can find q = -23 and r = -2 using the division algorithm.
- Conversion:
q = q-1
- r = r+n
+
-
q=-23 ➔ -23-1 = -24
- r= -2 ➔ -2+11 = 9
a = (q x n) + r
-
-255 = (-24 x 11) + 9
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 22 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 23 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
eg GCD(60,24) = 12
• Mathematical Definition
• gcd(a, b) = max[k, such that k|a and k|b]
• We define gcd(0, 0) = 0
• we require that the greatest common divisor be positive,
• We define gcd(a,0) = |a| • gcd(a,b) = gcd(a,-b) = gcd(-a,b) = gcd(-a,-b)
• When gcd(a,b)=1, it implies that there are no common divisor except 1. • In general, gcd(a,b) = gcd(|a|,|b|)
• So, a and b are said to be relatively prime to each other. • Eg: gcd(60,-24) = gcd(60,24) = 12
• Eg: gcd(8,15)=1 • gcd (a, b) = gcd (b, r), where r is the remainder of dividing a by b
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
q r1 r2 r
Divide 25/60 = 0.4166
0 25 60 25
q=0
r = 25 (0.416*60)
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 24 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
q r1 r2 r q r1 r2 r
Divide 60/25 = 2.4 Divide 25/10 = 2.5
0 25 60 25 0 25 60 25
q=2 q=2
2 60 25 10 2 60 25 10
r = 10 (0.4*25) r = 5 (0.5*10)
2 25 10 5
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
q r1 r2 r q r1 r2 r
Divide 10/5 = 2 When r2=0
0 25 60 25 0 25 60 25
q=2 Stop
2 60 25 10 2 60 25 10
r=0
2 25 10 5 2 25 10 5
2 10 5 0 2 10 5 0
5 0
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 25 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
q r1 r2 r
0 25 60 25
2 60 25 10 GCD(25,60)=5
2 25 10 5
2 10 5 0
5 0
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Euclidean Algorithm
Euclidean Algorithm
• gcd(1160718174, 316258250)=?
• Find the greatest common divisor of 2740 and 1760.
q r1 r2 r
1 2740 1760 980
1 1760 980 780 GCD(2740,1760)=20
1 980 780 200
3 780 200 180
1 200 180 20
9 180 20 0
20 0
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 26 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
q r1 r2 r
Homework
3 1160718174 316258250 211943424
1 316258250 211943424 104314826
• GCD(1970,1066) = ? Answer: 2
2 211943424 104314826 3313772
31 104314826 3313772 1587894
2 3313772 1587894 137984
11 1587894 137984 70070
1 137984 70070 67914
1 70070 67914 2156
31 67914 2156 1078
2 2156 1078 0
1078 0
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 27 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
q r1 r2 r s1 s2 s t1 t2 t a=161 b=28
------------------------------------
5 161 28 21 1 0 1 0 1 -5 161/28 = 5.75
q= 5
r= 21
------------------------------------
s=s1-(q*s2)
s=1-(5*0)
s=1
-------------------------------------
t=t1-(q*t2)
t=0-(5*1)
t=-5
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 28 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 29 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
s=0
t=1
-------------------------------------
s*a + t*b = GCD(a,b)
(0*0)+(1*45) = 45
0+45 = 45
45 = 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 30 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 31 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 32 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Some Zn sets
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 33 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Operation in Zn Operation in Zn
• The three binary operations that we discussed for the set Z can also Perform the following operations (the inputs come from Zn):
be defined for the set Zn. • Add 7 to 14 in Z15
• The result may need to be mapped to Zn using the mod operator.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Operation in Zn Operation in Zn
Perform the following operations (the inputs come from Zn): Perform the following operations (the inputs come from Zn):
• Add 7 to 14 in Z15 • Add 7 to 14 in Z15
• (7+14) mod 15 = 21 mod 15 = 6 • (7+14) mod 15 = 21 mod 15 = 6
• Subtract 11 from 7 in Z13
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 34 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Operation in Zn Operation in Zn
Perform the following operations (the inputs come from Zn): Perform the following operations (the inputs come from Zn):
• Add 7 to 14 in Z15 • Add 7 to 14 in Z15
• (7+14) mod 15 = 21 mod 15 = 6 • (7+14) mod 15 = 21 mod 15 = 6
• Subtract 11 from 7 in Z13 • Subtract 11 from 7 in Z13
• (7-11) mod 13 = -4 mod 13 = 9 mod 13 = 9 • (7-11) mod 13 = -4 mod 13 = 9 mod 13 = 9
• Multiply 11 by 7 in Z20
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Operation in Zn Operation in Zn
Perform the following operations (the inputs come from Zn): Properties
1. [(a mod n) + (b mod n)] mod n = (a + b) mod n
• Add 7 to 14 in Z15
• (7+14) mod 15 = 21 mod 15 = 6 2. [(a mod n) – (b mod n)] mod n = (a – b) mod n
3. [(a mod n) x (b mod n)] mod n = (a x b) mod n
• Subtract 11 from 7 in Z13
• (7-11) mod 13 = -4 mod 13 = 9 mod 13 = 9
Example
• Multiply 11 by 7 in Z20 1. [(11 mod 8) + (15 mod 8)] mod 8 = 10 mod 8 = 2 ; (11 + 15) mod 8 = 26 mod 8 = 2
• (11*7) mod 20 = 77 mod 20 = 17 2. [(11 mod 8) – (15 mod 8)] mod 8 = –4 mod 8 = 4 ; (11 – 15) mod 8 = –4 mod 8 = 4
3. [(11 mod 8) x (15 mod 8)] mod 8 = 21 mod 8 = 5 ; (11 x 15) mod 8 = 165 mod 8 = 5
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 35 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Operation in Zn Inverses
• In arithmetic, we often need to find the remainder of powers of 10 • When we are working in modular arithmetic, we often need to find
when divided by an integer. the inverse of a number relative to an operation.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Solution:
• Z10 = {0,1,2,3,4,5,6,7,8,9}
• Consider ‘0’ the additive inverse is itself ‘0’ [0+0] ≡ 0 mod 10
In modular arithmetic, each integer has an additive inverse.
The sum of an integer and its additive inverse is congruent to • ‘1’ additive inverse is ‘9’, [1+9] ≡ 0 mod 10
0 modulo n. • 2 additive inverse is 8, [2+8] ≡ 0 mod 10
• The six pairs of additive inverses are
(0, 0), (1, 9), (2, 8), (3, 7), (4, 6), and (5, 5).
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 36 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Inverses: Multiplicative
Inverses: Multiplicative • Find all multiplicative inverses in Z10.
• In Zn, two numbers a and b are the multiplicative inverse of each Solution
other if • Z10 = {0,1,2,3,4,5,6,7,8,9}
• 0 * NA ≡ 1 mod 10
• 0 has no multiplicative inverse under modulo 10.
• 1*? ≡ 1 mod 10
• 1*1 ≡ 1 mod 10
In modular arithmetic, an integer may or may not • The multiplicative inverse of 1 is 1 under modulo 10.
have a multiplicative inverse. • 2*? ≡ 1 mod 10
• 2 has no multiplicative inverse under modulo 10.
When it does, the product of the integer and its
• 3*? ≡ 1 mod 10
multiplicative inverse is congruent to • 3*7 ≡ 1 mod 10
1 modulo n. • The multiplicative inverse of 3 is 7 under modulo 10.
• There are only three pairs: (1, 1), (3, 7) and (9, 9).
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of • The numbers 0, 2, 4, 5, 6, and 8by:do
Prepared not have
Dr.Swetha.N.G., a Senior,
Asst Prof multiplicative
Dept of inverse.
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 37 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
• The gcd (100, 23) is 1; the inverse of 23 is -13 or 87. • The gcd (26, 12) is 2; the inverse does not exist.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 38 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 39 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
• Is 301 a prime?
Solution
• The floor of √301 = 17. We need to check 2, 3, 5, 7, 11, 13, and 17. The
numbers 2, 3, and 5 do not divide 301, but 7 does. Therefore 301 is not a
prime.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 40 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
• Here the exponent (12) and the modulus (11) are not the same. With
substitution this can be solved using Fermat’s little theorem.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 41 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 42 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 43 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
11*17
(2^2)*(5^2)
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Modular Exponentiation
• If the base and the modulus are closer to each other, convert the base
into a negative number.
• Choose whichever is the smallest to operate on.
Additional Input • If the exponent is greater, then divide the exponent into smaller
numbers and get the result. Finally combine all the answers obtained.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 44 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 45 of 46
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
5117 mod 19
Fast Modular Exponentiation Binary Equivalent of 117= 1 1 1 0 1 0 1
26 25 24 22 20
• ab mod m
5117 mod 19= 51 * 54* 516 * 532 * 564 (mod 19)
• Find the binary equivalent of b.
= 5 * 17 * 16 * 9 * 5 (mod 19)
• Replace each 1 in the equivalent with 2Position.
=1
• Raise a to the power of each 2Position.
• Solve it to get the answer.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 46 of 46