CSF Merged Notes
CSF Merged Notes
Dr Dongzhu Liu
Dr Emma Li
1
HOUSE KEEPING AND
GROUND RULES
2
Course Aims
• Course Spec:
https://www.gla.ac.uk/coursecatalogue/course/?code=COMPSCI4062
• https://www.gla.ac.uk/coursecatalogue/course/?code=COMPSCI5063
3
Communications
• Use Moodle Discussion Forum for general
questions
• Use Lab Assistants about coding during labs
• Use Moodle Coursework Questions forum for
questions about coursework
• Help each other through “peer support”
• Do not DM or email the course coordinators or the
lab assistants
Unless
• You have a problem that will affect your performance
ØPlease find our Office hours on Moodle page
4
How To Do Well
6
Schedules
• Lectures
Weeks 1-10
• Tutorials
Weeks 2-6 and Week 10
• Lab Sessions
Weeks 7-9
*Please check Moodle page for details.
7
Assessments - COMPSCI5063
Deadlines
Quizzes open for 24
• In class Quizzes (10%) hours until 1pm on the
(L2-L6) next day of the lecture
9
Plagiarism and Cheating
10
INTRO TO CYBER SECURITY
11
Name some cyber attacks
Weak Passwords
Phishing attacks
Trade secrets and insider data
theft
Ransomware
Malware Attacks
Sensitive data leaks and
Insider Threats breaches
12
Question?
13
High-level plan for secure system
Systematic thought is required for successful defense
ØGoal: Protect assets
Øonly legible entity/authorized users could receive a
file or use the system
ØAspects of Cyber Security (asset protection)
ü Confidentiality, Integrity, Availability, Authenticity,
Accountability, Non-repudiation
ØThreat model: assumptions about what the attacker
can do
ü e.g., can guess the password, cannot physically
steal our server
14
High-level plan for secure system
Systematic thought is required for successful defense
ØPolicy: Some plan (rules) that will get your system to
achieve the goal
ü e.g., set permissions on a file so it’s only readable
by Alice
ü Policy must include human components (e.g., do
not share passwords)
ØMechanism: Software/hardware that your system uses
to enforces policy
ü user accounts, passwords, encryption
ØOften layered: mechanism of one layer is policy of next
level down 15
Why need Cyber Security?
ØTo protect
vAssets
• Assets are things that need protection and are usually digital,
such as files.
vSome assets, such as keys and passwords, are
important for cyber security but are not stored as
files.
ØAspects of Cyber Security (asset protection):
ü Confidentiality, Integrity, Availability, Authenticity,
Accountability, Non-repudiation
16
Confidentiality
17
Confidentiality
18
Integrity
• Examples.
– Use a message digest to detect if a file has been
changed.
– Use a public key certificate for network
communications.
19
Availability
• Examples
– Protect against denial of service attacks.
20
Authenticity
• Accountability
– a crucial element of Building Integrity (BI)
initiatives and one of the key principles of Good
Governance. A responsible, responsive, and
democratic security sector cannot be conceived
without accountable personnel, institutions, and
procedures.
– an essential part of an information security plan
– Pointed towards who is responsible for each cyber
role in an organization
22
Non- repudiation
• Non-repudiation
– The author / owner of a document cannot say it was
not them.
– Assurance that the sender of information is
provided with proof of delivery and the recipient is
provided with proof of the sender's identity, so
neither can later deny having processed the
information.
– Non-repudiation provides evidence of data's
origin, authenticity, and integrity
– Digital file is properly tracked and users’
action are logged
23
Case study
Accountability Non-repudiation
24
Threats
25
Vulnerabilities
26
Protection and Risk
27
Technical Solutions are Essential
• Unbreakable encryption to keep secrets and ensure data is
not changed.
– The algorithm can’t be broken without the key.
– Keys must be kept secret.
• Digital signatures to allow legally enforceable contracts.
– So that signatures can’t be forged.
• Secure message digests to provide document fingerprints
without revealing the document content.
– So that two different documents can’t have the same message
digest.
• Secure protocols to make sure the basic building blocks of
encryption signatures and message digests are used
correctly.
– So that it is not possible to bypass the use of a key.
28
... but Not Enough
• People!
29
Questions
30
Knowledge survey
31
COMPSCI4062/COMPSCI5063
Cyber Security Fundamentals
(CSF)
Lecture 2
Cyber Attacks and Security Protocols
1
NETWORK STRUCTURES
2
Network Types
3
A Typical Network
4
Open Systems Interconnection
model (OSI model)
Serves as a window for users and application
7. Application processes to access network service.
Concerned with the syntax and semantics of the
6. Presentation information exchanged between the two systems.
Establish, maintain and synchronizes the interaction between
5. Session communicating devices (authentication & Authorization)
Reliable transmission of data segments between
4. Transport points on a network (TCP, UDP protcols)
Structuring and managing a multi-node network,
3. Network including addressing, routing and traffic control
Transmission of data frames between two nodes
2. Data link connected by a physical layer (media access control)
Transmission and reception of raw bit streams over
1. Physical a physical medium (e.g., optical fibre, cable,
wireless radio)
5
CYBERATTACKS
6
Defination
7
Types of attack
• Active attack
Øattempts to alter system resources or affect
their operation, e.g., Denial-of-service attack,
Spoofing, Man-in-the-middle attack, ARP
poisoning (Layer 2)
• Passive attack
Øattempts to learn or make use of information
from the system but does not affect system
resources, e.g., wiretapping, fiber tapping
8
Forms of Cyber Threats
• Environmental
– Break-in, physical damage, natural disaster, etc.
• Unintentional
– Human error, poor training, insufficient
documentation, etc.
• Intentional
– Internal, e.g., Staff
• External
– Intelligence agencies, hackers, terrorists, crackers,
criminals, industrial intelligence, etc.
9
Common Security Problems
• Snooping
– Unauthorized reading or interception of
information
• Modification
– Unauthorized change of information
• Masquerading or spoofing
– Impersonation of one entity by another
10
Common Security Problems
• Repudiation
– False denial of sending or creating information
• Denial of receipt
– False denial of receiving information
• Delay
– Temporary inhibition of access to services or
information
• Denial of service
– Long-term or permanent inhibition of access to
services or information
11
Denial-of-service attack
12
• The resources could be attacked:
• Network bandwidth
• System resources
• Application resources
• A typical Network
13
SYN Spoofing-1
• SYN spoofing attack targets the table of TCP
connections on the server (Layer 4)
• A type of DoS attack
14
SYN Spoofing-2
TCP's three-way
handshake used
to establish a
connection
15
SYN Spoofing -3
TCP’s SYN Spoofing
Attack
- Cause resources
on the server
binding on the
malicious use
- Legitimate clients
couldn’t use the
resource
16
UDP Flood
* A type of DoS 17
Distributed DoS
1. Application layer attacks
2. Protocol attacks
3. Volumetric attacks
18
Defense Against DOS Attacks
A (Alice) B (Bob)
E
(Evesdropper)
Man-in-the-Middle (MITM)
20
MITM Attack
21
Types of MITM Attack
• Wifi Eavesdropping
– Public wifi
• DNS Spoofing
– A Fraudulent web server, redirect a targeted user to a
malicious website under attacker contro
• IP spoofing
– The attackers imitate an approved console's IP address
• ARP spoofing
– fraudulent response, usually happens to a LAN with
ARP protocol
• E-mail Hacking
22
Defending MITM
• Wireless Access Point Encryption
• Use a VPN
• Strong user Credentials
• Public Key Pair Authentication
23
SECURITY PROTOCOLS
-KEEPING A SECRET
24
Keeping A Secret: Memorise
25
Keeping A Secret: Paper
29
SECURITY PROTOCOLS
-COMMUNICATING A SECRET
30
Problem: Communicating a Secret
32
Protocol: Secure Preparation
33
Using Encryption
34
Protocol: Use a Secret Algorithm
35
Protocol: Public Algorithm, Secret
Key (Private Key)
• Details of the encryption and decryption
algorithms are public.
• They have a parameter, the key, which is kept
secret.
• Knowledge of the algorithm is useless without
the key.
• Also called a one key system.
• Also called symmetric encryption.
36
Using a Secret Key
37
Reference Book
38
COMPSCI4062&5063: Cyber Security Fundamentals
Topic 3: Access Control
Dongzhu Liu
Email: [email protected]
Of ce: SAWB 510 (b)
1
fi
Quiz
2
Tutorial
Marking Criteria
Overview
Reading: Chapter 4 Access Control in Book “Computer Security Principles and Practice
(Third Edition)” by William Stallings and Lawrie Brown
5
fi
6
fi
fi
An access control mechanism mediates between a user (or a process executing
on behalf of a user) and system resources, such as applications, operating systems,
firewalls, routers, files, and databases. The system must first authenticate an entity
seeking access. Typically, the authentication function determines whether the user
Access control in a broader context
Authorization: The granting of a right or
permission to a system entity to access a
Authorization system resource. This function determines
database
who is trusted for a given purpose.
Security administrator
Access
Authentication
control
function
function
An access control mechanism mediates between a user and system resources such as
Figure 4.1 Relationship Among Access Control and Other Security Functions
applications, operating
Source: Based systems, rewalls, routers, les, and database.
on [SAND94].
7
fi
fi
fi
Basic Elements of Access Control
• Object: a resource to which access is controlled; an entity used to contain
and/or receive information (e.g., pages, les, mailboxes…)
8
fi
fi
fi
fi
fi
fi
fi
10
DAC: Access Matrix
Dimension 1: Identi ed subjects that may attempt data access to the resources
Own Own
User A Read Read
Write Write
Own
SUBJECTS User B Read Read Write Read
Write
Own
Read
User C Read Read
Write
Write
Own Own
OBJECTS
User A Read File 1 File 2Read File 3 File 4
Write Write
Access Matrix Own Own
User A Read
Own Read
Write Write
SUBJECTS User B Read Read Write Read
Write Own
SUBJECTS User B Read Read Write Read
Write
Own
Read
User C Read ReadOwn
Write Read
User C
Write
Read Write
Read
Write
(a) Access(a)matrix
Access matrix
File 1 A B C
File 2 B C
• Advantage Own
R
W
R
13
fi
15
fi
fi
fi
(a) Access matrix
16
fi
fi
fi
DAC: Other Forms
APTER 4 / ACCESS CONTROL
COMPSCI 4062 & 5063 Cyber Security Fundamentals [2022-2023]
Table 4.1 Authorization Table for Files in Figure 4.2
Authorization Table
An Access Control Model F2 S1 D2
This section introduces a general model for DAC developed by Lampson, Graham,
nd Denning [LAMP71, GRAH72, DENN71]. The model assumes a set of subjects,
17 Let us
set of objects, and a set of rules that govern the access of subjects to objects.
DAC: Model
• Three requirements
• Representing the protection state
• Enforcing access rights
• Allowing subjects to alter the protection state in certain ways.
18
fi
DAC: Model
System intervention
Memory
Segments
addressing
& pages
hardware
Terminal
Terminal
& device
& devices
manager
Instruction
decoding Instructions
hardware
grant a to Sn , X (Sk , grant, a , Sn , X )
Sk
delete b from Sp , Y (Sm , delete, b , Sp , Y ) Access
Sm matrix
monitor
Access
write matrix read
DAC:• Subjects:
Model Access rights with respect to a subject have to do with the ability to grant
or delete access rights of that subject to other objects, as explained subsequently.
• A Figure
separate4.3 is an example.
access For an access
control modulecontrol
is matrix A, each entry
associated with A[S,
each con- of
X] the
tains strings, called access attributes, that specify the access rights of subject S to object
objects
X. For example, in Figure 4.3, S1 may read file F1, because ‘read’ appears in A[S1, F1].
From a logical or functional point of view, a separate access control module is
• The module evaluates each request by the following steps
associated with each type of object (Figure 4.4). The module evaluates each request
by a subject to access an object to determine if the access right exists. An access
attempt triggers the following steps:
1. A subject S0 issues a request of type α for object X.
2. The request causes the system (the operating system or an access control inter-
face module of some sort) to generate a message of the form (S0, α, X) to the
controller for X.
3. The controller interrogates the access matrix A to determine if α is in A[S0, X].
If so, the access is allowed; if not, the access is denied and a protection viola-
tion occurs. The violation should trigger a warning and appropriate action.
Figure 4.4 suggests that every access by a subject to an object is mediated
by the controller for that object, and that the controller’s decision is based on the
current contents of the matrix. In addition, certain subjects have the authority to
make specific changes to the access matrix. A request to modify the access matrix is
treated as an access to the matrix, with the individual entries in the matrix treated as
objects. Such accesses are mediated by an22access matrix controller, which controls
DAC: Model
• How to modify the access matrix? 4.3 / DISCRETIONARY ACCESS CONTROL 123
• Access control system commands
Table 4.2 Access Control System Commands
‘control’ in A[S0, S]
<latexit sha1_base64="22Z443h9rELDv7Jc/9ZbRiKDvzI=">AAAB73icbVDLSgNBEOyNrxhfUY9eBoMgHsKuBPUY9OIxgnlAEkPvZDYZMju7zswKYclPePGgiFd/x5t/4yTZgyYWNBRV3XR3+bHg2rjut5NbWV1b38hvFra2d3b3ivsHDR0lirI6jUSkWj5qJrhkdcONYK1YMQx9wZr+6GbqN5+Y0jyS92Ycs26IA8kDTtFYqdVBEQ/x4axXLLlldwayTLyMlCBDrVf86vQjmoRMGipQ67bnxqabojKcCjYpdBLNYqQjHLC2pRJDprvp7N4JObFKnwSRsiUNmam/J1IMtR6Hvu0M0Qz1ojcV//PaiQmuuimXcWKYpPNFQSKIicj0edLnilEjxpYgVdzeSugQFVJjIyrYELzFl5dJ47zsXZQrd5VS9TqLIw9HcAyn4MElVOEWalAHCgKe4RXenEfnxXl3PuatOSebOYQ/cD5/AKuej70=</latexit>
⇤
column of the access matrix. Rule R7 enables any subject to create a new subject;
↵ S
<latexit sha1_base64="Husc4nc7UXSbUzoIkZ/DYte4euo=">AAAB6nicbVBNS8NAEJ3Ur1q/qh69LBbBU0lE1GPRi8dK7Qe0oWy2k3bpZhN2N0IJ/QlePCji1V/kzX/jts1BWx8MPN6bYWZekAiujet+O4W19Y3NreJ2aWd3b/+gfHjU0nGqGDZZLGLVCahGwSU2DTcCO4lCGgUC28H4bua3n1BpHstHM0nQj+hQ8pAzaqzUaPTdfrniVt05yCrxclKBHPV++as3iFkaoTRMUK27npsYP6PKcCZwWuqlGhPKxnSIXUsljVD72fzUKTmzyoCEsbIlDZmrvycyGmk9iQLbGVEz0sveTPzP66YmvPEzLpPUoGSLRWEqiInJ7G8y4AqZERNLKFPc3krYiCrKjE2nZEPwll9eJa2LqndVvXy4rNRu8ziKcAKncA4eXEMN7qEOTWAwhGd4hTdHOC/Ou/OxaC04+cwx/IHz+QPUrY2D</latexit>
fl
dard, Security Requirements for Cryptographic Modules (FIPS PUB 140-3, September
2009), that requires support for access control and administration through roles.
The relationship of users to roles is many to many, as is the relationship of
roles to resources, or system objects (Figure 4.6). The set of users changes, in some
environments frequently, and the assignment of a user to one or more roles may
Role 1
Role 2
Role 3
24
Role-Based Access Control (RBAC)
• RBAC controls access based on the roles that users have within
the system and on rules stating what accesses are allowed to
users in given roles (rather than user’s identity in DAC).
25
U
with only occasional additions or deletions. Each role will have specific access
3
o one or more resources. The set of resources and the specific access rights
ted with a particular role are also likely to change infrequently. U4
RBAC: Access Control Matrix
We can use the access matrix representation to depict the key elements of an
system in simple terms, as shown in Figure 4.7. The upper matrix relates U5
ual users to roles. Typically there are many more users than roles. Each matrix
U6
R1 R2 Rn
U1
Um
U2
U3
OBJECTS
R1 R2 Rn F1 F2 P1 P2 D1 D2
U4
owner read
R1 control owner
control
read *
owner
wakeup wakeup seek owner
U5
R2 control write * execute owner seek *
ROLES
U6
Um
Figure 4.7 Access Control Matrix Representation of RBAC
OBJECTS
R2 Rn F1 F2 P1 P2 D1 D2
RBAC3
Consolidated model
RBAC1 RBAC2
Role hierarchies Constraints
RBAC0
Base model
Role
hierarchy (RH) Oper-
ations
User Permission
assignment (UA) assignment (PA)
Users Roles 27 Permissions
Base model
User Permission
assignment (UA) assignment (PA)
Users Roles
Permissions
user_sessions session_roles
Objects
Sessions
Base model
User Permission
assignment (UA) assignment (PA)
Users Roles
Permissions
mapping to one
user_sessions session_roles
Objects
mapping to many
Sessions
subordinate roles. For example, in Figure 4.9, the Project Lead role includes all of
the access rights of the Production Engineer role and of the Quality Engineer role.
More than one role can inherit from the same subordinate role. For example, both
RBAC1: Role Hierarchies
the Production Engineer role and the Quality Engineer role include all of the access
rights of the Engineer role. Additional access rights are also assigned to the Produc-
tion Engineer Role and a different set of additional access rights are assigned to the
Quality Engineer role. Thus, these two roles have overlapping access rights, namely
the access rights they share with the Engineer role.
• Job functions with greater responsibility have greater authority to
CONSTRAINTS—RBAC2 Constraints provide a means of adapting RBAC to the
access specifics
resources of administrative and security policies in an organization. A constraint is
a defined relationship among roles or a condition related to roles. [SAND96] lists
• Role hierarchies make
the following types use of mutually
of constraints: the concept of inheritance
exclusive roles, to enable
cardinality, and prere-
quisite roles.
one role to implicitly include access rights associated with a
subordinate role
Director
Engineer 1 Engineer 2
Engineering dept.
Figure 4.9 Example of Role Hierarchy
30
RBAC2: Constraints
31
fi
RBAC2: Constraints
32
fi
RBAC2: Constraints
• Cardinality
Set a maximum number with respect to roles
• Set a maximum number of users that can be assigned to a given role
• Constraint on the number of roles that is a user assigned to
• Set a maximum number of roles that can be granted a particular permission
33
subordinate roles. For example, in Figure 4.9, the Project Lead role includes all of
the access rights of the Production Engineer role and of the Quality Engineer role.
More than one role can inherit from the same subordinate role. For example, both
RBAC2: Constraints
the Production Engineer role and the Quality Engineer role include all of the access
rights of the Engineer role. Additional access rights are also assigned to the Produc-
tion Engineer Role and a different set of additional access rights are assigned to the
Quality Engineer role. Thus, these two roles have overlapping access rights, namely
the access rights they share with the Engineer role.
• Prerequisite role
CONSTRAINTS—RBAC2 Constraints provide a means of adapting RBAC to the
specifics
A user can onlyofbeadministrative
assignedandto asecurity policiesrole
particular in aniforganization.
it is alreadyA constraint
assigned is to
a defined
some other specirelationship
ed roles among roles or a condition related to roles. [SAND96] lists
the following types of constraints: mutually exclusive roles, cardinality, and prere-
quisite roles.
Example: In a hierarchy, a user assigned to a Project Lead role must also be assigned to at
the subordinate Production Engineer and Quality Engineer roles.
Director
Engineer 1 Engineer 2
Engineering dept.
Figure 4.9 Example of Role Hierarchy
34
fi
Attribute-Based Access Control (ABAC)
35
ABAC: Attributes
It de nes speci c aspects of the subject, object, environment conditions,
and/or requested operations that are prede ned or preassigned by an
authority.
36
fi
fi
fi
fi
fi
2a
2d
Rules
1
Enforce
Decision
3
Object
Access control
2b mechanism
Subject
2c
Clearance
Name Owner
Type
Affiliation
Etc. Classification
Etc.
Subject attributes
Object attributes
Figure 4.10 Simple ABAC Scenario
37
fl
1 2 M
Figure
A 1 × 4.11
SA ×ACL
... and
× ABAC
SA Trust Relationships
R(o) ⊆ 2EA1 × EA2 × K... × EAN
A1138
× OA 2 × ...4 /×ACCESS
CHAPTER OAM CONTROL
A
on × EA2 ×for
1 notation ...the ×value
EAN assignment of individual attri-
3. We
ABAC: Policies now define
ATTR(s), ATTR(o),an and
ABAC policyaremodel,
ATTR(e) based
attribute on therelations
assignment model for
presented
sub- in
n for the [YUAN05].
value ject s, The following
assignment
object of conventions
individual
o, and are used:
attri- e, respectively:
environment
e(s) = “Service
1. S, O, andConsumer”
E are subjects, objects,
ATTR(s) ⊆ SA1 and environments,
× SA 2 × ... × SAK
respectively;
viceOwner(o)
“Service SAk (1= “XYZ,
2.Consumer” … k … K),Inc.”
OAm (1⊆…OA
ATTR(r) m1 …× M),
OA2and … Mn … N) are the pre-de-
EAn ×(1 OA
× ...
138 CHAPTER 4= / “01-23-2005”
rentDate(e) ACCESS CONTROL
er(o) = “XYZ,finedInc.”
attributes forATTR(o)
subjects,⊆objects,
EA ×and EA environments,
1 × ... × EArespectively;
2 N
e(e) = “01-23-2005”
rm, a Policy3.Rule, ATTR(s),
We alsowhich ATTR(o),
usedecides onand
the function ATTR(e)
whether
notation afor are
subject attribute assignment
s assignment
the value relationsattri-
of individual for sub-
n
ya particular
Rule, ject s,
butes. object
which environment
decides For e, and
o,
onexample: environment
is a Boolean
whether s e, respectively:
a subjectfunction of the
ar environment e, is a Boolean function of the
ATTR(s) =
Role(s) ⊆ “Service
SA1 × SA2Consumer”
× ... × SAK
(s, o, e) ← ƒ(ATTR(s), ServiceOwner(o) ATTR(r) ⊆ ATTR(e))
ATTR(o), OA1 × =OA“XYZ,
2 × ... Inc.” × OAM
e) ← ƒ(ATTR(s), ATTR(o), CurrentDate(e) ATTR(e))⊆ EA1 ×= EA
ATTR(o) “01-23-2005”
2 × ... × EAN
assignments of s, o, and e, if the function’s evaluation is
the
s ofresource
s, o, and4.ise,We
Inifthe
granted;
the most
also general
otherwise
function’s
use form, anotation
Policy
the access
evaluation
the function Rule,
is is denied. which
for the decides
value on whether
assignment a subject sattri-
of individual
epolicy
is granted; can access thean objectisodenied.
in a particular environment e, is a Boolean function of the
storeotherwise
butes.
may For
consist access
example:
of a number of policy rules,
attributes of s, o, and e:
re mayobjects
s and consistwithin
of a number
a security of domain.
policy rules,
The access con-
cts within a security domain. The Role(s)
access con- = “Service Consumer”
essence amounts Rule: to the evaluation (s,
can_access of applicable
o, e) ←policyƒ(ATTR(s), ATTR(o), ATTR(e))
mounts to the evaluation of applicable ServiceOwner(o)
policy = “XYZ, Inc.”
e.
Given all the attribute CurrentDate(e)
assignments of s, o,=and “01-23-2005”
e, if the function’s evaluation is
mple of an online true, then the accessstore
entertainment to thethat
resource is granted;
streams mov- otherwise the access is denied.
online 4. In the store
entertainment most that
general form,mov-
streams a Policy Rule, which decides on whether a subject s
5.
y fee. We willcan A policy
useaccess rule
this examplebase or
to policy
contrast store
RBACmay and
consist of a number of policy rules,
will use this example
covering to an object
contrast
many o inand
RBAC
subjects a particular
and
objects environment
within a security is a Boolean
e,domain. The function
access of the
con-
ore must enforce the following
attributes of s, o, and access
e: control policy
enforce
the movie’s the content
following access
trol decision
rating: control
process policy amounts to the evaluation of applicable policy
in essence
s content rating: rules in the policy store.
Rule: can_access (s, o, e) ← ƒ(ATTR(s), ATTR(o), ATTR(e))
Rating Users
NowAllowed
considerAccess
38
the example of an online entertainment store that streams mov-
rules in the policy store.
Now consider the example of an online entertainment store that streams mov-
ABAC: Example
ies to users for a flat monthly fee. We will use this example to contrast RBAC and
ABAC approaches.
• An online The store must
entertainment storeenforce the following
enforces accessaccess
the following control policy
control
based on the
policy user’son
based agethe
anduser’s
the movie’s content
age and the rating:
movie content rating:
q q
and fee, and we would K have to double the
Range(SA ) number
model,
and of
we separate
M would
Range(SA permissions
have
) to as well.
double the number of
•
Suppose movies
In general, if therekareare
= 1 K subject
Range(SA
k
classiattributes
edandasfee,
) and =either
mand New
M object
1 and we
Range(SA
m
Release
attributes,
would have)
and
to or
for Old
ifdouble the numb
each attribute, Range()on denotes k
the range of possible values to
it can m
take, then thedate,
Release, based k release date compared
In
= 1that as the number of attributes general, if the
there current
are
= 1 increases to accommodateK subject attribute
Thusnumber
respective we can ofseeroles and permissions requiredmfor an RBAC model are:
and userspolicies,
finer-grained are classi
theK numbered ofasrolesPremium
each Usergrows
attribute,
and permissions andexponentially.
Range() Regular
denotes User,
the
In range of p
q q
M
Thuscontrast,
we can
based onsee
the the that
ABAC feemodelas
they the
deals
pay.number of
withkadditional
Range(SA ) and attributes
respective number
attributes
Range(SA increases
inman
) of roles
efficientandto
way. accommodat
permissions
For req
this example, thethe
policy kR1
= 1 defined previously still
m = 1 applies. We need two new rules:
q
iner-grained policies, number of roles and permissions grows K exponentially. I
ontrast, the ABAC model
R2:can_access(u,
Thus we can deals
m,ase)
see that with
the additional
←number attributes
of attributes increases toin anRange(SA ) and
efficient kway.
accommodate Fo
finer-grained policies, the number
(MembershipType(u) = of k=1
roles and permissions grows exponentially.
Premium) In
his example, the policy R1 defined previously still applies. We need two new rule
contrast, the ABAC model deals
(MembershipType(u) = with additional
Regular attributes in an =
¿ MovieType(m) efficient way. For
OldRelease)
this example, the policy R1 defined previously Thus
still 4.7 /we
applies. canneed
We seetwo
IDENTITY, that as rules:
new the number
CREDENTIAL, of a
AND ACCE
R3:can_access(u,
R2:can_access(u, m, e) ← m, e) ← R3 ¿ R4
finer-grained policies, the number of roles and
R2:can_access(u, m, e)
With the ABAC model,
(MembershipType(u) =is ←Premium)
it also easycontrast,
to add environmental
the ABAC
ment e which is ignored
attributes.deals
here)model
Suppose
with addition
would be resolved by evalu
(MembershipType(u) = Premium)
we wish to add a new policy rule that is expressed in words as follows: Regular users are
(MembershipType(u) = Regular this ¿
example,
the following: the policy R1 =
MovieType(m) defined previously
OldRelease)
allowed to view new releases in promotional
(MembershipType(u) ¿ MovieType(m)
= Regularperiods. This would be=difficult to express
OldRelease)
R3:can_access(u,
inR3:can_access(u,
an RBAC model. In m,anm,e)e) ←model,
ABAC ← R3R3 ¿R4only
¿we R4 need add a conjunctive
R2:can_access(u,
R1:can_access(u, m, e) ←m, (AND) e)rule←
that checks to see the environmental attribute today’s
(Age(u) date
≥ falls¿in Rating(m)
17
(MembershipType(u)a promotional ∈ period.
{R,
= PG-13, G
Premium)
With the ABAC model, it is also easy to add environmental attributes. Suppose
WithwethewishABAC model,
to add a new policy it isthat
rule also easy toinadd
(Age(u)
is expressed ≥environmental
words 13 ¿ Age(u)
as follows:
(MembershipType(u) Regular <attributes.
users ¿ Regular
17=are Suppos
Rating(m) ¿∈
we wish
4.7toallowed
add atonew
IDENTITY, viewpolicy
new ruleinthat
CREDENTIAL,
releases isAND
expressed
promotional ACCESS
periods.
(Age(u) in<words
This MANAGEMENT
13 ¿ be
would
R3:can_access(u, asdifficult
follows:
Rating(m) m, ∈Regular
to express
e) ← R3users
{G}) ¿ R4ar
allowed toinview
an RBAC
newmodel. In anin
releases ABAC model, we only
promotional need add
periods. a conjunctive
This would (AND)
be rule to expre
difficult
that checks to see the environmental where
attributeAge and
today’s Rating
With
date fallsare
the in a the
ABAC subject
model,
promotional attribute
it is
period. and
also thetoobj
easy ad
n an RBAC model. In an ABAC model,
We now examine some concepts that we
are
The advantage
we
only
relevant
wish
need
to
of
to
an
add
add
access
the ABAC
a new
apolicy
conjunctive
control
model approach
shown here
rule that
(AND)
is
is thatru
expressed
it
centered on attributes. This sectionand provides
40 an overview of the concept of identity,
management of static roles, hence eliminating the ne
fi
fi
Summary
• Concept of Access Control
• De nition
Thank You
Quiz Time
• 15 minutes
43
COMPSCI4062&5063: Cyber Security Fundamentals
Topic 4: Cryptography I
Dongzhu Liu
Email: [email protected]
Of ce: SAWB 510 (b)
1

fi
Overview
• Cryptography
• Context
• Ingredients
• Classi cation
• Attacks
• Symmetric Encryption: Block Cipher
• DES/Triple DES (Feistel Cipher Structure)
• AES
• Symmetric Encryption: Stream Cipher
• RC4
• Cipher Block Modes of Operation
Reading: Chapter 20 in Book “Computer Security Principles and Practice (Third Edition)” by William
Stallings and Lawrie Brown
2

fi
Cryptography: Context
3

Cryptography: Ingredients
• Plaintext: original message
• Encryption algorithm: substitution/transformations on the plain text
• Secret key: algorithm input, substitution/transformations depends on the key
• Ciphertext: algorithm output, depends on plain text and secret key
• Decryption algorithm: reverse of encryption
Plaintext
Key Encryption
Ciphertext Decryption
Key
560213/Error
4

Cryptography: Classification
5

Symmetric Encryption
6

Asymmetric Encryption
Asymmetric Encryption
10

• Computationally Secure
• The cost of breaking the cipher exceeds the value of the encrypted information
• The time required to break the cipher exceeds the useful lifetime of the information
Unfortunately, it is very dif cult to estimate the amount of effort required to
cryptanalyze ciphertext successfully.
11

fi
Plaintext (2 bits)
algorithm K1
F
• The plaintext block is divided into two halves,
L0 and R0
L1 R1
• The two halves of the data pass through n
rounds of processing and then combine to Round i
Ki
produce the ciphertext block.
F
• The subkeys K are different from each other
i
Ln Rn
Ln + 1 Rn + 1
Ciphertext (2 bits)
12

• Key Size: similar to block size, most common key length 128 bits.
• Number of rounds: a single round offers inadequate security but that multiple
rounds offer increasing security. A typical size is 16 rounds.
13

fi
Plaintext (2 bits)
L0 bits bits R0
• Data Encryption Standard Round 1
K1
• 16 rounds of processing F
Round n
Kn
Ln Rn
Ln + 1 Rn + 1
Ciphertext (2 bits)
14

L0 bits bits R0
• Decryption DES Round 1
K1
Round i
Ki
Li Ri
Round n
Kn
Ln Rn
Ln + 1 Rn + 1
16

fi
20

fi
21

fi
22

fi
23

fi
24

fi
25

fi
26

fi
• Output f2: 1 1 1 0 1 1 0 1
• Ciphertext: 0 1 1 1 0 1 1 1
27

fi
key
28

fi
K1 K2
(a) Encryption
A B
K3 K2 K1 P E D
Symmetric Encryption:
K3 K2 Triple DES
K1 (a) Encryption
K3 K2
B A
C D B E A D P
• 3 DES
C uses three D keys and threeE executions D of theCDES P algorithm.
D
B
E
A
The
644 function
CHAPTER 20 /follows
SYMMETRICan encrypt-decrypt-encrypt
AND MESSAGE CONFIDENTIALITY(EDE) sequence(b) Decryption
(b) Decryption
ENCRYPTION
(b) Decryption Figure 20.2 Triple DES
Figure 20.2 Triple K
DES K2 K3
Figure 20.2 Triple DES
1
3DES uses three keys and three executions o
tion follows an encrypt-decrypt-encrypt (EDE) sequ
3DES uses three keys and A
three B
executions of the
644 CHAPTER P
20 / E
SYMMETRIC ENCRYPTION D
3DES uses three keys and three executions AND MESSAGE DESDESC algorithm.
E CONFIDENTIALITY
of the algorithm. The The
func- func-
C = E(K , D(K , E(K , 3 2 1
C E(K
C ==E(K , D(K
3, 3D(K , E(K
, E(K 1K, p)))
1, p)))
P = plaintext
K 3 K 2 2 2 1 E[K, X] = encryption of X using key K
where
where
P
A B D[K, Y] = decryption of Y using key K
C
E D E
ciphertext B A Decryption is simply the same operation with t
CC==ciphertext
C D E D P
• Decryption
plaintext
(a) Encryption
is simply the same operation with the key reversed P = D(K , E(K , D(K , 1 2 3
K1 K2
(a) Encryption
A B
P E D
Symmetric Encryption:
K3 K2 Triple DES
K1 (a) Encryption
K3 K2
The
644 function
CHAPTER 20 /follows
SYMMETRICan encrypt-decrypt-encrypt
ENCRYPTION AND MESSAGE CONFIDENTIALITY(EDE) sequence(b) Decryption
(b) Decryption Figure 20.2 Triple DES
K K2 K3
Figure 20.2 Triple DES
1
3DES uses three keys and three executions o
tion follows an encrypt-decrypt-encrypt (EDE) sequ
A B
3DES uses P
three keysEand
three D
executions
of the C
E DES algorithm. The func-
C = E(K 3, D(K 2, E(K1,
where
tion follows an encrypt-decrypt-encrypt (EDE) sequence (Figure 20.2a):
(a) Encryption
C = ciphertext
P = plaintext
C
K
= E(K 3, D(K
K 2
, E(K1, p)))
K
3 2 1 E[K, X] = encryption of X using key K
where D[K, Y] = decryption of Y using key K
K1 K2
(b)
(a)Decryption
Encryption
A B
Figure 20.2 Triple DES P E D
Symmetric Encryption:
K3 K2 Triple DES
K1 (a) Encryption
3DES uses three keys and three executions of the DES algorithm. The func-
K3 K2
tion follows an encrypt-decrypt-encrypt (EDE) sequence (Figure 20.2a):
B and three executions
A
• 3 DES
C uses three
D Ckeys
= E(K 3 , E 2
D(K , E(K 1, p))) D of theCDES
P algorithm.
D
B
E
A
whereThe
644 function
CHAPTER 20 /follows
SYMMETRICan encrypt-decrypt-encrypt
ENCRYPTION AND MESSAGE CONFIDENTIALITY(EDE) sequence(b) Decryption
(b) Decryption Figure 20.2 Triple DES
C = ciphertext K1 K3 K2
Figure 20.2 Triple DES 3DES uses three keys and three executions o
P = plaintext tion follows an encrypt-decrypt-encrypt (EDE) sequ
A B
E[K, X] = encryption
P of
E X using key D K
3DES uses three keys and three executions of the C
E DES algorithm. The func-
C = E(K 3, D(K 2, E(K1,
where
tion D[K,
follows
Y]an= encrypt-decrypt-encrypt (EDE)
decryption of Y using(a)key K sequence (Figure 20.2a):
Encryption
C = ciphertext
P = plaintext
Decryption is simply the C = E(K
K3 same operation
3 , D(K , E(K ,
K2 2 with1theKkeys
p))) reversedE[K, (Figure 20.2b):
1 X] = encryption of X using key K
where D[K, Y] = decryption of Y using key K
P = D(K1, E(K2, D(K3, C)))
C = ciphertext B A Decryption is simply the same operation with t
C D E D P
•There
Can triple DES reduce
is no cryptographic
P = plaintext
to singletoDES?
significance the use of decryption for the second P = D(K1, E(K2, D(K3,
State
Symmetric Encryption:
Figure AES
20.4 AES Encryption Round
5. Only the Add Round Key stage makes use of the key. For this re
cipher begins and ends with an Add Round Key stage. Any ot
• Advanced encryption standard (AES) [more secure and ef cient]
applied at the beginning or end, is reversible without knowledge
and so would add no security.
• Block length 128 bits
• Key length can be6. The
128,Add
192,Round
or 256Key
bitsstage by itself would not be formidable. The o
stages together scramble the bits, but by themselves would provide n
• Not a Feistel structure, processes
because theuse
they do not entire
the data block
key. We caninview
parallel during
the cipher as each
alternat
tions of and
round using substitutions XORpermutation.
encryption (Add Round
[Feistel Key) ofhalf
structure: a block,
of thefollowed
data
bling the
block is used to modify of the block
other (the
half, other
and thenthree stages),are
the halves followed by XOR encry
swapped.]
so on. This scheme is both efficient and highly secure.
• Key operations: substitute bytes, shift rows, mix columns, and add round key.
7. Each stage is easily reversible. For the Substitute Byte, Shift Row
• All operations are Columns
reversible: for substitute
stages, an inversebytes, shift
function rows,inmix
is used the columns,
decryptionan algo
inverse function istheused
AddinRound
the decryption;
Key stage, theforinverse
add round key, the
is achieved inverse the
by XORing is sa
achieved by XOR the keysame
to theround
block, key
usingtothe
theresult — A ⊕ A ⊕ B = B.
blockthat
8. Asthat
• It is easy to verify with most block
decryption ciphers,
does the the
recover decryption
plaintextalgorithm makes u
by reversible
operations. expanded key in reverse order. However, the decryption algorit
identical to the encryption algorithm. This is a consequence of the
structure of AES.
32

fi
Symmetric
646
Encryption: AES
CHAPTER 20 / SYMMETRIC ENCRYPTION AND MESSAGE CONFIDENTIALITY
Round 10
Substitute bytes Expand key Inverse sub bytes
Round 9
Inverse sub bytes
Substitute bytes
Shift rows
Round 9
Round 1
Round 10
Ciphertext Ciphertext
(a) Encryption (b) Decryption
Figure 20.3 AES Encryption and Decryption
33

Symmetric
648
Encryption: AES CHAPTER 20 / SYMMETRIC ENCRYPTION AND MESSAGE CONFIDENTIALITY
9. Once it is established that all four stages are reversible, it is easy to verify
that decryption does recover the plaintext. Figure 20.3 lays out encryption
and decryption going in opposite vertical directions. At each horizontal point
• Substitute Bytes Transformation (e.g., the dashed line in the figure), State is the same for both encryption and
decryption.
20.3 / ADVANCED ENCRYPTION STANDARD 649
• AES
Table 20.2 de nes
AES S-Boxes 10. a
The16·16
final round matrix
of bothof byte values,
encryption called
and decryption anofS-box
consists only three
stages. Again,
(a) S-box this is a consequence of the particular structure of AES and is
required toymake the cipher reversible.
0 1 2 3 4 5 6 7 8 9 A B C D E F
0 63 7C 77 7B F2 6B 6F C5 30 01 67 2B FE D7 AB 76
1
2
CA
B7
82
FD
Algorithm
C9
93
7D FA
26 36
59
3F
Details
47 F0 AD D4
F7 CC 34 A5
A2
E5
AF
F1
9C
71
A4
D8
72
31
C0
15
3 04 C7
We now look briefly at the principal elements
23 C3 18 96 05 9A 07 12 75
of AES in more detail.
80 E2 EB 27 B2
4 09 83 2C 1A 1B 6E 5A A0 52 3B D6 B3 29 E3 2F 84
5 53 D1 00 ED 20 FC BI 5B 6A CB BE 39 4A 4C 58 CF
6 S
D0 EF FB B
AA UBSTITUTE
43 4D T33YTES
85 45RANSFORMATION
F9 02 7F 50 TheA8forward substitute byte transformation,
3C 9F
x 7 51 A3
8F
called 92 40
9D
SubBytes, 38 F5
is aBC B6
simple DA 21
table 10 FF
lookup. F3
AESD2
defines a 16·16 matrix of byte values,
8 CD 0C 13 EC 5F 97 44 17 C4 A7 7E 3D 64 5D 19 73
9 60 81 4Fcalled
DC 22an 2A
S-box 90 (Table
88 46 EE20.2a),
B8 14that
DE contains
5E 0B DBa permutation of all possible 256 8-bit
A E0 32 3Avalues. Each individual byte of State isE4mapped
0A 49 06 24 5C C2 D3 AC 62 91 95 79 into a new byte in the following
B E7 C8 37 6D 8D D5 4E A9 6C 56 F4 EA 65 7A AE 08
C BA 78
way:
25 2E
The leftmost
1C A6 B4 C6
4E8 bits
DD 74
of the
1F
byte are used as a row value and the rightmost
4B BD 8B 8A
D 70 3E B54 bits
66 are
48 used
03 F6 as 0E a 61 column
35 57 value.
B9 86 These
C1 1D row9E and column values serve as indexes
E E1 F8
into the S-box to select a unique 8-bit output value. For example, the hexadecimal
98 11 69 D9 8E 94 9B 1E 87 E9 CE 55 28 DF
value4 {95} references row 9, column 5 of the S-box, which contains the value {2A}.
F 8C A1 89 0D BF E6 42 68 41 99 2D 0F B0 54 BB 16
Example:
2
3
54
08
7B
2E
94
A1
32
66
A6
28
C2
D9
EA 3D
23
24 B2
04
EE
76
4C
5B
65
95
A2
0B
49
8542
6D
FA
8B
C3
D1
4E
25
87 F2 4D 97
4 72 F8 F6 64 86 68 9883 16 45
D4 A4 5D
5C CC 965D 65 B6 92 EC 6E 4C 90
5 6C 70 48 50 FD ED B9 DA 5E 15 46 57 A7 8D 9D 84
6 90 D8 AB 00 8C BC 5C 0A
D3 33
F7 E4 98
58 05 B0B8 B3 45 06 4A C3 46 E7
x 7 D0 2C 1E 8F CA 3F 0F 02 C1 AF BD 03 01 13 8A 6B
8 3A 91 11 41 4F 67 F0 EA
DC 2D
97 F2 AD
CF CE C5F0 B4 E6 73 8C D8 95 A6
9 96 AC 74 22 E7 AD 35 85 E2 F9 37 E8 1C 75 DF 6E
A 47 F1 1A 71 1D 29 C5 89 6F B7 62 0E AA 18 BE 1B
B FC 56 3E 4BThe
C6 D2inverse
79 20 substitute
9A DB C0 byte
FE transformation,
78 CD 5A FA called InvSubBytes, makes use of
C 1F DD
the inverse S-box shown in Table 20.2b.
A8 33 88 07 C7 31 B1 12 10 59 27 80
34Note, for example, that the input {2A} pro-
EC 5F
D 60 51 7F A9 19 B5 4A 0D 2D E5 7A 9F 93 C9 9C EF

fi
0 63 7C 77 7B F2 6B 6F C5 30 01 67 2B FE D7 AB 76
1 CA 82 C9 7D FA 59 47 F0 AD D4 A2 AF 9C A4 72 C0
2 B7 FD 93 26 36 3F F7 CC 34 A5 E5 F1 71 D8 31 15
3 04 C7 23 C3 18 96 05 9A 07 12 80 E2 EB 27 B2 75
4 09 83 2C 1A 1B 6E 5A A0 52 3B D6 B3 29 E3 2F 84
5 53 D1 00 ED 20 FC BI 5B 6A CB BE 39 4A 4C 58 CF
Symmetricx
648
Encryption: AES
6
7
8
D0
51
CD
EF
A3
0C
AA
40
FB
8F
CHAPTER
13 EC 5F 97
43
92
4D
9D
17
33
38
20 /44 SYMMETRIC
85
F5
45
BC
3D 64
B6
C4 A7 7E ENCRYPTION
5D
F9
19 AND
73
02
DA
7F
21
50
10
3C
FF
MESSAGE CONFIDENTIALITY
9F
F3
A8
D2
9 60 81 4F DC 22 2A 90 88 46 EE B8 14 DE 5E 0B DB
A E0 32 3A 0A 49 06 24 5C C2 D3 AC 62 91 95 E4 79
B E7 C8 37 6D9. 8DOnce
D5 4E it isA9established
6C 56 F4 EA that65 all7Afour
AE stages
08 are reversible, it is easy to verify
C BA 78 25 2E 1Cthat
A6 decryption
B4 C6 E8 DDdoes74 recover
1F 4B BD the8B plaintext.
8A Figure 20.3 lays out encryption
D 70 3E B5 66 48 03 F6 0E 61 35 57 B9 86 C1 1D 9E
andD9 decryption going inE9opposite vertical directions. At each horizontal point
• Inverse Substitute Bytes Transformation
E
F
E1
8C
F8
A1
98
89
11
0D BF
69
(e.g.,
E6 the
8E
42
94
dashed
68
9B
41
1E 87
99line
CE
2D in0Fthe
55 28
B0 figure),
54
DF
BB State
16 is the same for both encryption and
decryption.
• Inverse S-box
10. The final round of both encryption and decryption consists of only three
(b) Inverse S-box
stages. Again, y this is a consequence of the particular structure of AES and is
0 1 2 3 4required
5 6 to
7 make8 9 theA cipher
B C reversible.
D E F
0 52 09 6A D5 30 36 A5 38 BF 40 A3 9E 81 F3 D7 FB
1 7C E3 39 82 9B 2F FF 87 34 8E 43 44 C4 DE E9 CB
2 54 7B 94 Algorithm
32 A6 C2 23 Details
3D EE 4C 95 0B 42 FA C3 4E
3 08 2E A1 66 28 D9 24 B2 76 5B A2 49 6D 8B D1 25
4 72 F8 F6 We now look briefly at the principal elements
64 86 68 98 16 D4 A4 5C
92 of-A
CC low
AES5D correlation
in more
65 detail.
B6 between input bits and
5 6C 70 48 50 FD ED B9 DA 5E 15 46 57 A7 8D 9D 84
x
6
7
90
D0
D8 AB
SUBSTITUTE
2C 1E
8F CA 3F
00 8C BC
BYTES
0F 02
D3 0A F7
TRANSFORMATION
C1 AF BD 03 01
E4
13
58
The
8A
05 B8
output bits
B3 45 06
6B forward substitute byte transformation,
8 3A 91 11 called
41 4F SubBytes,
67 DC EA is97 a simple
F2 CF table
CE F0lookup.
B4 E6 AES
73 defines a 16·16 matrix of byte values,
9
A
96 AC 74
47 F1 1A
22
71
E7 AD 35
called
1D
an29 S-box
C5
85
89
E2
(Table
6F
F9
B7
37 E8
20.2a),
62
1C 75 DF 6E
that contains
0E AA 18 BE 1B
-The output
a permutation cannot
of all possible be described as a
256 8-bit
3E values.
C6 Each 79 individual C0 FEof 78State
9A DB byte is mapped into a new byte in the following
B
C
FC 56
1F DD A8
4B
33 88
D2
07 C7
20
31 B1 12 10 59 27
CD 5A
80
FA
EC 5F simple mathematical function of the input.
way: The leftmost 4 bits of the byte are used as a row value and the rightmost
D 60 51 7F A9 19 B5 4A 0D 2D E5 7A 9F 93 C9 9C EF
E A0 E0
4 bits are used
3B 4D AE 2A F5 B0
as C8
a column
EB BB 3C
value.
83
These
53 99
row and column values serve as indexes
61
F 17 2B 04 into the 77S-box
7E BA D6 to26 select
E1 69 a 14
unique
63 55 8-bit
21 output
0C 7D value. For example, the hexadecimal
4
value {95} references row 9, column 5 of the S-box, which contains the value {2A}.
Accordingly, the value {95} is mapped into the value {2A}.
• Leftmost 4 bits Here— is anrow example index, rightmost
of the SubBytes 4 bits — column index, check S-
transformation:
box for 8-bit outputThe S-box value is constructed using properties of finite fields. The topic of finite
fields is beyond the scope of this book; it is discussed in detail in [STAL14a].
Example: EA 04 65 85 87 F2 4D 97
83 45 5D 96 EC 6E 4C 90
5C 33 98 B0 4A C3 46 E7
F0 2D AD C5 8C D8 95 A6
87 F2 4D 97 87 F2 4D 97
EC 6E 4C 90 6E 4C 90 EC
Example:
4A C3 46 E7 46 E7 4A C3
8C D8 95 A6 A6 8C D8 95
36
The inverse shift row transformation, called InvShiftRows, performs the cir-

87 F2 4D 97 87 F2 4D 97
4A
6E
C3
4C
46
90
E7
6E
46
4C
E7
90
4A
EC
C3
8C D8 95 A6 A6 8C D8 95
Example: 87 F2 4D 97 47 40 A3 4C
6E 4C 90 EC 37 D4 70 9F
46 E7 4A C3 94 E4 3A 42
A6 8C D8 95 ED A5 A6 BC
87 F2 4D 97 47 40 A3 4C
Example: 87
6E
6E 4C
4C 90
90 EC
EC 37
37 D4
D4 70
70 9F
9F
46
46 E7
E7 4A
4A C3
C3 94
94 E4
E4 3A
3A 42
42
A6
A6 8C
8C D8
D8 95
95 ED
ED A5
A5 A6
A6 BC
BC
01 ⇤ x = x
<latexit sha1_base64="nwZFI1jFMUpkGxmRujdUZhIKMhA=">AAACM3icbVBNS0JBFJ1nX/b6etWyzZAk6kLmmVQbQWoTrQzyA3wi88ZRB+d9MDMvFPE/temPtAiiRRFt+w+NT4PSLlzmcM493LnHDTmTCqEXI7Gyura+kdw0t7Z3dves/YOaDCJBaJUEPBANF0vKmU+riilOG6Gg2HM5rbuDq6lev6dCssC/U6OQtjzc81mXEaw01bZu0sjOwSEsDaHjQDONCrkh1NBMTxud5oYlmEEF6AQhjyREdlbrMaXf7A8dm9tWCuVRXHAZ2HOQAvOqtK0npxOQyKO+IhxL2bRRqFpjLBQjnE5MJ5I0xGSAe7SpoY89Klvj+OYJPNFMB3YDodtXMGZ/O8bYk3LkuXrSw6ovF7Up+Z/WjFT3ojVmfhgp6pPZom7EoQrgNEDYYYISxUcaYCKY/iskfSwwUTpmU4dgL568DGqFvH2WL94WU+XLeRxJcASOQQbY4ByUwTWogCog4AE8gzfwbjwar8aH8TkbTRhzzyH4U8bXN7jGogo=</latexit>
The mapping is designed to provide a good mixing among the bytes of each
column. The mix column transformation combined with the shift row transforma-
02 ⇤ x x left most digit istion ensures
0 —> that after
binary a few rounds, all output bits depend on all input bits.
multiplication
x left most digit isADD ROUND
1DD—> shift Kleft
OUND TRANSFORMATION
EY by
EY RANSFORMATION forward
In the1B
1, then XOR with (0001add round
1011) key
transformation, called AddRoundKey, the 128 bits of State are bitwise XORed
03 ⇤ x = (02 with the 128 bits of the round key. The operation is viewed as a column-wise
01) ⇤ x = (02 ⇤ x) x
87=1000 0111 02*87: 1) shift left by 1: 0000 1110 2) XOR with 1B: 0001 0101
6E=0110 1110 02*6E=1101 1100 03*6E=(02*6E) XOR 6E= 1011 0010
46=0100 0110 01*46=0100 0110 XOR
A6=1010 0110 01*A6=1010 0110
38 0100 0111 —> 47

Symmetric Encryption: AES
ED A5 A6 BC ED A5 A6 BC 1E 84 E7 D2
The first matrix is State, and the second matrix is the round key.
State Key
The inverse add round key transformation is identical to the forward a
The first matrix is State,
round and
The the issecond
first matrix
key transformation, matrix
State, and the
because isoperation
second matrix
the XOR the
is the round
round key. key.
is its own inverse.
The inverse add round39 key transformation is identical to the forward add

Symmetric
46 Encryption: Stream Cipher
CHAPTER 2 / CRYPTOGRAPHIC TOOLS
652 CHAPTER 20 / SYMMETRIC ENCRYPTION AND MESSAGE CONFIDEN 652 CHAPTER 20 / SYMMETRIC ENCRYPTION AND MESSAGE CONFIDEN
P1 P2 Pn
Encryption
b structure
structure a key
a key is binput
is input to atopseudorandom
b a pseudorandom bitbitgenerator
generatorthat
thatproduc
produ
8-bit 8-bit numbers
numbersK that Ethat
crypt are
nare apparently
apparently random.
random. AApseudorandom
pseudorandomstream
stream
• Stream cipher
K Encrypt
b
processes
K Encrypt
b
theunpredictable
input
unpredictable without
elements
without knowledge
b knowledge
continuously,
of of
thethe inputkey
input keyand
andthat
thathas
has an
an aa
producingC1 output one element atdoma character.
time, asThe output of the generator, keystream,isis co
calleda akeystream, co
C2 dom character. The n it goes
Poutput of the along.
generator, called
at a time
at a time withwith
the the plaintext
plaintext stream
stream using
using thethebitwise
bitwiseexclusive-OR
exclusive-OR
tion. For example, if the next byte generated by the generator is 011
tion. For example, if the next byte generated by the generator is 011
• A key is input to a pseudorandom bit generator
next plaintext byte is 11001100, that produces
then the a byte is:
resulting ciphertext
next plaintext byte is 11001100, then the resulting ciphertext byte is:
stream of Cnumbers — key
C stream
1 2 Cn
11001100 plaintext
b b b 11001100 plaintext
Decryption
10100000 ciphertext
Key Key 10100000
⊕ 01101100 ciphertext
key stream
K K
⊕ 01101100
11001100 key stream
plaintext
11001100 plaintext
With a properly designed pseudorandom number genera
cipher can be as secure as block cipher of comparable key length
Pseudorandom byte With a byte
Pseudorandom properly designed pseudorandom number genera
advantage of a stream cipher is that stream ciphers are almost alw
generator cipher can be
generator as secure as block cipher of comparable key length
(key stream generator) (keyuse fargenerator)
stream less code than do block ciphers. The example in this section
advantage of a stream
implemented in justcipher is that
a few lines of stream ciphers
code. Table 20.3are almostexec
compares alw
use farRC4 less code
with than
three do block ciphers.
well-known symmetric The example
block in The
ciphers. this section
advant
k
implemented
cipherk is thatin just
youacanfewreuselineskeys.
of code. Tableif20.3
However, twocompares
plaintexts exec
are e
Plaintext RC4 the withsamethree well-known symmetric
byte stream
Ciphertext key usingPlaintext
a stream cipher,block
then ciphers. The advant
cryptanalysis is often
byte stream byte stream
M ENCRYPTION C cipher is that youIfcan
[DAWS96].
DECRYPTION thereuse
two keys. However, if two plaintexts are e
M ciphertext streams are XORed together
the same
the XOR key of using a stream
the original cipher, If
plaintexts. then cryptanalysis
the plaintexts is often
are text strin
(b) Stream encryption 40 numbers,Iforthe
[DAWS96]. othertwobyte streams with
ciphertext known
streams areproperties, then cryp
XORed together

41

• Stream cipher
• A variable length key 1-256 bytes
• Use key to initialize state vector S (permutation)
• Once S vector is initialized, the input key is no longer used
• Key stream is generated by S (cycling, swapping… ) and take
XOR with plaintext for encryption
42

43

44

45

which the same plaintext block, if repeated, produces different ciphertext blocks.
1 ⊕ D(K, Cj) = Cj - 1 ⊕ Cj - 1 ⊕ Pj = CP
1j C2 CN
on, each cipher block is passed through the decryption algorithm.
ed with the preceding ciphertext block to produce the plaintext
6b.
this works,
t block we can write
of ciphertext, K
vector (IV) isKXORed
Decrypt
an initialization Decrypt K Decrypt
s
C1 = P1 ⊕ Ss [E(K, IV)] C1 C2 CM
(a) Encryption
CM - 1
P1 = C 1 ⊕ Ss [E(K, IV)] IV
Shift register Shift register Shift register
b – s bits s bits b – s bits s bits
holds for subsequent steps in the process. s bits
b – s bits
64 64 64
49

C1 = P1 ⊕ Ss [E(K, IV)]
Therefore,
P1 = C 1 ⊕ Ss [E(K, IV)]
Counter Mode
Although interest in the counter mode (CTR) has increased recently, with applica-
tions to ATM (asynchronous transfer mode) network security and IPSec (IP secu-
• Counter (CTR)
rity), this mode was proposed early on (e.g., [DIFF79]).
Figure 20.8 depicts the CTR mode. A counter equal to the plaintext block
size is used. The only requirement stated in SP 800-38A is that the counter value
• Counter size = plaintext block size
must be different for each plaintext block that is encrypted. Typically, the counter
is initialized to some value and then incremented by 1 for each subsequent block
(modulo 2b, where b is the block size). For encryption, the counter is encrypted and
• Counter is initialized to some value and then incremented by 1 for each
then XORed with the plaintext block to produce the ciphertext block; there is no
subsequent block
Counter Counter + 1 Counter + N - 1
P1 P2 PN
C1 C2 CN
(a) Encryption
C1 C2 CN
P1 P2 PN
(b) Decryption
50

• Counter (CTR)
• No chain, multiple blocks process in parallel
• Counter at i block cannot be computed until i-1 prior blocks are computed
• Only need encryption algorithm
51

Summary
• Cryptography
• Context, Ingredients, Classi cation, Attacks
• Symmetric Encryption: Block Cipher
• DES/Triple DES (Feistel Cipher Structure)
• AES
• Symmetric Encryption: Stream Cipher
• RC4
• Cipher Block Modes of Operation
• Electronic Code book (ECB)
• Cipher Block Chaining (CBC)
• Cipher Feedback (CFB)
• Counter (CTR)
52

fi
Thank You
Quiz Time
• 15 minutes
54

COMPSCI4062&5063: Cyber Security Fundamentals
Topic 5: Cryptography II
1
fi
Overview
• Asymmetric Encryption
• Con dentiality vs. Authentication
• Requirements
• Algorithms
• RSA
• Dif e-Hellman Key Exchange
• Tutorial Questions
2
fi
fi
Bobs’s
public key
ring
Joy
Ted
Mike Alice
Transmitted X=
X ciphertext D[PRa, Y]
Y = E[PUa, X]
Plaintext Plaintext
Encryption algorithm Decryption algorithm
input output
(e.g., RSA)
Bob Alice
(a) Encryption with public key
3 X=
Transmitted
fi
Bobs’s
public key
ring
Joy
Ted
Mike Alice
Transmitted X=
X ciphertext D[PRa, Y]
Y = E[PUa, X]
Plaintext Plaintext
Encryption algorithm Decryption algorithm
input output
(e.g., RSA)
Bob Alice
(a) Encryption with public key
4 X=
Transmitted
fi
Plaintext Plaintext
Encryption algorithm Decryption algorithm
input output
(e.g., RSA)
Alice’s
public key
ring
Joy
Ted
Mike Bob
Transmitted X=
X ciphertext D[PUb, Y]
Y = E[PRb, X]
Plaintext Plaintext
Encryption algorithm Decryption algorithm
input output
(e.g., RSA)
Bob Alice
keys.
ed on Requirements
Diffie
two and Hellman
related keys. for
Diffie Public-Key
postulated
and thisbased
Hellman Cryptography
system without
on two
postulated dem-
related
this keys.
system Diffie and Hellman
without dem- postulat
The cryptosystem illustrated in Figureonstrating 2.6 depends
that on algorithms
such a cryptographic exist. algorithm
However, they did
gorithms
rating thatexist.
such However,
algorithms they did
exist. lay out the conditions that
basedThe oncryptosystem
two related keys. DiffieHowever,
illustrated in Figure
and Hellman
such
they did lay out
2.6 postulated
depends
algorithms must on the
this
fulfill
conditions
a cryptographic
system
[DIFF76]:
that
without algorithm
dem-
hfulfill [DIFF76]:
algorithms
based
Asymmetric
onstrating on must
two
that fulfill
related
such [DIFF76]:
keys. Diffie
Encryption:
algorithms exist. and Hellman
However, postulated
Conditions
they did lay out this system
the without
conditions dem-
that
onstrating that such algorithms exist. 1.However,
It is computationally
they did easy
lay out for a party
the B to gener
conditions that
nally
It iseasy
such for a party
algorithms
computationally must B to generate
fulfill
easy [DIFF76]:
for a partya pair
B to(public
generatekey a
private key PRb).
PU
pairb , (public key PU ,
b
such algorithms
. private key PR ). must fulfill [DIFF76]:
1. It is computationally
b easy for a party 2. ItBis to generate a pair
computationally easy(public key PU
for a sender ,
A, bknow
nally easy
1.• Computationally
It
It is private for
is a sender A, easyeasy
knowingfor atheparty B tokey
public generate
and
key PRb). easy for a sender A, knowing the public key(public
computationally
computationally for a party
messageB to
to the
generate
be a pair
encrypted, a of to
pair
M, keys
thekey
generate
and the PU
corre
b
ncrypted,
message M,to to
private
be generate
key PR
encrypted, the
). corresponding
to generate ciphertext:
2. It • isComputationally
computationallyeasy b M,easy for sendercorresponding
foraasender the A,knowing
A, knowingthe theciphertext:
C =
public
public E(PU
key
key b,and
and M)the
2. It
message Cis=
the computationally
toE(PU
plain b, M), to
betext
encrypted, easy
M,
Cgenerate
= to for
E(PU aM)
generate
the
,
3. sender
It the A,
corresponding
is knowing
corresponding
computationally the
easy public
ciphertext:
cipher-text
for the key and
receiver B to the
dec
b
message to be encrypted, M, to generate using thethe corresponding
private key to recover ciphertext:
the original messa
ally easy for the receiver B to C
decrypt = E(PU
the resulting, M) ciphertext
It is computationally easy for the receiver B bto decrypt the resulting ciphertext
key to recover the original message: C = E(PUb, M) M = D(PRb,C) = D[PRb, E(PU
using
3. Itthe is private key to recover
computationally easy the
for original
the receiver message:
BBtotodecrypt thethe
resulting ciphertext
• Computationally easy for a receiver 4. It is
decrypt
computationally
cipertext
infeasible for an
using
opponent, k
M = D(PR 3. It
using is
thecomputationally
,C) = D[PR
private key ,
D(PR E(PU
to easy,
recover for
M)] the
the receiver
original B to
message:decrypt the resulting ciphertext
the M =key b,C) = D[PRbto , E(PU b, M)]
b private b b
using the private key to recover the original message:determine the private key, PRb.
nally
It isinfeasible for an opponent,
computationally M = D(PR
infeasible knowing
for b,C) =the D[PR
an opponent, public key, bPU
b, knowing
E(PU b, public key, PUb,
, M)]
the
private key, PR M = D(PRbTable
b. private key, ,C) = D[PR b, E(PU b,Public-Key
M)]
to4.determine the
It is computationally infeasible PR . 2.3 Applications for
b for an opponent, knowing the public Cryptosystems
key, PUb,
4. determine
to It is computationally
the private infeasible
key, PRb. for an opponent, knowing the public Symmetrickey, PUb
Key
for Public-Key to determine the private key, PR
Cryptosystems b.
Algorithm Digital Signature Distribution
e 2.3 Applications for Public-Key Cryptosystems
RSA Yes Yes
Table 2.3 Applications for Public-Key
Symmetric Key Cryptosystems
Encryption
Symmetric Key of
Diffie-Hellman Encryption
No of Yes
al Table 2.3 Applications
Signature for Public-Key
Distribution Cryptosystems
Secret Keys
orithm Digital Signature Distribution
DSS
Symmetric Key Secret
Yes Keys
Encryption of No
Yes
A Algorithm Yes
Yes Yes Yes
Symmetric
Elliptic Curve
Distribution Key Yes Encryption
Secret
Yes Keys of Yes
Digital Signature
No Algorithm
ie-Hellman NoYes
Digital Signature YesNo Distribution No Secret Keys
RSA Yes 6 Yes Yes
RSA One of the first public-key schemes was developed in 1977 by Ron Rivest, A
Shamir, and Len Adleman at MIT and first published in 1978 [RIVE78]. The RS
scheme has since reigned supreme as the most widely accepted and implemente
approach to public-key encryption. RSA is a block cipher in which the plaintext an
ciphertext are integers between 0 and n – 1 for some n.
In 1977, the three inventors of RSA dared Scientific American readers to decod
a cipher they printed in Martin Gardner’s “Mathematical Games” column. The
offered a $100 reward for the return of8a plaintext sentence, an event they predicte
Algorithms: RSA
gcd(f(n)
(n), d) = gcd(
ed mod
f(n). Equivalently, f(n) == 11; that is, the greatest common divisor of f(n)
gcd(f(n),d)
and d is 1.
some elementary concepts from number theory. For a review, see Appendix B.
Figure 21.5 summarizes the RSA algorithm. Begin by selecting two prime
numbers,
me elementary p and from
concepts q, andnumber
calculating theirFor
theory. product n, which
a review, see isAppendix
the modulus B. for encryp-
e elementary concepts
tion and fromNext,
decryption. number theory.
we need For a review,
the quantity see Appendix
f(n). Then B. e that
select an integer
is relatively prime to f(n) [i.e., the greatest common divisor of e and f(n) is 1].
Finally, calculate d as the multiplicative inverse of e, modulo f(n). It can be shown
that d and e have the desired properties.
Suppose that user Acommon
has published
divisoritsexamples:
public key gcd(12,
and that13) user
=B 1 wishes to
<latexit sha1_base64="wWHItR9loavLfta72aZ+eZYB1W0=">AAACJ3icbVDLSgNBEJz1GeMr6tHLYBAUJOyqqAiK6MWjglEhCWF20hsH57HM9ErCkr/x4q94EVREj/6JE83BV5+Kqi66uuJUCodh+BYMDY+Mjo0XJoqTU9Mzs6W5+XNnMsuhyo009jJmDqTQUEWBEi5TC0zFEi7i66O+fnED1gmjz7CbQkOxthaJ4Aw91Szt1xE6mNO2NyE4pNwoZTRtiRvhjKXQYSqV4HZpj+Z1q2ibt3or0fpatLG6F9FmqRxWws+hf0E0AGUymJNm6bHeMjxToJFL5lwtClNs5Myi4BJ6xXrmIGX8mrWh5qFmClwj//yzR5c906KJj5UY3Y/q2e+OnCnnuir2m4rhlfut9cn/tFqGyU4jFzrNEDT/OpRkkqKh/dJ8GxY4yq4HjFvhs1J+xSzj6Kst+hKi3y//BefrlWirsnm6WT44HNRRIItkiayQiGyTA3JMTkiVcHJL7skTeQ7ugofgJXj9Wh0KBp4F8mOC9w84mKTN</latexit>
greatest
send the message M to A. Then B calculates C = Me (mod n) and transmits C. On <latexit sha1_base64="y53hTSet6M37076aT7YD/6nzo/8=">AAAB+nicbVDLSgMxFM3UV62vqS7dBItQQcpMKdWNUHTjsoJ9QDuUTCbThiaZIckoZeynuHGhiFu/xJ1/Y9rOQlsPXDiccy/33uPHjCrtON9Wbm19Y3Mrv13Y2d3bP7CLh20VJRKTFo5YJLs+UoRRQVqaaka6sSSI+4x0/PHNzO88EKloJO71JCYeR0NBQ4qRNtLALqZ9yeEQB9OyWz2vn13VB3bJqThzwFXiZqQEMjQH9lc/iHDCidCYIaV6rhNrL0VSU8zItNBPFIkRHqMh6RkqECfKS+enT+GpUQIYRtKU0HCu/p5IEVdqwn3TyZEeqWVvJv7n9RIdXnopFXGiicCLRWHCoI7gLAcYUEmwZhNDEJbU3ArxCEmEtUmrYEJwl19eJe1qxa1Xane1UuM6iyMPjsEJKAMXXIAGuAVN0AIYPIJn8ArerCfrxXq3PhatOSubOQJ/YH3+AM1Rkmg=</latexit>
gcd(14, =2
keys were generated as follows: 12
Algorithms:
ement. We need to find aRSA
relation-
M • Preliminary
multiplicative inverses modulo
2. f(n), is the Euler totient function.
shown in Appendix B that for p, q
to as the Euler totient of n, is the
atively prime to n. The relationship <latexit sha1_base64="O7pERFAvnKet03n6uJebwQWm9pA=">AAAB/HicbVDLSgMxFM3UV62v0S7dBIswXVhmpKgboejGZQX7gHYomTRtQzOZNMkIw1B/xY0LRdz6Ie78G9N2Ftp64F4O59xLbk4gGFXadb+t3Nr6xuZWfruws7u3f2AfHjVVFEtMGjhikWwHSBFGOWloqhlpC0lQGDDSCsa3M7/1SKSiEX/QiSB+iIacDihG2kg9u9gVI+qISfnaEWde2ZmY1rNLbsWdA64SLyMlkKHes7+6/QjHIeEaM6RUx3OF9lMkNcWMTAvdWBGB8BgNScdQjkKi/HR+/BSeGqUPB5E0xTWcq783UhQqlYSBmQyRHqllbyb+53ViPbjyU8pFrAnHi4cGMYM6grMkYJ9KgjVLDEFYUnMrxCMkEdYmr4IJwVv+8ippnle8i0r1vlqq3WRx5MExOAEO8MAlqIE7UAcNgEECnsEreLOerBfr3fpYjOasbKcI/sD6/AGBd5K9</latexit>
= 1
<latexit sha1_base64="zkMELAPnXmiyaghS5NZH228fiAk=">AAACRnicbVA9TxtBFNxzPiBOCE4o0zzFRILGukMIUiLSpAQpBiT7ZO3tvbNX7Jd23yGsk39dmtR0+QlpUgRFadkzLhLISCuNZua91ZvCKRkoTb8nnSdPnz1fW3/Rfflq4/Vm783bs2BrL3AorLL+ouABlTQ4JEkKL5xHrguF58Xlp9Y/v0IfpDVfaO4w13xqZCUFpyhNevnYzeSO2YUx4TU1IAPQDMHUukAPtgJngyR5hSAN4TRuAoWhDXED22YbuCnBo+JtRs3BeakRyLbeYDHp9dNBugQ8JtmK9NkKJ5Pezbi0otZoSCgewihLHeUN9ySFwkV3XAd0XFzyKY4iNVxjyJtlDQv4EJUSKuvjMwRL9e+JhusQ5rqISc1pFh56rfg/b1RT9TFvpHE1oRH3H1W1as9sO4VSehQUry8lFz7WJUDMuOeCYl/dWEL28OTH5GxvkB0M9k/3+0fHqzrW2Tv2nu2wjB2yI/aZnbAhE+wr+8F+sdvkW/Iz+Z38uY92ktXMFvsHHXYHQeuwaw==</latexit>
(n) is the number of positive integers less than n and relatively prime to n.
13
2. Calculate n = pq = 17 * 11 = 187.
3. Calculate f(n) RSA
Algorithms: = (p - 1)(q - 1) = 16 * 10 = 160.
Example:
<latexit sha1_base64="DS5Rx5wx+bnB2Q33V+2zKYWcIho=">AAACGnicbZDLSgMxFIYzXut4G3XpJliEClImpbZuBopuXFawF+iUkknTNjSTGZOMUIY+hxtfxY0LRdyJG9/G9LLQ1gOBj/8/h5PzBzFnSrvut7Wyura+sZnZsrd3dvf2nYPDuooSSWiNRDySzQArypmgNc00p81YUhwGnDaC4fXEbzxQqVgk7vQopu0Q9wXrMYK1kToOir3CObz3ytD3oS08VDRg+/GA5cSZVzJMvYuJB+2uh5ChjpN18+604DKgOWTBvKod59PvRiQJqdCEY6VayI11O8VSM8Lp2PYTRWNMhrhPWwYFDqlqp9PTxvDUKF3Yi6R5QsOp+nsixaFSozAwnSHWA7XoTcT/vFaie5ftlIk40VSQ2aJewqGO4CQn2GWSEs1HBjCRzPwVkgGWmGiTpm1CQIsnL0O9kEelfPG2mK1czePIgGNwAnIAgTKogBtQBTVAwCN4Bq/gzXqyXqx362PWumLNZ47An7K+fgCgxpsH</latexit>
p = 2, q = 7 Encryption
Plaintext: n = 14 M6 n
(n) = 6
Ciphertext: e=5 C = M e (mod n)
dd==11
17 (multiple choices)
<latexit sha1_base64="T8Em9A2qcjNA62VkPD5oECckyHc=">AAAB63icbVBNS8NAEJ3Ur1q/qh69LBbBU0lErBeh6MVjBfsBbSibzaZdursJuxuhhP4FLx4U8eof8ua/cdPmoK0PBh7vzTAzL0g408Z1v53S2vrG5lZ5u7Kzu7d/UD086ug4VYS2Scxj1QuwppxJ2jbMcNpLFMUi4LQbTO5yv/tElWaxfDTThPoCjySLGMEml8IbrzGs1ty6OwdaJV5BalCgNax+DcKYpIJKQzjWuu+5ifEzrAwjnM4qg1TTBJMJHtG+pRILqv1sfusMnVklRFGsbEmD5urviQwLracisJ0Cm7Fe9nLxP6+fmujaz5hMUkMlWSyKUo5MjPLHUcgUJYZPLcFEMXsrImOsMDE2nooNwVt+eZV0LureVf3y4bLWvC3iKMMJnMI5eNCAJtxDC9pAYAzP8ApvjnBenHfnY9FacoqZY/gD5/MHNZKNtA==</latexit>
14
Algorithms: RSA
• Key generation
<latexit sha1_base64="c74gbttMbsVrAJfA/BZ82qeRdoo=">AAACC3icbZDLSsNAFIYn9VbjLerSzdAi1E1JpF42QtGNywr2Ak0ok8mkHTqZhJmJUEL3bnwVNy4UcesLuPNtnLRZaOsPAz/fOYcz5/cTRqWy7W+jtLK6tr5R3jS3tnd296z9g46MU4FJG8csFj0fScIoJ21FFSO9RBAU+Yx0/fFNXu8+ECFpzO/VJCFehIachhQjpdHAqgTEjeIAusmI1vjJlQNd1zyDGuTUaWgwsKp23Z4JLhunMFVQqDWwvtwgxmlEuMIMSdl37ER5GRKKYkampptKkiA8RkPS15ajiEgvm90yhceaBDCMhX5cwRn9PZGhSMpJ5OvOCKmRXKzl8L9aP1XhpZdRnqSKcDxfFKYMqhjmwcCACoIVm2iDsKD6rxCPkEBY6fhMHYKzePKy6ZzWnfN6465RbV4XcZTBEaiAGnDABWiCW9ACbYDBI3gGr+DNeDJejHfjY95aMoqZQ/BHxucP4gWXwQ==</latexit>
<latexit sha1_base64="IwdLcmZhXBlQkC9MLqXGOymYJ1s=">AAACgHicbVFbb9MwFHbCbYTLCjzycqCiKmItMdoKmhRpghceh7Ruk+qocpzT1poTR7YzqKL+Dv4Xb/wYJJy2D6PjWJY+fRfZ55ysUtK6OP4dhHfu3rv/YO9h9Ojxk6f7nWfPz62ujcCx0Eqby4xbVLLEsZNO4WVlkBeZwovs6kurX1yjsVKXZ25ZYVrweSlnUnDnqWnn56iX0P7R23cUGIuYwx+uOVugwZk2uGo52ktGg9Zy0yAtzOU1Wqjt8crzRzmwV+0BVugcRtBLJptUuiMwBhEzcr5w3Bj9HcBHewmsvQfAIE8GFKJo2unGw3hdcBvQLeiSbZ1OO79YrkVdYOmE4tZOaFy5tOHGSaFwFbHaYsXFFZ/jxMOSF2jTZj3AFbzxTA6+ZX9LB2v2ZqLhhbXLIvPOgruF3dVa8n/apHazT2kjy6p2WIrNQ7NagdPQbgNyaVA4tfSACyP9X0EsuOHC+Z21Q6C7Ld8G5x+GdDQ8/HbYPfm8HcceeUlekz6h5CM5IV/JKRkTQf4E3eAgGIRh2A/fh3RjDYNt5gX5p8Ljvx0ntJQ=</latexit>
6 = 1(5) + 1
Therefore
1=6 1(5)
This gives us:
5d mod 6 = [6 1(5)] mod 6
d= 1 + 6N for any integer N
<latexit sha1_base64="QmxKyeWbc9Qn3wk5SKWjnqMuUbM=">AAACDXicbVC7SgNBFJ31GeMramkzmAiCGHYlRBshaGMVIhgjJEuYndyNQ2Znl5m7YljyAzb+io2FIrb2dv6Nu0kKX6c6nHMv99zjRVIYtO1Pa2Z2bn5hMbeUX15ZXVsvbGxemTDWHJo8lKG+9pgBKRQ0UaCE60gDCzwJLW9wlvmtW9BGhOoShxG4Aesr4QvOMJW6hVLv5MDZr9ZpB+EOE+qHmjI1pEIh9EHTUr00yncLRbtsj0H/EmdKimSKRrfw0emFPA5AIZfMmLZjR+gmTKPgEkb5TmwgYnzA+tBOqWIBGDcZfzOiu6nSGwfxQ4V0rH7fSFhgzDDw0smA4Y357WXif147Rv/YTYSKYgTFJ4f8WFIMaVYN7QkNHOUwJYxrkWal/IZpxjEtMCvB+f3yX3J1WHaq5cpFpVg7ndaRI9tkh+wRhxyRGjknDdIknNyTR/JMXqwH68l6td4mozPWdGeL/ID1/gX65Zmg</latexit>
! 5d = 1(5), d = 1
15
Calculate dh(n) = (p - 1)(q - 1)
Calculate d e mod h(n) = 1
Public key
Select integer e gcd( h(n), e) = 1; 1 6 e 6 h(n)
KU = {e, n}
Algorithms: RSA
Private keyd
Calculate KR = {d,h(n)
d e mod n} = 1
Public key
• Encryption KU = {e, n}
Private key Encryption
KR = {d, n}
Plaintext: M6 n
Ciphertext: C = M e (mod n)
Encryption
Plaintext: n = 14, e = 5, M = 2 M6 n
<latexit sha1_base64="HLcCWbVZ6bP+WomnjJkXLnaEJg0=">AAACDXicbVDLSsNAFJ3UV42vqEs3g1VwUUpSUnUTKHbjRqhgH9DEMplO26GTSZiZCKX0B9z4K25cKOLWvTv/xuljoa0HLhzOuZd77wkTRqWy7W8js7K6tr6R3TS3tnd296z9g7qMU4FJDccsFs0QScIoJzVFFSPNRBAUhYw0wkFl4jceiJA05ndqmJAgQj1OuxQjpaW2dcI9x81D4pXy8MYrQt+HZsWDxfsS9KO4Ax0Xem7bytkFewq4TJw5yYE5qm3ry+/EOI0IV5ghKVuOnahghISimJGx6aeSJAgPUI+0NOUoIjIYTb8Zw1OtdGA3Frq4glP198QIRVIOo1B3Rkj15aI3Ef/zWqnqXgYjypNUEY5ni7opgyqGk2hghwqCFRtqgrCg+laI+0ggrHSApg7BWXx5mdSLBee84N66ufLVPI4sOALH4Aw44AKUwTWoghrA4BE8g1fwZjwZL8a78TFrzRjzmUPwB8bnDyGmlpA=</latexit>
Example:
Ciphertext: C = 25 Decryption
mod 14 =4 C = M e (mod n)
Ciphertext: C
• Decryption
Plaintext: M = C d (mod n)
Decryption
Figure 21.5 The RSA Algorithm
Ciphertext: C
Plaintext: M = C d (mod n)
M = 417 mod 14 = 2
16
As an example of another use of the Diffie-Hellman algorithm, suppose
that in a group of users (e.g., all users on a LAN), each generates a long-lasting
private key and calculates a public key. These public values, together with global
public values for q and a, are stored in some central directory. At any time, user
B can access user A’s public value, calculate a secret key, and use that to send
Algorithms: Diffie-Hellman Key Exchange
an encrypted message to user A. If the central directory is trusted, then this form
of communication provides both confidentiality and a degree of authentication.
Because only A and B can determine the key, no other user can read the message
(confidentiality). User A knows that only user B could have created a message
using this key (authentication). However, the technique does not protect against
• Purpose: Two users exchange a secret key securely that can then
replay attacks.
Alice Bob
Y = c
Select privateq X= 13, ↵ = 2 X A 6 q2 is a primitive root
<latexit sha1_base64="p2D9tAULrBHEkM3O9ao8ieE/u1M=">AAAB9XicbVDLSgNBEOz1GeMr6tHLYBA8SNiNQb0Egl48RjAPSNbQO5lNhsw+nJlVQsh/ePGgiFf/xZt/4yTZgyYWNBRV3XR3ebHgStv2t7W0vLK6tp7ZyG5ube/s5vb26ypKJGU1GolINj1UTPCQ1TTXgjVjyTDwBGt4g+uJ33hkUvEovNPDmLkB9kLuc4raSPcPZefslLRRxH0sFzu5vF2wpyCLxElJHlJUO7mvdjeiScBCTQUq1XLsWLsjlJpTwcbZdqJYjHSAPdYyNMSAKXc0vXpMjo3SJX4kTYWaTNXfEyMMlBoGnukMUPfVvDcR//NaifYv3REP40SzkM4W+YkgOiKTCEiXS0a1GBqCVHJzK6F9lEi1CSprQnDmX14k9WLBOS+Ubkv5ylUaRwYO4QhOwIELqMANVKEGFCQ8wyu8WU/Wi/Vufcxal6x05gD+wPr8AYVGkT4=</latexit>
mod 13 = 1 20
<latexit sha1_base64="Pv+oqCvDCFRez4T6+9QlaGPB+1E=">AAACbXicbZHLSgMxFIYz463W26i48IIEi5dVmRlr60YounFZwV6g05ZMJtOGZi4kGaGU7nxCd76CG1/BtFOwdjwQ+PnO+TnJHzdmVEjT/NT0ldW19Y3cZn5re2d3z9g/aIgo4ZjUccQi3nKRIIyGpC6pZKQVc4ICl5GmO3ya9ptvhAsaha9yFJNOgPoh9SlGUqGe8W53TegEkQcr8OrBgo4DYd7uWr8M2goqZC+gUopuF5CVolLWeJfxlZdsPaNgFs1Zwayw5qIA5lXrGR+OF+EkIKHEDAnRtsxYdsaIS4oZmeSdRJAY4SHqk7aSIQqI6IxnaU3gpSIe9COuTijhjC46xigQYhS4ajJAciCWe1P4X6+dSP++M6ZhnEgS4nSRnzAoIziNHnqUEyzZSAmEOVV3hXiAOMJSfdA0BGv5yVnRsItWuVh6KRWqj/M4cuAUXIAbYIEKqIJnUAN1gMGXZmjH2on2rR/pZ/p5Oqprc88h+FP69Q81xKqf</latexit>
mod 7 = 1
1
2 mod 13 = 2 21 mod 7 = 2
User B Key Generation2
2
mod 13 = 4
22 mod 7 = 4
3
2 mod 13 = 8
Y B = c2X5 B mod
Select private X B X B 6 q4 23 mod 7 = 1
2 mod 13 = 3
24 mod 7 = 2
Calculate public Y B mod13q= 6
6
25 mod 7 = 4
2 mod 13 = 12
7 26 mod 7 = 1
2 mod 13 = 11
Generation of Secret Key by 2User
8
modA13 = 9
K = (YB ) X A mod q 29 mod 13 = 5
210 mod 13 = 10
11
1 to q-1
2 mod 13 = 7
12
Generation of Secret Key
18 by User B
2 mod 13 = 1
X
CHAPTER 21 / PUBLIC-KEY CRYPTOGRAPHY AND MESSAGE AUTHENTICATION
Y A = cX A mod q
Select private X A XA 6 q
Calculate public Y A
Y B = cX B mod q
Select private X B XB 6 q
Calculate public Y B
q = 13, ↵ = 2
<latexit sha1_base64="p2D9tAULrBHEkM3O9ao8ieE/u1M=">AAAB9XicbVDLSgNBEOz1GeMr6tHLYBA8SNiNQb0Egl48RjAPSNbQO5lNhsw+nJlVQsh/ePGgiFf/xZt/4yTZgyYWNBRV3XR3ebHgStv2t7W0vLK6tp7ZyG5ube/s5vb26ypKJGU1GolINj1UTPCQ1TTXgjVjyTDwBGt4g+uJ33hkUvEovNPDmLkB9kLuc4raSPcPZefslLRRxH0sFzu5vF2wpyCLxElJHlJUO7mvdjeiScBCTQUq1XLsWLsjlJpTwcbZdqJYjHSAPdYyNMSAKXc0vXpMjo3SJX4kTYWaTNXfEyMMlBoGnukMUPfVvDcR//NaifYv3REP40SzkM4W+YkgOiKTCEiXS0a1GBqCVHJzK6F9lEi1CSprQnDmX14k9WLBOS+Ubkv5ylUaRwYO4QhOwIELqMANVKEGFCQ8wyu8WU/Wi/Vufcxal6x05gD+wPr8AYVGkT4=</latexit>
Example:
Generation of Secret Key by User A
3
<latexit sha1_base64="FWHlGiNw6LV4nGFiZ6YDf4fzl9E=">AAACD3icbVC7TgJBFJ3FF+Jr1dJmItFYkV0gSkOC2lhiIg/DIpkdBpgws7OZmdWQDX9g46/YWGiMra2df+MAWyh4kpucnHNv7r3HDxlV2nG+rdTS8srqWno9s7G5tb1j7+7VlYgkJjUsmJBNHynCaEBqmmpGmqEkiPuMNPzh5cRv3BOpqAhu9CgkbY76Ae1RjLSROvZxs3NeLkDoSdofaCSleIC3RoL5uwL0uOhCt1CGpY6ddXLOFHCRuAnJggTVjv3ldQWOOAk0ZkipluuEuh0jqSlmZJzxIkVChIeoT1qGBogT1Y6n/4zhkVG6sCekqUDDqfp7IkZcqRH3TSdHeqDmvYn4n9eKdK/UjmkQRpoEeLaoFzGoBZyEA7tUEqzZyBCEJTW3QjxAEmFtIsyYENz5lxdJPZ9zT3PF62K2cpHEkQYH4BCcABecgQq4AlVQAxg8gmfwCt6sJ+vFerc+Zq0pK5nZB39gff4AHZCZiw==</latexit>
X X = 3 ! Y = 2 mod 13 = 8
K = (YB ) A
mod q
A A
XB = 5 ! YB = 25
<latexit sha1_base64="JkMZ4zR6TewHCZsa/VuGI0TXRe0=">AAACD3icbVDLTsJAFJ36RHxVXbqZSDSuSIuAbkgIblxiIg8DtZlOpzBh2mlmphpC+AM3/oobFxrj1q07/8YBulDwJDc5Oefe3HuPFzMqlWV9G0vLK6tr65mN7ObW9s6uubfflDwRmDQwZ1y0PSQJoxFpKKoYaceCoNBjpOUNLid+654ISXl0o4YxcULUi2hAMVJacs2TtlurlCDsCtrrKyQEf4C3WoKFuxLshtyH9lkFll0zZ+WtKeAisVOSAynqrvnV9TlOQhIpzJCUHduKlTNCQlHMyDjbTSSJER6gHuloGqGQSGc0/WcMj7Xiw4ALXZGCU/X3xAiFUg5DT3eGSPXlvDcR//M6iQounBGN4kSRCM8WBQmDisNJONCngmDFhpogLKi+FeI+EggrHWFWh2DPv7xImoW8Xc4Xr4u5ai2NIwMOwRE4BTY4B1VwBeqgATB4BM/gFbwZT8aL8W58zFqXjHTmAPyB8fkDJCuZjw==</latexit>
mod 13 = 6
Generation of Secret Key by User B
K = (YA ) X B mod q
19
Calculate public Y A Y A = cX A mod q
Algorithms: Diffie-Hellman
User B Key GenerationKey Exchange
Y B = cX B mod q
Select private X B XB 6 q
Calculate public Y B
The security of the Diffie-Hellman key exchange lies in the fact that, while it
is relatively easy to calculate exponentials modulo a prime, it is very difficult to cal-
culate discrete logarithms.
q = 13, For
↵ =large
2 primes, the latter task is considered infeasible.
<latexit sha1_base64="p2D9tAULrBHEkM3O9ao8ieE/u1M=">AAAB9XicbVDLSgNBEOz1GeMr6tHLYBA8SNiNQb0Egl48RjAPSNbQO5lNhsw+nJlVQsh/ePGgiFf/xZt/4yTZgyYWNBRV3XR3ebHgStv2t7W0vLK6tp7ZyG5ube/s5vb26ypKJGU1GolINj1UTPCQ1TTXgjVjyTDwBGt4g+uJ33hkUvEovNPDmLkB9kLuc4raSPcPZefslLRRxH0sFzu5vF2wpyCLxElJHlJUO7mvdjeiScBCTQUq1XLsWLsjlJpTwcbZdqJYjHSAPdYyNMSAKXc0vXpMjo3SJX4kTYWaTNXfEyMMlBoGnukMUPfVvDcR//NaifYv3REP40SzkM4W+YkgOiKTCEiXS0a1GBqCVHJzK6F9lEi1CSprQnDmX14k9WLBOS+Ubkv5ylUaRwYO4QhOwIELqMANVKEGFCQ8wyu8WU/Wi/Vufcxal6x05gD+wPr8AYVGkT4=</latexit>
Example:
Here is an example. Key exchange is based on the use of the prime 3
number <latexit sha1_base64="vljjMOWRE7lJhq7z9yk6gFDWsdY=">AAAB+nicbVDLTgIxFO3gC/E16NJNIzFxRWaEIBsSohsTN5jII4GRdDodaGink7ajIcinuHGhMW79Enf+jQVmoeBJbnJyzr259x4/ZlRpx/m2MmvrG5tb2e3czu7e/oGdP2wpkUhMmlgwITs+UoTRiDQ11Yx0YkkQ9xlp+6Ormd9+IFJREd3pcUw8jgYRDSlG2kh9O39Tg5X7EuxxEUC3BGvVvl1wis4ccJW4KSmAFI2+/dULBE44iTRmSKmu68TamyCpKWZkmuslisQIj9CAdA2NECfKm8xPn8JTowQwFNJUpOFc/T0xQVypMfdNJ0d6qJa9mfif1010WPUmNIoTTSK8WBQmDGoBZznAgEqCNRsbgrCk5laIh0girE1aOROCu/zyKmmdF91KsXxbLtQv0ziy4BicgDPgggtQB9egAZoAg0fwDF7Bm/VkvVjv1seiNWOlM0fgD6zPH5UakaI=</latexit>
3 K select
= 6 secret
modkeys13 = 8
<latexit sha1_base64="FWHlGiNw6LV4nGFiZ6YDf4fzl9E=">AAACD3icbVC7TgJBFJ3FF+Jr1dJmItFYkV0gSkOC2lhiIg/DIpkdBpgws7OZmdWQDX9g46/YWGiMra2df+MAWyh4kpucnHNv7r3HDxlV2nG+rdTS8srqWno9s7G5tb1j7+7VlYgkJjUsmJBNHynCaEBqmmpGmqEkiPuMNPzh5cRv3BOpqAhu9CgkbY76Ae1RjLSROvZxs3NeLkDoSdofaCSleIC3RoL5uwL0uOhCt1CGpY6ddXLOFHCRuAnJggTVjv3ldQWOOAk0ZkipluuEuh0jqSlmZJzxIkVChIeoT1qGBogT1Y6n/4zhkVG6sCekqUDDqfp7IkZcqRH3TSdHeqDmvYn4n9eKdK/UjmkQRpoEeLaoFzGoBZyEA7tUEqzZyBCEJTW3QjxAEmFtIsyYENz5lxdJPZ9zT3PF62K2cpHEkQYH4BCcABecgQq4AlVQAxg8gmfwCt6sJ+vFerc+Zq0pK5nZB39gff4AHZCZiw==</latexit>
X = 3 ! Y = 2 modcase
q = 353 and a primitive root of 353, in this
A A 13 a= =8 3. A and B
XA = 97 and XB = 233, respectively. 5Each computes its public key: 5
<latexit sha1_base64="JkMZ4zR6TewHCZsa/VuGI0TXRe0=">AAACD3icbVDLTsJAFJ36RHxVXbqZSDSuSIuAbkgIblxiIg8DtZlOpzBh2mlmphpC+AM3/oobFxrj1q07/8YBulDwJDc5Oefe3HuPFzMqlWV9G0vLK6tr65mN7ObW9s6uubfflDwRmDQwZ1y0PSQJoxFpKKoYaceCoNBjpOUNLid+654ISXl0o4YxcULUi2hAMVJacs2TtlurlCDsCtrrKyQEf4C3WoKFuxLshtyH9lkFll0zZ+WtKeAisVOSAynqrvnV9TlOQhIpzJCUHduKlTNCQlHMyDjbTSSJER6gHuloGqGQSGc0/WcMj7Xiw4ALXZGCU/X3xAiFUg5DT3eGSPXlvDcR//M6iQounBGN4kSRCM8WBQmDisNJONCngmDFhpogLKi+FeI+EggrHWFWh2DPv7xImoW8Xc4Xr4u5ai2NIwMOwRE4BTY4B1VwBeqgATB4BM/gFbwZT8aL8W58zFqXjHTmAPyB8fkDJCuZjw==</latexit>
<latexit sha1_base64="KWL701QURMMUOpc38y9WUzaX8LQ=">AAAB+nicbVDLSgMxFM3UV62vqS7dBIvgqsxo1W4KRTeCmwr2Ae1YMplMG5pkhiSjlLGf4saFIm79Enf+jWk7C60euHA4517uvcePGVXacb6s3NLyyupafr2wsbm1vWMXd1sqSiQmTRyxSHZ8pAijgjQ11Yx0YkkQ9xlp+6PLqd++J1LRSNzqcUw8jgaChhQjbaS+XbyuwerdKezxKIDuCaxV+3bJKTszwL/EzUgJZGj07c9eEOGEE6ExQ0p1XSfWXoqkppiRSaGXKBIjPEID0jVUIE6Ul85On8BDowQwjKQpoeFM/TmRIq7UmPumkyM9VIveVPzP6yY6rHopFXGiicDzRWHCoI7gNAcYUEmwZmNDEJbU3ArxEEmEtUmrYEJwF1/+S1rHZfesXLmplOoXWRx5sA8OwBFwwTmogyvQAE2AwQN4Ai/g1Xq0nq03633emrOymT3wC9bHN5takaY=</latexit>
• Public q = 13, ↵ = 2, YA = 8, YB = 6
<latexit sha1_base64="FpPRBrWl9muNUe1+jpj5MGI409Q=">AAACB3icbVDLSgMxFM3UV62vUZeCBIvgopSZWmo3hVo3LivYh7TDkEkzbWjmYZIRytCdG3/FjQtF3PoL7vwbM+0stPXA5R7OuZfkHidkVEjD+NYyK6tr6xvZzdzW9s7unr5/0BZBxDFp4YAFvOsgQRj1SUtSyUg35AR5DiMdZ3yV+J0HwgUN/Fs5CYnloaFPXYqRVJKtH9/XzPMC7CMWjlCtVIB39mUNVpPeqFVytp43isYMcJmYKcmDFE1b/+oPAhx5xJeYISF6phFKK0ZcUszINNePBAkRHqMh6SnqI48IK57dMYWnShlAN+CqfAln6u+NGHlCTDxHTXpIjsSil4j/eb1IulUrpn4YSeLj+UNuxKAMYBIKHFBOsGQTRRDmVP0V4hHiCEsVXRKCuXjyMmmXimalWL4p5+uNNI4sOAIn4AyY4ALUwTVoghbA4BE8g1fwpj1pL9q79jEfzWjpziH4A+3zBykElaw=</latexit>
q = 13, ↵ = 2, XA = 3, YA = 8, YB = 6
<latexit sha1_base64="H3N2vk/25Nr/3XaoLf4SqM10SXc=">AAACDnicbVC7TgJBFJ3FF+Jr1dJmIiGxIGQXCdJsgthYYiIPA5vN7DDAhNmHM7MmZMMX2PgrNhYaY2tt5984C1soeJLJPTnn3ty5xw0ZFdIwvrXM2vrG5lZ2O7ezu7d/oB8etUUQcUxaOGAB77pIEEZ90pJUMtINOUGey0jHnVwlfueBcEED/1ZOQ2J7aOTTIcVIKsnRC/eWeV6EfcTCMbLKRdh1Li0l3KkCa0ltWNWco+eNkjEHXCVmSvIgRdPRv/qDAEce8SVmSIieaYTSjhGXFDMyy/UjQUKEJ2hEeor6yCPCjufnzGBBKQM4DLh6voRz9fdEjDwhpp6rOj0kx2LZS8T/vF4khzU7pn4YSeLjxaJhxKAMYJINHFBOsGRTRRDmVP0V4jHiCEuVYBKCuXzyKmmXS2a1VLmp5OuNNI4sOAGn4AyY4ALUwTVoghbA4BE8g1fwpj1pL9q79rFozWjpzDH4A+3zBwBSl6Y=</latexit>
• User A
q = 13, ↵ = 2, XB = 5, YB = 6, YA = 8
<latexit sha1_base64="h6QJ3gTwbtp5oX7CoQRKLOgmg7s=">AAACDnicbVC7TgJBFJ31ifhatbSZSEgsCNlFRJpNEBtLTORhYLOZHQaYMPtwZtaEbPgCG3/FxkJjbK3t/BtnYQsFTzK5J+fcmzv3uCGjQhrGt7ayura+sZnZym7v7O7t6weHLRFEHJMmDljAOy4ShFGfNCWVjHRCTpDnMtJ2x1eJ334gXNDAv5WTkNgeGvp0QDGSSnL0/L1lnhVgD7FwhKxSAXacunVegHeqVJJyacFq1tFzRtGYAS4TMyU5kKLh6F+9foAjj/gSMyRE1zRCaceIS4oZmWZ7kSAhwmM0JF1FfeQRYcezc6Ywr5Q+HARcPV/Cmfp7IkaeEBPPVZ0ekiOx6CXif143koOqHVM/jCTx8XzRIGJQBjDJBvYpJ1iyiSIIc6r+CvEIcYSlSjAJwVw8eZm0SkWzUizflHO1ehpHBhyDE3AKTHABauAaNEATYPAInsEreNOetBftXfuYt65o6cwR+APt8wcF4pep</latexit>
• User B
21
• Public q = 13, ↵ = 2, YA = 8, YB = 6
<latexit sha1_base64="FpPRBrWl9muNUe1+jpj5MGI409Q=">AAACB3icbVDLSgMxFM3UV62vUZeCBIvgopSZWmo3hVo3LivYh7TDkEkzbWjmYZIRytCdG3/FjQtF3PoL7vwbM+0stPXA5R7OuZfkHidkVEjD+NYyK6tr6xvZzdzW9s7unr5/0BZBxDFp4YAFvOsgQRj1SUtSyUg35AR5DiMdZ3yV+J0HwgUN/Fs5CYnloaFPXYqRVJKtH9/XzPMC7CMWjlCtVIB39mUNVpPeqFVytp43isYMcJmYKcmDFE1b/+oPAhx5xJeYISF6phFKK0ZcUszINNePBAkRHqMh6SnqI48IK57dMYWnShlAN+CqfAln6u+NGHlCTDxHTXpIjsSil4j/eb1IulUrpn4YSeLj+UNuxKAMYBIKHFBOsGQTRRDmVP0V4hHiCEsVXRKCuXjyMmmXimalWL4p5+uNNI4sOAIn4AyY4ALUwTVoghbA4BE8g1fwpj1pL9q79jEfzWjpziH4A+3zBykElaw=</latexit>
q = 13, ↵ = 2, XA = 3, YA = 8, YB = 6
<latexit sha1_base64="H3N2vk/25Nr/3XaoLf4SqM10SXc=">AAACDnicbVC7TgJBFJ3FF+Jr1dJmIiGxIGQXCdJsgthYYiIPA5vN7DDAhNmHM7MmZMMX2PgrNhYaY2tt5984C1soeJLJPTnn3ty5xw0ZFdIwvrXM2vrG5lZ2O7ezu7d/oB8etUUQcUxaOGAB77pIEEZ90pJUMtINOUGey0jHnVwlfueBcEED/1ZOQ2J7aOTTIcVIKsnRC/eWeV6EfcTCMbLKRdh1Li0l3KkCa0ltWNWco+eNkjEHXCVmSvIgRdPRv/qDAEce8SVmSIieaYTSjhGXFDMyy/UjQUKEJ2hEeor6yCPCjufnzGBBKQM4DLh6voRz9fdEjDwhpp6rOj0kx2LZS8T/vF4khzU7pn4YSeLjxaJhxKAMYJINHFBOsGRTRRDmVP0V4jHiCEuVYBKCuXzyKmmXS2a1VLmp5OuNNI4sOAGn4AyY4ALUwTVoghbA4BE8g1fwpj1pL9q79rFozWjpzDH4A+3zBwBSl6Y=</latexit>
• User A
q = 13, ↵ = 2, XB = 5, YB = 6, YA = 8
<latexit sha1_base64="h6QJ3gTwbtp5oX7CoQRKLOgmg7s=">AAACDnicbVC7TgJBFJ31ifhatbSZSEgsCNlFRJpNEBtLTORhYLOZHQaYMPtwZtaEbPgCG3/FxkJjbK3t/BtnYQsFTzK5J+fcmzv3uCGjQhrGt7ayura+sZnZym7v7O7t6weHLRFEHJMmDljAOy4ShFGfNCWVjHRCTpDnMtJ2x1eJ334gXNDAv5WTkNgeGvp0QDGSSnL0/L1lnhVgD7FwhKxSAXacunVegHeqVJJyacFq1tFzRtGYAS4TMyU5kKLh6F+9foAjj/gSMyRE1zRCaceIS4oZmWZ7kSAhwmM0JF1FfeQRYcezc6Ywr5Q+HARcPV/Cmfp7IkaeEBPPVZ0ekiOx6CXif143koOqHVM/jCTx8XzRIGJQBjDJBvYpJ1iyiSIIc6r+CvEIcYSlSjAJwVw8eZm0SkWzUizflHO1ehpHBhyDE3AKTHABauAaNEATYPAInsEreNOetBftXfuYt65o6cwR+APt8wcF4pep</latexit>
• User B
Find XA or XB by solving
<latexit sha1_base64="1XSyD0feeRDgrRhRt/K6ecZTu3w=">AAACDnicbZC7TgJBFIZnvSLeUEubiUBiRXYNUUvExFhiIpcECJkdZmHC7Mxm5iyRbHgCG1/FxkJjbK3tfBuHS6Hgqb78/zk55/x+JLgB1/12VlbX1jc2U1vp7Z3dvf3MwWHNqFhTVqVKKN3wiWGCS1YFDoI1Is1I6AtW9wfXE78+ZNpwJe9hFLF2SHqSB5wSsFInk28Be4DkhssuzjU6Vzms9ATKOeyPsFFiyGVv3Mlk3YI7LbwM3hyyaF6VTuar1VU0DpkEKogxTc+NoJ0QDZwKNk63YsMiQgekx5oWJQmZaSfTd8Y4b5UuDuwhgZKAp+rviYSExoxC33aGBPpm0ZuI/3nNGILLdsJlFAOTdLYoiAUGhSfZ4C7XjIIYWSBUc3srpn2iCQWbYNqG4C2+vAy1s4J3XijeFbOl8jyOFDpGJ+gUeegCldAtqqAqougRPaNX9OY8OS/Ou/Mxa11x5jNH6E85nz+qf5qf</latexit>
Attack Example:
22
c c c c
X and then computing the corresponding public 1. YDarth
keys and
< qprepares
and
Y
is
.
a for the attack by
primitive
attack3.byDarth intercepts
<
generating q and
root of X
is a
two random
qD2
YA andprivate
primitive transmits
D2
keysYXD1 to<
and
D1 root
qBob. Darth also calculates
and
of q
is a root of q
primitive D1 root of q D2
XD2 and then computing the cor
K2 = (Y ) mod q. 2. Alice transmits Y to Bob.
<latexit sha1_base64="m+aafNetCBPBlDSsXWMsMedRTmU=">AAACKXicbVDLSiNBFK32bXxlnKWb0mQgAxK6RXQ2QlAXwmwcMCZDOtNUV26SItUPq26LoenfmY2/4kZBcdz6I1Mde+HrFAWnzrmXW/f4sRQabfufNTU9Mzs3v7BYWlpeWV0rf1k/11GiODR5JCPV9pkGKUJookAJ7VgBC3wJLX90lPutS1BaROEZjmPoBmwQir7gDI3klRsuwhWmCjiIS9C0+ttLjz0nq27T6k/POagV7+9/0rZ3mFF3Mz/UDaIevajSrOSVK3bdnoB+JE5BKqTAqVe+c3sRTwIIkUumdcexY+ymTKHgErKSm2iIGR+xAXQMDVkAuptONs3oN6P0aD9S5oZIJ+rrjpQFWo8D31QGDIf6vZeLn3mdBPs/uqkI4wQh5C+D+omkGNE8NtoTJiKUY0MYV8L8lfIhU4yjCTcPwXm/8kdyvlN39uq7v3YrjcMijgWyQbZIjThknzTICTklTcLJX3JD7smDdW3dWo/W00vplFX0fCVvYD3/ByqZo20=</latexit>
<latexit sha1_base64="m+aafNetCBPBlDSsXWMsMedRTmU=">AAACKXicbVDLSiNBFK32bXxlnKWb0mQgAxK6RXQ2QlAXwmwcMCZDOtNUV26SItUPq26LoenfmY2/4kZBcdz6I1Mde+HrFAWnzrmXW/f4sRQabfufNTU9Mzs3v7BYWlpeWV0rf1k/11GiODR5JCPV9pkGKUJookAJ7VgBC3wJLX90lPutS1BaROEZjmPoBmwQir7gDI3klRsuwhWmCjiIS9C0+ttLjz0nq27T6k/POagV7+9/0rZ3mFF3Mz/UDaIevajSrOSVK3bdnoB+JE5BKqTAqVe+c3sRTwIIkUumdcexY+ymTKHgErKSm2iIGR+xAXQMDVkAuptONs3oN6P0aD9S5oZIJ+rrjpQFWo8D31QGDIf6vZeLn3mdBPs/uqkI4wQh5C+D+omkGNE8NtoTJiKUY0MYV8L8lfIhU4yjCTcPwXm/8kdyvlN39uq7v3YrjcMijgWyQbZIjThknzTICTklTcLJX3JD7smDdW3dWo/W00vplFX0fCVvYD3/ByqZo20=</latexit>
<latexit sha1_base64="/0Du3UXsX+0GIT2jCNg3w2ZlpkU=">AAACF3icbVDLTsJAFJ3iC/GFunQzCia4Ia0h6saEoAsTN5jIw1BspsMAE6YPZ26NpOlfuPFX3LjQGLe6829sgYWC5+YmJ+fcm5l7bF9wBbr+raXm5hcWl9LLmZXVtfWN7OZWXXmBpKxGPeHJpk0UE9xlNeAgWNOXjDi2YA17cJb4jXsmFffcaxj6rO2Qnsu7nBKIJStbNIE9QJi/tIzTwo0VVqKD27BpheeWEUXY3E0Km47XwXd5HGWsbE4v6iPgWWJMSA5NULWyX2bHo4HDXKCCKNUydB/aIZHAqWBRxgwU8wkdkB5rxdQlDlPtcHRXhPdjpYO7nozbBTxSf2+ExFFq6NjxpEOgr6a9RPzPawXQPWmH3PUDYC4dP9QNBAYPJyHhDpeMghjGhFDJ479i2ieSUIijTEIwpk+eJfXDonFULF2VcuXKJI402kF7qIAMdIzK6AJVUQ1R9Iie0St60560F+1d+xiPprTJzjb6A+3zB8L7nSM=</latexit>
<latexit sha1_base64="MAiW76szr4RYi0eNA0xoOlmE85E=">AAAB8HicbVDLSgNBEOz1GeMr6tHLYBAiSNgNQT0GRRBEiGAekixhdjKbDJmZXWZmhbDkK7x4UMSrn+PNv3HyOGhiQUNR1U13VxBzpo3rfjtLyyura+uZjezm1vbObm5vv66jRBFaIxGPVDPAmnImac0ww2kzVhSLgNNGMLga+40nqjSL5IMZxtQXuCdZyAg2Vnq8Ltx2Sqfo7qSTy7tFdwK0SLwZycMM1U7uq92NSCKoNIRjrVueGxs/xcowwuko2040jTEZ4B5tWSqxoNpPJweP0LFVuiiMlC1p0ET9PZFiofVQBLZTYNPX895Y/M9rJSa88FMm48RQSaaLwoQjE6Hx96jLFCWGDy3BRDF7KyJ9rDAxNqOsDcGbf3mR1EtF76xYvi/nK5ezODJwCEdQAA/OoQI3UIUaEBDwDK/w5ijnxXl3PqatS85s5gD+wPn8AXw9jug=</latexit>
E(K , M )
Alice generates a private
2 Bob generates akey X such
private A A key XB such that XB < q
= = key XB such that XB < q
3. Darth sends Bob
key XAE(K1, XA < or
such that M) q E(K1, M ), where M is any message. In the first
YA = c A mod q key YB = cXB mod q
case, Darth simply wants to eavesdrop on the communication without Alice calculates a public
altering Bob calculates a public
YA
key YA = c mod q key YB = c B mod q Bob.
X
Alice calculates a public Bob calculates akey
public YB
it. In the second case,XA Darth wants toYmodify the message
A YB going
X to
0
<latexit sha1_base64="yGBIkTEgzk/BBiHKnsWixX9X6uU=">AAACFXicbVDLSgNBEJz1bXxFPXoZTEQFCbsi6lEigiBCBKNCEsLspNcMzs4sM71iWPITXvwVLx4U8Sp482+cxIDPOlVXddPdFSZSWPT9d29oeGR0bHxiMjc1PTM7l59fOLM6NRyqXEttLkJmQQoFVRQo4SIxwOJQwnl4td/zz6/BWKHVKXYSaMTsUolIcIZOauY36gg3mFlQLUvLOqTFg7WjZrBBj9eLVJuvcnW92G3mC37J74P+JcGAFMgAlWb+rd7SPI1BIZfM2lrgJ9jImEHBJXRz9dRCwvgVu4Sao4rFYBtZ/6suXXFKi0buiEgrpH31+0TGYms7ceg6Y4Zt+9vrif95tRSj3UYmVJIiKP65KEolRU17EdGWMMBRdhxh3Ah3K+VtZhhHF2TOhRD8fvkvOdssBdulrZOtwl55EMcEWSLLZI0EZIfskUNSIVXCyS25J4/kybvzHrxn7+WzdcgbzCySH/BePwD6f5rh</latexit>
25
Asymmetric Encryption
26
Asymmetric Encryption
27
Asymmetric Encryption
28
Asymmetric Encryption
29
Tutorial Question 1
Problem 1. For any block cipher, the fact that it is a nonlinear function is crucial to its security. To
see this, suppose that we have a linear block cipher EL that encrypts 128-bit blocks of plaintext into
128-bit blocks of ciphertext. Let EL(k, m) denote the encryption of a 128-bit message m under a key
k (the actual bit length of k is irrelevant). Thus
Describe how, with 128 chosen ciphertexts, an adversary can decrypt any ciphertext without knowl-
edge of the secret key k. (A “chosen ciphertext” means that an adversary has the ability to choose a
ciphertext and then obtain its decryption. Here, you have 128 plaintext/ciphertext pairs to work with
and you have the ability to chose the value of the ciphertexts.)
Solution: For 1 i 128, take ci 2 {0, 1}128 to be the string containing a 1 in position i and
Chosen ciphertext: Paired plaintext
then zeros elsewhere. Obtain the decryption of these128 ciphertexts. Let m1 , m2 , · · · , m128 be the
c 1 = [1, 0, 0, · · · , 0] m1
<latexit sha1_base64="cRZhhpnSeJjqe1e4s79Rm3dX6Wc=">AAACOnicbVBLSwMxGMzWV62vqkcvwSJ4WEpSinoRil48tmBV2F2WbDbbhmYfJFmhLP1dXvwV3jx48aCIV3+A6boHX0MCw8w3JN8EmeBKI/Ro1RYWl5ZX6quNtfWNza3m9s6VSnNJ2ZCmIpU3AVFM8IQNNdeC3WSSkTgQ7DqYnM/961smFU+TSz3NmBeTUcIjTok2kt8cUB+fQgfbEJkDbejSMNXKcM91G9TvnDrIxjayK72US6fAnZPZ3EVltvKx5zdbqI1KwL8EV6QFKvT95oMbpjSPWaKpIEo5GGXaK4jUnAo2a7i5YhmhEzJijqEJiZnyinL1GTwwSgijVJqbaFiq3xMFiZWaxoGZjIkeq9/eXPzPc3IdnXgFT7Jcs4R+PRTlAuoUznuEIZeMajE1hFDJzV8hHRNJqDZtN0wJ+PfKf8lVp42P2t1Bt9U7q+qogz2wDw4BBsegBy5AHwwBBXfgCbyAV+veerberPev0ZpVZXbBD1gfnzQHpf0=</latexit>
<latexit sha1_base64="XhJBAcgrJ6n29lR3YlsSIVFlBqg=">AAACAXicbZBNS8MwGMfT+TbrW9WL4CU4BE+jHUN3HHrxOMG9wFpKmqVbWNKWJBVGmRe/ihcPinj1W3jz25h2PejmAyE//v/nIXn+QcKoVLb9bVTW1jc2t6rb5s7u3v6BdXjUk3EqMOnimMViECBJGI1IV1HFyCARBPGAkX4wvcn9/gMRksbRvZolxONoHNGQYqS05Fsn3Heg65rcb+RXQZnTaM19q2bX7aLgKjgl1EBZHd/6ckcxTjmJFGZIyqFjJ8rLkFAUMzI33VSSBOEpGpOhxghxIr2s2GAOz7UygmEs9IkULNTfExniUs54oDs5UhO57OXif94wVWHLy2iUpIpEePFQmDKoYpjHAUdUEKzYTAPCguq/QjxBAmGlQzN1CM7yyqvQa9Sdy3rzrllrX5dxVMEpOAMXwAFXoA1uQQd0AQaP4Bm8gjfjyXgx3o2PRWvFKGeOwZ8yPn8AuJaUhA==</latexit>
corresponding plaintexts. Now, given any ciphertext c which does not consist of all zeros, there is a
uniquec2nonempty 0, · · ·of, 0]
= [0, 1,subset m2together to obtain c. Let I(c) ✓ {1, 2, · · · , 128}
the ci which we can XOR
…
0 1
c128 = [0, 0, 0, · · · , 1] M Mm128 M
c= ci = E(mi ) = E @ mi A (2)
Thus, we obtain the plaintext of c by computing i2I(c) mi . Let 0 be the all-zero string. Note that
0 = 0 0. From this we obtain E(0) = E(0 0)30= E(0) E(0) = 0. Thus, the plaintext of c = 0
roblem 1. For any block cipher, the fact that it is a nonlinear function is crucial to its security.
ee this, suppose that we have a linear block cipher EL that encrypts 128-bit blocks of plaintext in
28-bit blocks of ciphertext. Let EL(k, m) denote the encryption of a 128-bit message m under a k
Tutorial Question 1
(the actual bit length of k is irrelevant). Thus
…
…
nique nonempty subset of the ci which we can XOR together to obtain c. Let I(c) ✓ {1, 2, · · · , 12
plaintext: m1 m3
<latexit sha1_base64="3eZJG8bd7zj39JqtFOEB8HyCJ08=">AAAB9XicbVBNSwMxEJ2tX7V+VT16CRbBU9nVoh6LXjxWsB/Qrks2zbahyWZJskpZ+j+8eFDEq//Fm//GtN2Dtj4YeLw3w8y8MOFMG9f9dgorq2vrG8XN0tb2zu5eef+gpWWqCG0SyaXqhFhTzmLaNMxw2kkUxSLktB2ObqZ++5EqzWR8b8YJ9QUexCxiBBsrPYjAQz2Z8FQjEZwH5YpbdWdAy8TLSQVyNILyV68vSSpobAjHWnc9NzF+hpVhhNNJqZdqmmAywgPatTTGgmo/m109QSdW6aNIKluxQTP190SGhdZjEdpOgc1QL3pT8T+vm5roys9YnKSGxmS+KEo5MhJNI0B9pigxfGwJJorZWxEZYoWJsUGVbAje4svLpHVW9S6qtbtapX6dx1GEIziGU/DgEupwCw1oAgEFz/AKb86T8+K8Ox/z1oKTzxzCHzifP3b8kdo=</latexit>
Describe how, with 128 chosen ciphertexts, an adversary can decrypt any ciphertext without know
For all-zero string EL[k, 0]= 0 why?
dge of the secret key k. (A “chosen ciphertext” means that an adversary has the ability to choose
iphertext and then obtainEL[k,0]=1
Suppose its decryption.
then weHere, you have
will have 128 plaintext/ciphertext
the following contradiction pairs to work w
nd you have the ability to chose the value of the ciphertexts.)
olution: For 1setplaintext
i 128,as take
m1c= i 2m{0,= 1}
0 128
to be the string containing a 1 in position i a
<latexit sha1_base64="HnAmwKaCmRdHphdQzgNOFF8BQks=">AAACSHicbZBLSwMxFIUz9VXrq+rSTbAoLqTMlKJuCkURXLioYB/QGYZMmrahSWZMMkIp/XluXLrzN7hxoYg7M9Mq2nohcO537iXJCSJGlbbtZyuzsLi0vJJdza2tb2xu5bd3GiqMJSZ1HLJQtgKkCKOC1DXVjLQiSRAPGGkGg4vEb94TqWgobvUwIh5HPUG7FCNtkJ/3D7nvVLhfqtjQdXNJB90wYrGCBsIKnODL6/bgGM6YXsW0gtzBH9f7tlNiZjw/X7CLdlpwXjhTUQDTqvn5J7cT4pgToTFDSrUdO9LeCElNMSPjnBsrEiE8QD3SNlIgTpQ3SoMYwwNDOrAbSnOEhin9vTFCXKkhD8wkR7qvZr0E/ue1Y90980ZURLEmAk8u6sYM6hAmqcIOlQRrNjQCYUnNWyHuI4mwNtnnTAjO7JfnRaNUdE6K5ZtyoXo+jSML9sA+OAIOOAVVcAVqoA4weAAv4A28W4/Wq/VhfU5GM9Z0Zxf8qUzmCySRq58=</latexit>
2
hen zeros elsewhere. Obtain themdecryption
1 m2 = of0 these128 ciphertexts. Let m1 , m2 , · · · , m128 be t
orresponding plaintexts. Now, given
EL[k,any m1ciphertext
m2 ] =c1which doesm
6= EL[k, not] consist
EL[k, ofm
all ]zeros, there is
1 2
nique nonempty subset of the ci which we can XOR together to obtain c. Let I(c) ✓ {1, 2, · · · , 12
enote this subset. Observe
0 1
M M M
c= ci = E(mi ) = E @ mi A (
i2I(c) i2I(c) i2I(c)
L
hus, we obtain the plaintext of c by computing i2I(c) mi . Let 0 be the all-zero string. Note th
= 0 0. From this we obtain E(0) = E(0 0) = E(0) E(0) = 0. Thus, the plaintext of c =
32
128
Figure 2.3b) ishas
an adversary
Thus,
generated
we the
A from
ability
Solution:
obtain the to
temporary Schoose
by selecting
For
plaintext1a
vector,
of T, is
follows:
c i
by follows:
one of the 255 entries
also
128,
L
created.
take
computing c 2 If
then
m{0,the
. K
1}
Letlength
128
to ofthe
be be
the thestring
is0 transferred keyto
all-zero Kcontaining
T.is Otherwise,
string. 256
Notebytes,a 1 infor
that po
c fashion. As each value of k is generated, the entries in S are once i
i2I(c) i
then
d.plaintext/ciphertext
0 = 0 0. From thenK
pairs to
this
iswork
zeros transferred
with E(0)
we elsewhere.
obtain
to T. Otherwise, for
Obtain
= E(0 the0)decryption
= E(0)
a keyelements
keylen of
E(0)
of length of
these128
= 0.
keylen
T are
ciphertexts.
Thus,
/* Initialization */ the
bytes,
copied
Let
plaintext
the first
ofmc 1=,from
m0 2 , · ·K
· ,a
keylen elements of T are copied 128 from K as and then K is
necessary to repeated
fill /*
out as many
T. times
Initializa
These prelimin
is m = 0. Hence we can
corresponding decrypt every
plaintexts. c 2Now,
{0, given
1} . any ciphertext which does not consist of all zero
Tutorial Question 2
N OF Scontaining
string To begin,atheas
1 innecessary
entries
position to
of S iare
and fill out T. These preliminary
set equal to the values from follows:
for i = 0 c
operationsto 255
can do
be summarized as
unique
in ascending order; follows:
that is, S[0]nonempty
= 0, S[1] subset
= 1, . . of = 255. weS[i]
the ci which
. , S[255] =i; together to obtain c. Let I(c) ✓ {1,
can XOR for i = 0 to
hertexts. Let m 1 , m2 , · · · , m128 be the
vector, T, is also created. If the length of the key K is 256 bytes, T[i] = K[i mod keylen];
denote this subset. Observe /*the=i;
Initializ
does not
sferred toconsist
Problem of all zeros,
2. What
T. Otherwise, for
RC4 there
a key islength
a will
keyofvalue keylen
leave
Next
bytes,
/*
we
the first during initialization?
S unchanged
Initialization
use T to produce the
*/
initial 0That S[i]
is,
permutation
after
of 1
S. This
initial
involves start
nts
to of T are
obtain copied
Let from K and then K is repeated as many times
c. I(c) ✓ {1, 2, · · · , 128}
permutation of S, the entries of S will be equal for to iM the
= 0 values
toM from
255 0do
through 255 in M ascending
to S[255], and, for each S[i], swapping S[i] with anoth i = 0 to
fororder.
o fill out T. These preliminary operationswith
can S[0] and going through
be summarized as T[i] = K[i mo
c = =i;
byte in S S[i]
according to cai scheme
= E@
E(mi )by=T[i]:
dictated mi A
S[i] =i;
0 1 i2I(c) i2I(c) i2I(c)
T[i] /*= Initial
K[i modPermutation
keylen]; of S */ T[i] = K[i m
@
M
i
A
/* Initialization */
mProblem 3. RC4 has a secret (2) Next we use T to produce the initial pe
internal state which
j =is0;
a permutation
Lof all the possible values of the
for i =Thus,
0 to we 255obtain
do the plaintext of c by computing m i .This
Let involves
0 be the starting
all-zero string
i2I(c) vector S and the two
S[i] =i;
Next we use
indices i T j.
and with S[0] and going through to S[255], and, fo
to produce the
forinitial
i = permutation
0 to 255 of
i2I(c)
do S.
Next we use T to produce the initial p
0 =S[0]
with 0 and0. From
goingthis we obtain
through E(0)
to S[255], ==(j
j and,E(0
for 0) S[i],
+ each
S[i] =+ E(0)
swapping
T[i]) modS[i]
E(0) 0. Thus,
= with
256; the plaint
another
Let 0 be theT[i] = K[i
all-zero keylen];
modNote
string. that byte in S according to a scheme dictated by T
Swapwith S[0]128
(S[i],
byte in S according to a scheme dictated by T[i]:
and going through to S[255], and, f
S[j]);
is m = 0. Hence we can decrypt every
1
cbyte .
2 {0,in1}S according to a scheme dictated by
E(0)
use 0. Thus,the
= produce
T to theinitial
plaintext of c = 0 of S. This involves starting
permutation Because the only operation on S is a swap, the only effect is a permutati
To make it simple, we
/*swapping
oing through to S[255], and, for each S[i], Initial
S still
use a key of
Permutation
S[i] with
contains allanother
the numbers
length 256, T from
is /* Initial Permutatio
a
*/ 255.
of 0Sthrough
copy of/*K (key).
Initial Permutati
ding to a scheme dictated by T[i]: j = 0;
Problem 2. What forRC4i = key0value will leave
to 255 j = 0;
do S unchanged during
j = initialization?
0; That is, aft
/* Initial Permutation of S */
Thatpermutation
Design
ngjinitialization?
= 0; T[i]
is, (K[i])
after of S, that
such
the initial the=entries
j (j +ofS[i] equal tofor
S will+beT[i]) ifor
the values
mod 256; =
from00=through
i to0 to255
255255indodo
ascend
Swap (S[i], S[j]);
bytes. The first j j are
two =bytes = +(j +that
S[i] +T[i
T[
for i = 0 to 255 do
Solution:
rom 0 through 255 in ascending order.
j = (j + S[i] + T[i]) mod 256;
Use a key of length 256 (j S[i]
zero; is +K[0] =
Thereafter, Swap (S[i], S[j]);
s areSwap
zero;(S[i],
that is K[0]
S[j]);= K[1] we
= have:
Because the only operation on S is a swap, the Swap
0. K[2] = 255; K[3] = 254; . . . K[255] = 2. (S[i],
only effect S[j]);
is a permutation.
. S still contains all the numbers from 0 through 255.
the only operation on S is a swap, the only effect is a permutation. Because the only operation on S is a
all the numbers from 0 through 255. Because the only operation on S is a s
S still contains all the numbers from 0 throu
1
S still contains all the numbers from 0 throug
33
a random permutation. Analysis shows that the period of the cipher is
ly likely to be greater than 10100 [ROBS95]. Eight lengthtokey of from
sixteen machine1 to 256 bytes (8 to 2048 bits) is used to initialize a 256-b
e required per output byte, and the cipher canstate vector S,towith
be expected elements S[0], S[1], . . . , S[255]. At all times, S contains a p
run very
ware. RC4 is used in the SSL/TLS (Secure Sockets mutation of all 8-bit numbers from 0 through 255. For encryption and decrypt
Layer/Transport
Tutorial Question 3
COMPSCI
y) standards that 4062 & 5063
have been Cyber
defined forSecurity Fundamentals
a byte
communication k (see
in a systematic
servers. It is also used in the WEP (Wired Equivalent
Figure
between
Privacy)
Web2.3b) is generated from S by selecting one of the 255 ent
[2022-2023]
proto- As each value of k is generated, the entries in S are o
fashion.
wer WiFi Protected Access (WPA) protocol that againarepermuted.
part of the IEEE
s LAN Problem
standard.3.RC4 RC4
washas
kepta as
secret
a tradeinternal state
secret by RSA which is aInpermutation of all the possible values of the
Security.
94, the RC4 algorithm was anonymously posted I on the InternetOF onSthe To begin, the entries of S are set equal to the values fr
vector S and the two indices i and j.
anonymous remailers list.
NITIALIZATION
0 through 255 in ascending order; that is, S[0] = 0, S[1] = 1, . . . , S[255] = 2
4 algorithm (a)is Using a straightforward
remarkably simple and quite scheme
easy
A to to store A
explain.
temporary the internal
variable-
vector, T, isstate,
also how many
created. If bits are used?
the length of the key K is 256 by
from 1 to 256 bytes (8 to 2048 bits) is usedthen to initialize a 256-byte
(b) Suppose we think of it from the point of view oftohow
K is transferred much information
T. Otherwise, for a keyisofrepresented by bytes,
length keylen the the f
with elements S[0], S[1], . . . , S[255]. At allkeylen
times, S contains of
elements a per-
T are copied from K and then K is repeated as many tim
state. In that case, we need to determine how
l 8-bit numbers from 0 through 255. For encryption and decryption, may different states there are, then take the log to the
as necessary to fill out T. These preliminary operations can be summarized
Figure 2.3b)
base 2 tois generated
find out how S by selecting
frommany one of the 255
bits offollows:
information thisentries
represents. Using this approach, how many bits
c fashion. As each value of k is generated, the entries in S are once
ed. would be needed to represent the state? /* Initialization */
Solution: for i = 0 to 255 do
ON OF S To begin, the entries of S are set equal to the values from
(a)
(a)Simply
iorder; store
for 0 that and 8
i, j,use
to 255, whichsame
S,bits, requires 8j,+S[0], 8 + (256 ⇥…, 2064 bits
8) S[255]
S[1],S[i] ==i;
in ascending is, S[0] = 0, S[1] = 1, . . . , for
S[255] = 255. use 8*256 bits
(b)isThe
vector, T, also number
created. of
If states is [256!
the length ⇥ 256
of the key K
2
]⇡ is 2
1700
. Therefore,
256 bytes, T[i]1700 bits mod
= K[i are required.
keylen];
nsferred to T. Otherwise, for a key of length keylen bytes, the first
nts of T are copied from K and then K is repeated Nextaswe use times
many T to produce the initial permutation of2S. This involves start
<latexit sha1_base64="IN6x7nbPN4AukaT5VdhPFLBNKY0=">AAACDXicbZC7TsMwFIYdrqXcAowshoJUliqJSstYwcJYJHqRmhA5rttadeLIdhBV1Bdg4VVYGECIlZ2Nt8FtM0DLL1n69J9zdHz+IGZUKsv6NpaWV1bX1nMb+c2t7Z1dc2+/KXkiMGlgzrhoB0gSRiPSUFQx0o4FQWHASCsYXk3qrXsiJOXRrRrFxAtRP6I9ipHSlm+euIz3fafonFeOXEVDIjXdOWfQRXEs+AO0q5blmwWrZE0FF8HOoAAy1X3zy+1ynIQkUpghKTu2FSsvRUJRzMg47yaSxAgPUZ90NEZI7/XS6TVjeKqdLuxxoV+k4NT9PZGiUMpRGOjOEKmBnK9NzP9qnUT1LryURnGiSIRni3oJg4rDSTSwSwXBio00ICyo/ivEAyQQVjrAvA7Bnj95EZpOya6UyjflQu0yiyMHDsExKAIbVEENXIM6aAAMHsEzeAVvxpPxYrwbH7PWJSObOQB/ZHz+AAktmQM=</latexit>
• 15 minutes
37
COMPSCI4062&5063: Cyber Security Fundamentals
Topic 6: Network Security
1
fi
Overview
• Internet Security
• Secure Sockets Layers (SSL) / Transport Layer Security (TLS)
One of the most widely used security services is the Secure Sockets Layer (SSL) and
the follow-on Internet standard known as Transport Layer Security (TLS), the lat-
ter defined in RFC 4346. TLS has largely supplanted earlier SSL implementations.
TLS is a general-purpose service implemented as a set of protocols that rely on
Transport Layer Security (TLS): Architecture
TCP. At this level, there are two implementation choices. For full generality, TLS
could be provided as part of the underlying protocol suite and therefore be trans-
parent to applications. Alternatively, TLS can be embedded in specific packages.
For example, most browsers come equipped with SSL, and most Web servers have
• TLSimplemented
is designed to make use of TCP to provide a reliable end-to-end
the protocol.
secure service.
TLS Architecture
• TwoTLS is designed to make use of TCP to provide a reliable end-to-end secure service.
layers
TLS is not a single protocol but rather two layers of protocols, as illustrated in
Figure 22.4.
• Record protocol:
The Record Protocol provides basic security services to various higher-layer
• Handshake, Changethe
protocols. In particular, Cipher Spec,
Hypertext Alter Protocol
Transfer Protocols:
(HTTP), which provides
the transfer service for Web client/server interaction, can operate on top of TLS.
Change
Handshake Alert Heartbeat
Cipher Spec HTTP
Protocol Protocol Protocol
Protocol
Record Protocol
TCP
IP
• TLS connection
• A transport that provides a suitable type of service
• peer-to-peer relationship
• transient, associated with one session
• TLS session
• An association between a client and a server
• Created by the Handshake Protocol
• De ne a set of cryptographic security parameters
• Security parameters can be shared among multiple connections
• Avoid negotiation of new security parameters for each connection
4
fi
• Record Protocol
HAPTER 22 / INTERNET SECURITY PROTOCOLS AND STANDARDS
Fragment Reassemble
Compress Decompress
(optional)
Encrypt Decrypt
Append TLS
record header
Received data
version and length elds
Figure 22.5 TLS Record Protocol Operation
TCP
5
fi
Transport Layer Security (TLS): Protocols
• Alert Protocol
• Purpose: Convey TLS-related alerts to the peer entity
• Each message in this protocol consists of two byte
• First byte: severity of the message (“warning” or “fatal”) — if “fatal”, TLS
immediately terminates the connection. Other connections on the same
session may continue, but no new connections on this session may be
established.
• Second byte: speci c alert
fi
fi
• Handshake Protocol
• Allows the server and client to authenticate each other
• Negotiate an encryption and MAC algorithm and cryptographic keys to be
used to protect data sent in an TLS record
• This protocol is used before any application data are transmitted
Client Server
ge
key_exchan
-Establish the security capabilities server_ Phase 2
Server may send certificate, key exchange,
t
te _reques and request certificate. Server signals end
certifica
-Client_hello e
of hello message phase.
ver_hello_don
ser
Highest TLS version
Time
certifica
te
Random structure (for key exchange)
client_k Phase 3
ey_exch Client sends certificate if requested. Client
ange
Session ID (nonzero value for updating sends key exchange. Client may send
certifica certificate verification.
te_verif
the parameters of an existing connection y
Phase 4
CipherSuite (cryptographic algorithms) Change cipher suite and finish
ciph er_spec handshake protocol.
change_
Compression method
finished
Client Server
ge
r_key_exchan
-Additional key information serve Phase 2
Server may send certificate, key exchange,
t
te _reques and request certificate. Server signals end
certifica of hello message phase.
-Request for certi cate from the client llo_don
e
ver_he
ser
(public-key encryption)
Time
certifica
te
client_k Phase 3
ey_exch Client sends certificate if requested. Client
ange
sends key exchange. Client may send
-sever-done message, wait for a client certifica
te_verif
y
certificate verification.
response
change_
cipher_
spec
finished
Phase 4
Change cipher suite and finish
ciph er_spec handshake protocol.
change_
finished
Client Server
Time
certifica
te
client_k Phase 3
ey_exch Client sends certificate if requested. Client
ange
sends key exchange. Client may send
certifica certificate verification.
te_verif
y
change_
cipher_
spec
finished
Phase 4
Change cipher suite and finish
ciph er_spec handshake protocol.
change_
finished
Client Server
Client
te
certifica
ver_hello_don
ser
Spec Protocol)
Time
certifica
-Sends the nished message under the te
client_k Phase 3
new algorithms, keys, and secrets — key ey_exch
ange Client sends certificate if requested. Client
sends key exchange. Client may send
exchange and authentication processes certifica
te_verif
y
certificate verification.
were successful
change_
cipher_
spec
finished
finished
Record Protocol
TCP
IP
fi
14
15
• Accidental association
• Malicious association
• Ad hoc networks
• Nontraditional networks
• Man-in-the middle attacks
• Denial of service (DoS)
•…
16
17
Wireless Network Threats
18
fi
Wireless Network Threats
19
Wireless Network Threats
20
fi
Wireless Network Threats
21
Wireless Network Threats
22
Wireless Security Measures
• Encryption
23
fi
Wireless Security Measures
24
fi
fi
fi
fi
fi
fi
fi
Wireless Security Measures
25
26
fi
Assemble data
into frame Reliable data delivery
Medium Access
Addressing Wireless access control
Control
Error detection protocols
Medium access
Encoding/decoding
Frequency band
of signals
definition
Physical Bit transmission/
Wireless signal
reception
encoding
Transmission medium Antenna characteristics
• Physical layer
• Signal encoding/decoding
• Bit transmission/reception
• Speci cation of the transmission medium
24.3 / IEE
• For IEEE 802.11: frequency bands and antenna characteristics
Gener
fu
Ass
into
Medium Access
Add
Control
Err
Me
Enc
of s
Physical Bit
rece
Tra
28
fi
error detection.
• Govern access to the LAN transmission medium. Logical Link
Control
Flo
Err
Ass
into
Medium Access
Add
Control
Err
Me
Enc
of s
Physical Bit
rece
Tra
29
fi
! MAC Destination
• control: ThisMAC Address: any
eld contains The protocol
destination physical
control address on
information the LAN
needed for
for the
this MPDU.
functioning of the MAC protocol. e.g., a priority level could be indicated here.
! MAC • service Data Unit:
Source MAC The data
Address: The from
sourcethephysical
next higher layeron the LAN for this
address
! CRC: MPDU.
The cyclic redundancy check eld.This is an error-detecting code, such as
that• which
MACisService
used in other
Data data-link
Unit: control
The data fromprotocols. The CRC
the next higher layer.is calculated
based on the bits in the entire MPDU.
• CRC: The cyclic redundancy check field, also known as the Frame Check
Sequence (FCS) field. This is an error-detecting code, such as that which is
used in other data-link control protocols.
30
The CRC is calculated based on the
fi
fi
IEEE 802.11 Protocol Architecture
Gener
fu
Ass
into
Medium Access
Add
Control
Err
Me
Enc
of s
Physical Bit
rece
Tra
31
Distribution System
AP 2
AP 1
Basic Service
Set (BSS)
Basic Service STA 1
Set (BSS)
STA 8
STA 2
STA 6 STA 7
STA 4
STA 3
32
fi
Distribution System
AP 2
AP 1
Basic Service
Set (BSS)
Basic Service STA 1
Set (BSS)
STA 8
STA 2
STA 6 STA 7
STA 4
STA 3
33
34
fi
Distribution System
AP 2
AP 1
Basic Service
Set (BSS)
Basic Service STA 1
Set (BSS)
STA 8
STA 2
STA 6 STA 7
STA 4
STA 3
35
Distribution System
AP 2
AP 1
Basic Service
Set (BSS)
Basic Service STA 1
Set (BSS)
STA 8
STA 2
STA 6 STA 7
STA 4
STA 3
36
• Association-Related Services
Before the distribution service can deliver data or accept data from a station,
that station must be associated.
24.3 / IEEE 802.11 WIRELESS LAN OVERVIEW 745
24.3 / IEEE 802.11 WIRELESS LAN OVERVIEW 745
! No transition: A station is either stationary or moves within the range of a single BSS Distribution System
! BSS transition: A station moves from one BSS to another BSS within the same ESS
Distribution System
! ESS transition: A station moves from a BSS in one ESS to a BSS within another ESS
Distribution System
AP 2
• Association-Related Services
Distributed system need to know the identity of the AP to which the message
should be delivered in order for that message to reach the destination station.
— A station must maintain an association with the AP within its current BSS.
• Association: Establishes an initial association between a station and an
AP. The AP can then communicate this information to other APs within the
ESS to facilitate routing and delivery of addressed frames.
• Reassociation: Enables an established association to be transferred from
one AP to another, allowing a mobile station to move from one BSS to
another.
• Disassociation: A noti cation from either a station or an AP that an
existing association is terminated. A station should give this noti cation
before leaving an ESS or shutting down.
38
fi
fi
IEEE 802.11i Wireless LAN Security
39
cause cryptographic keys to be generated and placed on the AP and the STA.
Frames are exchanged between the AP and STA only.
• Protected data transfer: Frames are exchanged between the STA and the end
station through the AP. As denoted by the shading and the encryption module
IEEE 802.11i Operation
icon, secure data transfer occurs between the STA and the AP only; security is
not provided end-to-end.
STA (STA)
Station AccessAP
Point (AP) AS Server (AS)
Authentication End Station
Phase 1 - Discovery
Phase 2 - Authentication
• Phase 1 Discovery
41
fi
• Phase 2 Authentication
• The AP blocks nonauthentication traf c between the STA and AS until the
authentication transaction is successful.
• The AP does not participate in the authentication transaction other than
forwarding traf c between the STA and AS.
42
fi
fi
• The AP and the STA perform several operations that cause cryptographic
keys to be generated and placed on the AP and the STA.
• Frames are exchanged between the AP and STA only.
43
• Frames are exchanged between the STA and the end station through the
AP.
• Secure data transfer occurs between the STA and the AP only; security is
not provided end-to-end.
44
45
Summary
• SSL/TLS
• Protocol Architecture
• Connection & Session
• Protocols
• Attack
46
Thank You
Quiz Time
• 15 minutes
48
COMPSCI4062/COMPSCI5063
Cyber Security Fundamentals
(CSF)
1
Identification & Access
Authentication Control
System/
network
resources
Identity (a user, an
application)
2
Identity, Identification and
Authentication
• Definitions
– Identity
• Representation of an entity inside a computer system
• It often implies the use of a unique name for an entity
vA person’s identity can change or be falsified, e.g., last name
– Identification
• is the claim of a user or an application that is using/running in
the system
• This could be achieved by a user ID, process ID, a smart
card or anything else that may uniquely identify a subject or a
person.
vThe ID, smart card could be stolen
– Authentication
• Verification/prove process of the identity of an entity
3
Identity
• Purposes
– For access control
– For accountability
• Logging & Auditing
• Identities in a security system
– A data file (an object in general)
• File name: for the human being
• File descriptor: for a process
• File allocation table entry: for the kernel (MS-DOS and
Windows 9x OS)
• A user
– Any name comprised of an arbitrary number of
alphanumeric characters
• May be constrained in some ways, e.g., name + organization
4
Groups and Roles
• An identity may refer to an entity that is
comprised of a group of entities
– A convenient way of performing access control and
other security functions to a set of entities at the same
time
– Models of groups
• Static: alias to a set of entities
• Dynamic: construct for grouping a set of entities
• An identity may refer to a role
• To tie entities together
• To represent rights or security functions to which entities are
assigned or entitled 5
Identity and Certificate
• Certificate issued by a certificate authority (CA)
• CA acts as a trusted 3rd party
– Class 1
• Authentication of an e-mail address, web application,
– Class 2
• Verification of real name and address through an online
database - online purchasing
– Class 3
• Background check by an investigative service- a higher
level of assurance
– Example: Certificate Authority Security Council (CASC)
funded in 2013- dedicated to addressing industry issues
and educating the public on internet security.
6
Trust of Identity
• Trust of a certificate
– Depending on the trustworthiness of the certificate
authority (CA)
– Depending on the level of trust indicated by the CA
• High: a passport
• Low: an unsworn statement
– It’s all relative
• The point
– Identity has the trust issue
– Certificate also has the trust issue
7
Authentication
• Purpose
– To verify that a stated identity really belongs to the right
entity
• Methods
– What the entity knows – knowledge-based authentication
• Password, PIN, DoB, mother’s maiden name, etc
– What the entity has – token-based authentication
• Badge, ID card, key, etc.
– What the entity is – Biometric authentication
• Fingerprints, personal characteristics, gait and motion
biometrics, etc.
– Where the entity is
• Specific terminal, special access device, etc
8
Authentication Components
• For creating and storing authentication
information Identification &
Authentication
– Authentication information: A
• For an entity to prove its identity
– Complementary information: C
A C=f(A)
• For a system to store authentication information
along with the corresponding identity
• For a system to verify authentication information
– Complementary functions: F
• For a system to generate the complementary
information from the authentication information
• For f belongs to F, f: Aà C
9
Authentication Components
• For performing authentication
– Authentication functions: L
• For the system to verify an Identification & l(A, C)à{true, false}
identity Authentication
11
Password Attacks-Dictionary Attack
• Dictionary attack
– Most passwords are not random sequences of
characters and numbers, but instead are combinations
of “normal” words, proper names, acronyms, etc.
• E.g., “Betty23” or “ChocolateFrog”
– In a dictionary attack a list of possible passwords is used
in order to break into an account
• The list might contain common words, names, acronyms,
common passwords, etc.
• This vastly reduces the search space
12
Password Attacks-
Brute-Force Attacks
• Brute-Force Attacks (exhaustive attack) involves trying
every possible combination of characters until the
correct password is found
• The time required to crack a password depends upon
the length of the password
– e.g., if a password is between 1 and 8 characters long, and is
comprised of upper or lower case letter (52), numbers (10),
or special characters (32 in an English keyboard). Then there
are ∑$!"# 94! = 6.1×10#% possible passwords
– If the password is exactly 8 characters long, then there are
94$ possible passwords. (∑&!"# 94! less possible passwords)
– Making a password standards public can be a security risk
13
Counter-Measures to Password
Guessing
• Goal
– To maximize the amount of time consumed before the
password is correctly guessed
• Calculation
– P: probability of correctly guessing a password in a
specified period of time, e.g., 0.5
ØIn number of time units
– G: number of password guesses that can be carried out
in one time unit
– T: number of time units for the calculation
– N: total number of possible passwords
– Anderson’s Formula: P≥TG/N or N≥TG/P
14
An Example of Password Guessing
• The objective
– To determine the minimum length of password in a system
• Parameters
– A=96 characters
– G=10!per second
– P=0.5
– T=365 days =365 ×24 ×60 ×60 seconds=31.536 ×10"
• Assumptions
– The length of time required to try out each password is
constant
– All passwords are equally like to be selected
• The result
– N≥TG/P=6.31× 10##
– N=∑&$%# 96$ ≥ 6.31× 10## S≥ 6
15
Password Selection
• Theorem
– When the selection of a password from a set of
possible passwords is equally probable, the expected
time that is needed for guessing a password is the
longest
• Strong passwords
– At least one digit
– At least one letter (upper and lower)
– At least one special character, e.g., punctuation,
control character
16
Methods against Password Guessing
• Exponential back-off
– Wait for 𝑡 !"# seconds before the next log-in when the
𝑛$% authentication attempt fails
• t is a system parameter
• Disconnection
– Disconnect after a specified number of failed attempts
• Disabling
– Disable after a specified number of failed attempts
• Jailing (Honey pot)
– Fool the attacker, then record all the activities that the
attacker conducts
17
Biometrics
• Purpose
– The use of automated measurement of biological or
behavioural features to characterize and hence,
identify an entity
• Methods (requires special sensors)
– Fingerprints
– Voices recognition
– Eyes
– Faces
– Keystrokes (pressure, interval, duration, position, etc)
– Gaits and motion biometrics
18
Strong authentication
19
Kerberos Authentication
• Foundation
– Needham-Schroeder protocol plus
Denning and Sacco modification AS
TGS
• Kerberos application scenario
Authentication
– A system consist of a central
authentication server AS, a ticket- service
granting server TGS and one or more Ticket -granting 𝑆#
application servers 𝑆#, … , 𝑆' service
– AS authenticates a user to the
Kerberos system User
– TGS issues tickets to the user to 𝑆(
authenticate to the application Application
servers service
– 𝑆#, 𝑆(, … , 𝑆' can be accessed by the
user by presenting tickets issued by
TS 𝑆'
20
Components of the Kerberos
Protocol
• Secret key based cryptography
• The authentication server AS shares a secret
key with each and every user and with the
ticket-Granting server TGS
– Question: how to achieve the above?
• The ticket-Granting Server TGS shares a secret
key with each and every of the applications
severs 𝑆! , … , 𝑆"
21
Components of the Kerberos
Protocol
• Ticket
– 𝑇)*$+,,&,./,. =
𝐴𝑙𝑖𝑐𝑒 𝐴𝑙𝑖𝑐𝑒 0 𝑠 𝑎𝑑𝑑𝑟𝑒𝑠𝑠 𝑣𝑎𝑙𝑖𝑑 𝑡𝑖𝑚𝑒‖𝐾)*$+,,&,./,. 𝐾1,./,.
v𝐾!"#$%,'%()%( is the session key generated by the server that created the
ticket to be shared between “Alice” and “Server” so as to access “Server”
v𝐾*%()%( is the secret key that “Server” shares with the server that created
the ticket
– To be presented by Alice to Server for access
• Authenticator
– 𝐴)*$+,,&,./,. = 𝐴𝑙𝑖𝑐𝑒 𝑡 𝐾2 𝐾)*$+,,&,./,.
v𝐾!"#$%,'%()%( is the session key that is shared between “Alice” and “Server”
so as to access “Server”
v𝑡 is the timestamp when the authenticator is created
v𝐾+ is an alternative session key
– To prove to Server that Alice has the session key 22
The Kerberos Protocol
TGS S
AS
4.
3. 𝑆‖𝐴!"#$%,'( 7 𝐴𝑙𝑖𝑐𝑒‖ 𝐾!"#$%,( 𝐾!"#$%,'( =
𝑇!"#$%,'( 𝑇!"#$%,'(
2. 𝐾!"#$%,'( 𝐾!"#$% ‖
𝑇!"#$%,'( 5.
1. Alice‖𝑇𝑆
𝐴!"#$%,( 7𝑇!"#$%,(
Alice
23
The Kerberos Protocol
• Single sign-on
– User only needs to log in once with the Authentication
Server (AS)
vResult: a ticket-issuing ticket is issued to the user to access
the Ticket-Granting Server (TGS)
– TGS issues tickets to the user to access the application
servers
vResult: logging-in to the application servers is transparent to
the user
• Widely used in financial systems and large-scale
e-commerce applications
25
Summary
• Identity
• Identification
• Authentication
• Passwords and password attacks
– Challenge and response
– Biometrics
– The Kerberos protocol
• Reference book: Introduction to Computer
Security by Matt Bishop, 2004
26
Lab report
• Lab 1 example
27
COMPSCI4062/COMPSCI5063
Cyber Security Fundamentals
(CSF)
Lecture 8
Web application security
1
Web Application
• Web Application
– an application program that is stored on a remote
server and delivered over the internet through a
browser interface
– Interactive
– Examples?
• Webpage
– A document which can be displayed in a web browser
such as Firefox, Google Chrome, Microsoft Edge, or
Apple Safari
2
Web Applications
• The HTTP protocol
– HTTP is the carrier protocol which allows our browsers
and applications to receive content such as HTML ("Hyper
Text Markup Language"), CSS ("Cascading Style Sheets"),
images and videos from a server
3
A secure protocol
• HTTPS: An extension of HTTP. It uses encryption for
the secure communication over a computer
network
– The HTTP protocol does not support encryption for data-in-
transit, hence a wrapper around HTTP is added for encryption
support. This is indicated with a S following HTTP, i.e. HTTPS
– The encryption used to be SSL ("Secure Sockets Layer"), but
has since been deprecated. Instead TLS ("Transport Layer
Security") is typically used to enforce encryption
– All major web browsers today will show a lock icon in the URL
address bar if HTTPS is used
5
• Sessions & State
6
Web Application Attacks
* https://lab.wallarm.com/owasp-top-10-2021-proposal-based-on-a-statistical-data/ 7
Three main web application
vulnerabilities
• SQL Injection
– Browser sends malicious input to server
– Bad input checking leads to malicious SQL query
• CSRF-Cross-site request Forgery
– Bad web site sends browser request to good web
site, using credentials of an innocent victim
• XSS - Cross-site scripting
– Bad web site sends innocent victim a script that
steals information from an honest web site
8
Three main web application
vulnerabilities
Uses SQL to change meaning of
• SQL Injection database command
– Browser sends malicious input to server
– Bad input checking leads to malicious SQL query
• CSRF-Cross-site request Forgery
Leverage user’s session at victim sever
– Bad web site sends browser request to good web site,
using credentials of an innocent victim
• XSS - Cross-site scripting
– Bad web site sends innocent victim a script that steals
information from an honest web site
Inject malicious script into trusted context 9
SQL injection
1. Hacker identifies 2. Malicious SQL query
vulnerable, SQL- driven is validated &
website & injects Command is executed
malicious SQL query by database
via input data
Website Input Fields
Hacker Database
10
Command Injection
$recipient = $_POST[‘recipient’];
$sql = "SELECT PersonID FROM Person WHERE
Username='$recipient'";
$rs= $db->executeQuery($sql);
• Problem
– What if ‘Recipient’ is malicious string that changes
the meaning of the query?
13
Normal Query
14
• Bad input
–Suppose user = "'or 1=1 -- " (URL
encoded)
–Then scripts does:
ok= execute (SELECT …
WHERE user = ' or 1=1 -- …)
–The “--” causes rest of line to be ignored
–Now the login always succeeds
15
CardSystem Attack
• CardSystems
– Credit card payment processing company
– SQL injection attack in June 2005
– Put out of business
• The Attack
– 263,000 credit card numbers stolen from database
– Credit card numbers stored unencrypted
– 43 million credit card numbers exposed
16
Preventing SQL Injection
17
Cross Site Request Forgery
• Cross-site request forgery (also known as
XSRF or CSRF) is an attack against web-
hosted apps
• Web browsers send some types of
authentication tokens automatically with
every request to a website.
• Also known as a one-click attack or session
riding because the attack takes advantage
of the user's previously authenticated
session.
18
Recall: Session using cookies
Browser Server
POST/
L ogin.cg
i
k ie : a uthe nticator
Set-coo
GET…
cookie
: authe
nticato
r
se
Respon
Vulnerabilities? 19
CSRF
q u est
3: The user visits a malicious
r g e d re
site, (e.g. www.bad-crook- n d s fo ate nk
se im b a
site.example.com.) Which ac ker s legit m the
H a ro
contains an HTML form similar 4: guised ation f
d is u n ic c u ted
to this m exe usly
com t is
es revio
re q u p
g e d si n g ken
o r k u to
5: F e ban idation ie)
h l k
by t ned va on coo
g i
assi enticat
h
( au t
Malicious website 20
HTML form
21
CSRF defense
22
Cross Site Scripting (XSS)
23
Three main web site vulnerabilities
Attacker’s malicious code
• SQL Injection executed on victim server
– Browser sends malicious input to server
– Bad input checking leads to malicious SQL query
• CSRF-Cross-site request Forgery
Attacker site forges request from victim
browser to victim server
– Bad web site sends browser request to good web site,
using credentials of an innocent victim
• XSS - Cross-site scripting
– Bad web site sends innocent victim a script that steals
information from an honest web site
Attacker’s malicious code executed on victim browser 24
Cross-site scripting (XSS)
to v i ctim
e cte d l in k
sc r i pt- in j
cke r s e nd
1. Atta a i l sc a m )
(e.g., em b l e d a ta
S e n d v alu a Attacker
4.
2. Victim click
s on link and
requests legit
imate website
3. Victim’s
browser lo
site, but a ads legitim
lso execut ate
Victim user e s malicious
script
Victim server
25
Two different XSS attacks
• Reflected XSS (“type 1”)
– The attacker script is reflected back to the user as
part of a page from the victim site
26
Reflected XSS attack
to v i ctim
e ct e d l in k
sc r i pt- in j
cke r s e nd
1. Atta a i l sc a m )
(e.g., em b l e d a ta
S e n d v alu a Attacker
4.
2. Victim click
s on link and
requests legit
imate website
3. Victim’s
browser lo
site, but a ads legitim
lso execut ate
Victim user e s malicious
script
Victim server
27
Stored XSS attack
d ata Attacker
a b le
va l u
n d 1. Inject
Se Store bad
4. malicious
2. Victim requ script stuff
e sts content
3. Victim r
eceives an
malicious d execute
script s
Victim user
Victim server
28
XSS defenses
• Proxy-based: analyze the HTTP traffic exchanged
between user’s web browser and the target web
server by scanning for special HTML characters and
encoding them before executing the page on the
user’s web browser
• Application level firewall: anaylze browsed HTML
pages for hyperlinks that might lead to leakage of
sensitive information
• Auditing system: monitor execution of JavaScript
code and compare the operations against high level
policies to detect malicious behaviour
29
• Reference Book:
Andrew Hoffman, Web Application Security,
O’Reilly, 2020
30
COMPSCI4062/COMPSCI5063
Cyber Security Fundamentals
(CSF)
Lecture 9
Digital Forensics
1
Digital Forensics
2
• Focuses on a digital device involved in an incident
or crime
– Computer intrusion
– Generic criminal activity
• Perpetrator uses internet to gather information used in the
perpetration of a crime
– Digital device is an instrument of a crime
• Perpetrator uses cell-phone to set-off a bomb
• Email scams
• Internet auction fraud
• Computer is used for intrusion of another system
3
Digital Forensics
• Digital Investigation has different goals
– Prevention of further intrusions
vGoal is to reconstruct modus operandi of intruder to predict
and prevent further intrusions
– Assessment of damage
vGoal is to certify system for safe use
– Reconstruction of an incident
vFor criminal proceeding
vFor organization-internal proceedings
4
• Process where we develop and test hypotheses
that answer questions about digital events
– We can use an adaptation of the scientific method
where we establish hypotheses based on findings
and then (if possible) test our hypotheses against
findings resulting from additional investigations
5
• Evidence
• Procedural notion
• That on what our findings are based
• Legal notion
• Defined by the “rules of evidence”
• Differ by legislation
• “hear-say” is procedurally evidence, but excluded
(under many circumstances) as legal evidence
6
Types of digital forensics
Computer Forensics Network Forensics
Mobile Forensics
Forensic Data Analysis (FDA)
7
• Digital Forensics is a procedure of acquiring and
processing data found in digital devices. Digital
Forensics was used as a synonym of computer
forensics in early years but now there are different
categories depending on the type of the digital
evidence and procedures.
• Computer Forensics is the procedure of acquiring
a snapshot of the internal state of a computer
system (cloning the hard drive/memory) and
moving on in analysing the acquired copy.
8
• Network forensics is focusing on the
communication aspect of the device and it
captures the traffic as data for further analysis;
helps in intrusion detection.
• Mobile Forensics is representing practices
employed for recovering data from a mobile
device.
• Forensic data analysis is another branch which
focuses on structured data analysis relevant to
financial crimes.
• Most of the time these practices are used in
digital crime investigations and the goal is to
lead into successful prosecution
9
Who should know about digital
forensics
• Those involved in legal proceedings that might
use digital evidence
– Judges, prosecutors, attorneys, law enforcement,
expert witnesses
• Those involve in systems administration
– Systems administrators, network administrators,
security officers
– Those writing procedures
– Managers
10
Is computer Forensics Important?
• Be able to discover
malicious activities
11
Computer Forensics Steps
1. Seizure
2. Acquisition
4. Reporting
12
Note
• Upon arriving at a crime scene a forensic investigator should
be cautious. The forensic investigator must search the crime
scene extensively, label and register in a formal form all the
hardware equipment found and place them safely in antistatic
bags. The hard drive must be removed if a desktop is
discovered powered off and placed in a safe box. If a desktop
is powered on an investigator needs to decide if he/she will
proceed with a live forensics procedure.
15
• Note
– Getting the time from BIOS is important as if this is
set wrongly some evidence might be pointing us in
the wrong direction.
– A registry table example
16
Step 2: Acquisition
17
Step 2: Acquisition
18
• After the seizure has taken place the forensic
investigator will take the hard drive or laptop and
generate a clone copy of its content.
• For this clone a specific hash value will be
generated and kept safely; in this way the forensic
examiner will ensure that while analysing the data
he\she will not make any changes in the copy and
use it as a proof that can be presented in court.
• It is a good practice for an investigator to work on a
second copy; so if anything goes wrong he/she
does not have to re-do this step.
19
• Tools can be used (e.g., FTK Imager) to
acquire a copy of a forensic image.
• There’re the different types of format that
exist; raw format is a bit by bit copy often
accompanied with metadata of the suspect
drive.
• Write blockers ensure that nothing can be
written on the suspect drive which helps in
eliminating the possibility of contaminating
evidence
20
Step 3: Analysis – Physical
Searching (1/3)
• Creating a case using Autopsy
üFirst thing is to make a hash check
üString commands, indexing, grep search via
index & foremost, file carving
üUse of foremost for extracting all the files
üForemost is command-line tool to recover deleted
files from disk images
21
Step 3: Analysis – Physical
Searching (2/3)
22
23
24
25
26
Notes
• In the analysis step the forensics investigator
searches for evidence in the acquired copy. There
are multiple searching techniques that can be
employed that will result in different types of
information.
• List of users, emails, documents, and pictures are
some of the files that can be fully recovered and
examined.
• Always make a hash comparison to ensure your
copy has not been compromised in any way. A good
tool that can be used for loading an image and
moving into the analysis is called Autopsy. 27
Notes
• There are different commands that can be used upon
searching for evidence in a forensic copy. Keyword
searching reminds a bit of google searching. Depending on
what type of investigation you have different relevant words
that can be “good” candidates.
• The grep command is used for specific files that you want to
be extracted. Foremost is one of the most useful ones as it
can extract from our copy all the recovered data and separate
them in different folders depending on their file type; one for
.doc, .pdf etc.
• Metacam is specifically used for getting into the .jpeg
directory. As you dig deeper you might find information also
about the type of the camera that was used to take these
photos
28
Step 3: Analysis – Whitelist
Production
• Creation of Windows XP image (qemu)
containing known “good” hashes for filtering
29
Notes
30
Step 3: Analysis - Registry
Examination (1/2)
• Identifying the users and all the installed
applications and devices on the suspect OS
31
Step 3: Analysis - Registry
Examination (2/2)
• User Activity Tracking
• Malware Analysis
32
Note
33
Step 3: Analysis - Browser Analysis
(1/2)
34
Step 3: Analysis - Browser Analysis
(2/2)
35
• Notice that the suspect has installed a
windows update and has been accessing some
photos saved on their device
36
Step 3: Analysis & Reconstruction
• Creation of .fls file
and use of Zeitline
for examining all
the events
• Creation of events’
timeline by using
Zeitline;
• Filtering and dig
further
37
Notes
38
Step 4: Report
39
Note
42
Note 2/4
43
Note 3/4
44
Note 4/4
45
Summary
46
Fundamentals of
Bitcoin & Blockchain
Nguyen Truong
[email protected]
1
A bit about myself
Hanoi University of Science and Pohang University of Science and DASAN Networks Corporation,
Technology, Vietnam (BSc) Technology, South Korea (MSc) South Korea (Software Engineer)
Liverpool John Moores Imperial College London, Research University of Glasgow, Lecturer
University, Ph.D (2015-2018) Associate (2018-2022) (2022-onward)
Firstly, I would like to introduce a bit about my self My name is Nguyen Truong. I did
my bachelor at Hanoi University of Science and Technology in Vietnam, Master at
Pohang University of Science and Technology in South Korea. I graduated PhD from
Liverpool John Moores University in Liverpool in 2018 and after that (October 2018), I
went to Imperial College London to work as Research Associate/Fellow at Data
Science Institute, Department of Computing. I joined the Uni of Glasgow as an
assistant professor from February this year.
I also have some industry experience as well as I worked as a Software Engineer for a
networking/communications corporation in Seoul Korea for 3 years, programming
some wireless communication protocols (IEEE 802.11ac) for their wireless routers.
2
Outline
I. Concept of Bitcoin
II. Cryptography in Bitcoin
III. Bitcoin Protocol & Blockchain Technology
1. Bitcoin Addresses
2. Bitcoin Distributed Ledger: a Blockchain
3. Transactions in Bitcoin and Blockchain
4. Consensus Mechanism: Proof-of-Work
IV. Research on Bitcoin Security & Privacy
V. Q&A Section
Right, Let’s get to the outline of the lecture, which consists of 4 parts:
In the first part, I briefly introduce the concept of Bitcoin and cryptocurrencies in
comparison with the traditional banking system.
The third section, which is the most important knowledge to be delivered in this
seminar, is to present about how bitcoin works as well as introduce the underlying
technology behind Bitcoin called Blockchain. This section is quite long and consists of
4 parts as you can see here:
1. Bitcoin Addresses
2. Bitcoin Distributed Ledger: a Blockchain
3. Transactions in Bitcoin and Blockchain
4. Consensus Mechanism: Proof-of-Work
3
The forth section is to open some ongoing research directions related to the security
and privacy in bitcoin
3
I. Concept of Bitcoin
Here come to the first part of the talk, I would like to give you some basic concept
about bitcoin.
4
Bitcoin vs Traditional (centralised) Banking system
Ok, before going further to answer the question What Bitcoin IS, we need to
understand the concept of cryptocurrencies and the decentralized payment/banking
system
Let’s take a look at the history and innovation of payment systems throughout the
years.
It starts from a balance sheet Mesopotamia written onto a stone, the Ancient
Accounting Systems in Babylon in 2040BC (Now this stone is in Louve museum,
France.)
After that, we have various the centralized banking systems including American
Express, Bank of America HSBC, VISA, Mastercard.
Until 983, we have an “electronic cash” system proposed by Chaum, which is the
initial idea of crypto-currency.
5
The main difference of electronic cash proposed by Chaum and Cryptocurrency is that
the electronic cash system is a privacy-preserving banking but not decentralized. It
still relies on a centralized banking to operate.
5
David Chaum and E-Cash
➢ Prevent double-spending
➢ Blind Signature: to provide anonymity
➢ Various practical issues:
▪ Need for trusted central party
▪ Computationally expensive
▪ Etc.
In Electronic cash system, Chaum proposed the the RSA blind signatures that
was to ensure the unlinkability between withdrawal and spend transactions.
Depending on the payment transactions, one distinguishes between on-line
and off-line electronic cash: If the payee has to contact a third party (e.g., the
bank or the credit-card company acting as an acquirer) before accepting a
payment, the system is called an on-line system.[2] In 1990, Chaum together
with Moni Naor proposed the first off-line e-cash system, which was also
based on blind signatures.[3]
6
Ideas of Cryptocurrencies
7
▪ How are disagreements resolved?
➢ They also need techniques to
prevent forgery and double
spending.
➢ They should also prevent a denial-
of-service attack
▪ So that someone is not prevented
from spending their money.
7
Protocol Consideration
➢ Consumer:
▪ Privacy; Security; Protection; Regulation
➢ Business:
▪ Availability of anonymity; Cost and ease of acquisition; Availability; Risk
of fraud; Liability for fraud.
➢ Financial And Government:
▪ Consumer protection; Financial loss; Privacy vs fighting crime; Federal
reserve regarding the money.
➢ Technical Challenges:
▪ Anonymous spending; Privacy; Preventing fraud, like double spending;
Cost effective
Some considerations should be taken into account when designing and developing a
digital cash payment. From the perspective of:
➢Consumer:
▪ Privacy; Security; Protection;
Regulation
➢ Business:
▪ Availability of anonymity; Cost
and ease of acquisition;
8
Availability; Risk of fraud;
Liability for fraud.
➢ Financial And Government:
▪ Consumer protection; Financial
loss; Privacy vs fighting crime;
Federal reserve regarding the
money.
➢ Technical Challenges:
▪ Anonymous spending; Privacy;
Preventing fraud, like double
spending; Cost effective
8
What is Bitcoin?
9
Note that Satoshi Nakamoto: The anonymous person or a group of people
believed to have invented Bitcoin.
9
Bitcoin vs Traditional (centralised) Banking system
So, let’s see what are the main differences between the traditional centralised
payment system (central bank or financial service provider) versus Decentralised
payment system (e.g., bitcoin)
We consider three main features: 1- identity, 2- authentication, and 3- transactions
In centralised banking system, it maintains a ledger to record all transactions and
balance sheet:
- Identity is your sort-code, account number.
- To authenticate the user, it is either Physical bank card with PIN, or
Internet/Mobile Banking, and authorised by the banking system.
- How about the transaction: Let say Alice transfers 1USD/1BTC to Bob:
- Record the transaction, then update the balances:
- Alice balance will be deduced by 1
- Bob balance will be added by 1
10
- Authentication: using (elliptic curve) digital signature
- Transactions: verified and recorded (onto distributed ledger (i.e., Bitcoin
blockchain) by participants in the network.
10
Bitcoin vs Traditional (centralised) Banking system
Look at these two figures, we can see the Comparison between centralised ledger
and bitcoin ledger.
The bitcoin distributed ledger is composed by a chain of block in which the current
block is linked with the previous block using the hash of the previous block header: as
you can see in the figure.
That’s why it coined the term: blockchain
Blockchain is the Underlying technology of Bitcoin.
We will go into detail how Bitcoin and Blockchain technology in the next few slides.
11
II. Cryptography and Data
Structure in Bitcoin
Before going into detail of Bitcoin and the underlying Blockchain technology in
Bitcoin,
I would like to remind you some of the crypto techniques used in Bitcoin system.
12
Blockchain Technology
https://bitsonblocks.net/2015/09/09/a-gentle-introduction-to-blockchain-technology/
Unravelling what the blockchain is, how it works, and what its benefits are is pretty
difficult. It took me many weeks to only get a rough idea of what is going on.
13
tech, but Blockchain goes
further than only Bitcoin
13
Public-key Crypto
It is used for two purposes : 1) generating identity in Bitcoin system and 2) digital
signature for verifying transactions in bitcoin system.
Basically, Secp256k1 is used to generate a keypair: public key and private key
for each user of Bitcoin system. It takes the Secp256k1 with a cryptographic
pseudo random generator to generate the key pair.
14
Public-key Crypto: Digital Signatures
15
Cryptographic Hash Functions
Fixed Size
Message of arbitrary length Hash Fn Hash
16
16
Linked List and Blockchain
➢ A linked list is a basic data structure where a series of data blocks are linked
together.
➢ Each block contains the ID of the next one in the chain.
➢ It is possible to get to all of the blocks if we start with a pointer to the first
block in the list.
➢ If each block also contains a hash of the previous block, then it is called a chain
of block. The Bitcoin Ledger is stored in a chain of block, or Blockchain
➢ It is not possible to insert a block in the middle of the list.
▪ One of the hashes would disagree.
In Bitcoin, the LEDGER is stored in a chain of blocks, which is a special type of linked
list data structure; hence the name Blockchain.
➢ A linked list is a basic data structure where a series of data blocks are linked
together.
➢ Each block contains the ID of the next one in the chain.
➢ It is possible to get to all of the blocks if we start with a pointer to the first
block in the list.
➢ If each block also contains a HASH of the PREVIOUS BLOCK, then it is called
a Block Chain.
➢ It is not possible to insert a block in the middle of the list. Because if we do that
→ One of the hashes would disagree.
17
lock lock lock
ea er ea er ea er
Here are the figures of linked list and blockchain, a special type of linked list.
18
Data Structure:
Binary and Merkle Tree
➢ A binary tree is like a linked list, but each block has pointers to two
other blocks.
➢ In a sorted binary tree, the left and right linked blocks are in sorted
order.
▪ Left before, right after.
➢ It is possible to find a block or prove that a block is not in a sorted tree,
much quicker than a linked list.
▪ Not all the blocks need to be checked.
➢ Each block in a binary tree can also contain the hashes of the two
linked blocks. It is then called a Merkle tree.
▪ It is impossible to insert a block in the middle of the tree
afterwards.
In each block, many transactions are recorded. These transactions are stored using
Merkle tree data structure.
Before going to Merkle tree data structure, I would like to remind a bit about Binary
tree.
➢ A binary tree is like a linked list, but each block has pointers to two other blocks.
➢ In a sorted binary tree, the left and right linked blocks are in sorted order.
▪ Left before, right after.
➢ It is possible to find a block or prove that a block is not in a sorted tree, much
quicker than a linked list.
▪ Not all the blocks need to be checked.
19
20
Here is the figures illustrate the Merkle tree data structure, and how the transactions
Tx0, Tx1, Tx2, and Tx3 is stored in Merkle tree in one Bitcoin Block (right hand side
figure).
Note that: The root of the Merkle tree is put in the block header.
20
Back to Bitcoin
Miner P2P
Network
Developer
Ok, let assume that we grasp necessary knowledge about cryptography techniques to
be used in Bitcoin,
Now, we’re going back to Bitcoin.
21
• How to exchange privacy-preserving payments?
21
III. Bitcoin Protocol
1. Bitcoin Addresses
2. Bitcoin Distributed Ledger: Bitcoin Blockchain
3. Transactions
4. Consensus Mechanism: Proof-of-Work
22
BTC Addresses: Identity
1EGam2BeXd8sgphB44mEYqnDyDszw4YTEr
3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy
The first important thing is the Identities in Bitcoin system called Bitcoin Addresses.
As I mentioned in the previous slide, each user has a public and Private key-pair.
And the Bitcoin address is generated using Hash of Hash of the user’s public-key (two
HASH operations for better security)
This Address is then used in the transactions to exchange Bitcoin and written onto the
distributed ledger (i.e., the bitcoin blockchain).
And this is the detail how the Bitcoin Addresses is generated.
23
Bitcoin Ledger: a Blockchain
• Remind:
• Bitcoin distributed ledger is a chain of blocks (i.e., Bitcoin blockchain)
• Each block contains Header and Transactions
• Nodes in the Bitcoin network are expected to store exactly the same
ledger (i.e., blockchain) → reach the consensus
We have identity in the ledger, now let’s see how the bitcoin ledger is constituted:
24
Bitcoin Block
https://bitcoin.org/en/developer-reference#block-headers
Here the detailed structure of the block: Each block contains Header and Transactions
- Prev. Hash: A SHA256(SHA256()) hash in internal byte order of the previous block’s
header. This ensures no previous block can be changed without also changing this
block’s header.
- Merkle Root hash
- Time
- Nonce: An arbitrary number miners change to modify the header hash in order to
produce a hash less than or equal to the target threshold
25
Transactions in Bitcoin
• Transactions:
• Data Types: Merkle Tree
• Root hash of the Merkle Tree is
written in the header
• If any transaction is modified, then the
Root hash is changed
→ resulting in the change of the hash of
Block header.
26
Transactions in Bitcoin
• Transaction:
• Alice transfers 0.25 BTC to Bob
Alice Bob
Transaction
@Alice @Bob
Wallet Wallet
27
1. {"hash":"7c4025...",
2. "ver":1,
Transaction in Bitcoin 3. "vin_sz":1,
4. "vout_sz":1,
5. "lock_time":0,
• ransaction Data ype: “Input”, 6. "size":224,
“ utput” an other para eters 7. "in":[ Tx Input
8. {"prev_out":
• Input of the transaction is an output of 9. {"hash":"2007ae...",
another transaction. 10. "n":0},
• Alice needs to claim she has 1BTC by
showing the output of another transaction 11. "scriptSig":"304502... 042b2d..."}],
(which is 1BTC) belong to her. 12. "out":[ Tx Output
• To do that, Alice needs to use her private- 13. {"value":"0.25",
key to generate her digital signature 14. "scriptPubKey":"OP_DUP OP_HASH160 a7db6f
• Outputs: Define conditions using a OP_EQUALVERIFY OP_CHECKSIG"} Condition to
scripting system {"value":"0.75", Bob
• The conditions must be satisfied in order to 15. "scriptPubKey":"OP_DUP OP_HASH160 34sa6f
spend the output in the next transactions OP_EQUALVERIFY OP_CHECKSIG"}]} Condition to
Alice
28
28
Bitcoin Scripting System
<signature><publicKey> OP_CHECKSIG
Constants Operation
are pushed onto executed on
the stack stack values
CRYPTOGRAPHY AND SECURE DEVELOPMENT 29
DR. NGUYEN TRUONG: [email protected]
29
Transactions in Bitcoin
0.25 BTC
@Bob
1 BTC 0.5 BTC
@Alice @Eve
0.75 BTC 0.75 BTC
@Alice @Alice
0.25 BTC
@Alice
Transaction 1 Transaction 2
https://developer.bitcoin.org/reference/transactions.html
Another example here, Alice after the transaction 1 wants to transfer 0.5BTC to Eve
(transaction 2):
She claims the output of the transaction1 as the input of the transaction2 and so on…
Ok, now we understand the whole structure of a block in the Bitcoin blockchain (the
ledger).
Remind: header (contains previous hash of the previous block’s header) and number
of transactions which are structured using Merkle tree.
Now, let’s move on how a new Block is appended to the ledger → this is call the
consensus mechanism/consensus algorithm/consensus protocol
30
Consensus Mechanism: Proof-of-Work
Probably many of you guys here heard about the term Proof-of-work in Bitcoin.
Let’s see what it is.
31
Consensus Mechanism: Proof-of-Work
• Nonce?
• Number only used once
• Some nodes in the Bitcoin network try to find
Nonce N, s.t.:
→ this process is known as “mining”, an the
no es are “miners”
Hold on, we understand all of the information in a Bitcoin BLOCK, except the
term NONCE.
A nonce is an abbreviation for "number only used once”.
The "nonce" in a bitcoin block is a 32-bit (4-byte) field whose value is adjusted
by miners so that the hash of the block will be less than or equal to the
current target of the network.
Any change to the block data (such as the nonce) will make the block hash
completely different.
Since it is believed infeasible to predict which combination of bits will result in
the right hash, many different nonce values are tried, and the hash is
recomputed for each value until a hash less than or equal to the
current target of the network is found.
32
Consensus Mechanism: Proof-of-Work
Proof-of-work:
Pick a nouce such that H(prev hash, nounce,
Tx) < E. E is a variable that the system
specifies. Basically, this amounts to finding a
hash value whose leading bits are zero.
There is no way to bypass/short cut the
calculation. Only try all possibilities to find
the nonce.
The work required is exponential in the
number of zero bits required.
33
An example here, we try out values of the nonce
N to satisfy Hash(Hash(B3)|txs|N) < target
= 0x000**
33
Successful
Proof-of-Work: Miner C
Update Rule and Forks
This usually happens due to a it is huge network, lots of miners, and the
transmission of the broadcast of the new block takes time to reach all nodes in
the network.
Let consider: we have to miners A and B successfully mine a block. Both
successfully find the nonce to produce a new block (not that the list of
transactions might be different) and broadcast their new blocks to the network
Consider node X and node Y in the network. X receives the new Block from miner A
first, consequently, when it receives the new block from miner B, it will discard this
block.
On the other hands, node Y receives block from B first, thus discard the block
broadcasted from A.
This will create two different blockchains in the network, called Forks.
34
Proof-of-Work:
Update Rule and Fork
Eventually all the nodes will have a same blockchain (the longest one).
So at this point of time, there are two blockchain in the network. That’s alright, don’t
worry.
Let consider the next block, for instance, Miner C computes the nonce for the next
block (look at the figure in the previous slide)
The current blockchain in the miner C contains the block from miner A the miner C
mined on this blockchain.
Then when it broadcast its new block to the whole network, node Y for instance, see
this blockchain from miner C and it will replace this new blockchain as this blockchain
from miner C is longer than the current one.
In other word, the previous block from miner B is discarded, and the block is called
orphan block.
→ Eventually all the nodes will have a same blockchain (the longest one)
35
IV. Research on Bitcoin Security &
Privacy
36
Security in Bitcoin
Confidentiality→ Pseudonymity
Are my transactions private? Anonymous?
37
The first two challenges are nicely solved by using public-key cryptography/ Peer-to-
peer network protocols as mentioned in the previous slides.
We are now considering the integrity and the confidentiality security aspects:
37
Why Proof-of-Work?
*https://ccaf.io/cbeci/index
According to the Cambridge Center for Alternative Finance (CCAF), Bitcoin currently
consumes around 110 Terawatt Hours per year — 0.55% of global electricity
production, or roughly equivalent to the annual energy draw of small countries like
Malaysia or Sweden.
Bitcoin has set a new hashrate record of at just shy of 150 exa-
hashes per second — 150 with 18 zeroes. This is coming less than
10 days before the 2020 bitcoin halving.
The effects of the hashrate surge are already evident with block
explorers registering 16 blocks mined in one hour just days ago.
38
This is way above the six blocks per hour on average the network is
used to.
38
Bitcoin Security: Double-spend
Victim V
39
Bitcoin Security: Double-spend
40
This is practically impossible.
However, we have a concept of Mining pool, it is because the
40
Bitcoin Privacy: Pseudonimity
Here we have:
•Bitcoin is pseudo-anonymous as due to
its BTC addresses (like a random string of
41
characters)
ut What’s wrong? e e ber the
transactions from Alice to Bob, and Alice to
Eve:
Alice BTC relates to each other due to
the definition of transactions
Combined with other side-information
or low-layer network information (e.g.,
IP addresses) in the Bitcoin network
There is a change of figuring out the
real identity of BTC owners.
Some Solutions have been proposed such
as
Mixer, JoinCoin, k-anonymity Privacy,
N-anonymity Privacy, Zeno-
Knowledge-Proof
However, there is always a trade of
between privacy and performance. It is
still an ongoing research topic.
41
Thank you for
your listening
#UofGWorldChangers
@UofGlasgow
42
DayOfWeek, DayOfMonth Month 2XXX
XX.XX am/pm XX.XX am/pm
(2 hours)
Note: the questions without answers are from tutorials and quizzes.
The answers can be found in the Moodle page (tutorials and quizzes)
1. This part consists of 10 multiple-choice questions. A correct answer to the question is
worth 1.5 marks, an incorrect answer will result in -0.5 mark, and no answer will result in
0 marks. Only one answer is correct. [15]
(a) Which of the following is not the purpose of user authentication?
(A) access control
(B) accountability
(C) confidentiality
(D) availability
(b) Which is not the purpose of Man-in-the-middle attack?
(A) render a service inaccessible
(B) manipulate transmitted content
(C) collect information
(D) collect personal data
(c) From technique side, which of the following is the most reasonable way to recognise a
phishing email?
(A) Checking the sender name appears in the email
(B) Clicking the link in the email content
(C) Replying the email to confirm information
(D) Checking the contents of the email in a sandbox environment
(d) Which is the most important for the Acquisition step in computer forensics?
(A) Shut down the computer in the scene
(B) Using specific devices (e.g. write blockers) to save the raw data
(C) Save the data in a personal device
(D) Save in a format that’s easy to be analysis
(e) what is the common part of the SQL injection and cross-site request forgery?
(A) attack via SQL code
(B) attackers can edit the data saved in the server
(C) attackers can change the information shown in the website
(D) attack via sending a malicious link to the user
(f) For basic elements of access control, which of the following can be an object?
(A) Records
(B) Directory trees
(C) Mailboxes
(D) All of the above
(g) Which of the following are ignored in most access control policies?
1 CONTINUED OVERLEAF
(A) Subject attributes
(B) Object attributes
(C) Environment attributes
(D) None of the above
(h) Which of the cipher block modes supports the multiple blocks processing in parallel?
(A) Cipher Block Chaining
(B) Cipher Feedback
(C) Counter
(D) None of the above
(i) In RSA, we have p=7, q=2, e=5, which of the following can be a value of d?
(A) 3
(B) 19
(C) 11
(D) None of the above
(j) What protocol is NOT a part of SSL/TLS?
(A) Handshake protocol
(B) Change cipher spec protocol
(C) Record protocol
(D) Heartbeat protocol
2. Assume a system with N job positions. For job position i, the number of individual users
in that position is Ui and the number of permissions required for the job position is Pi .
(a) For a traditional discretionary access control (DAC) scheme, how many relationships
between users and permissions must be defined? [2]
(b) For a role-based access control (RBAC) scheme, how many relationships between users
and permissions must be defined? [2]
3. (a) Briefly explain the difference between cross-site request forgery and cross-site scripting.
Focus on the difference on 1) where the vulnerability come from 2) the consequence if the
attack happens . [6]
(b) List the possible methods to prevent the above attacks and explain why. (list two methods
for each attack)? Q3: This assesses the two attacks in the web application. [4]
4.
The answers can be found in Lecture 8
Explain how user authentication works. List the three main types of user authentication.[6]
Q4: This assesses the the user authentication. The answer can be found in Lecture 7
5. In IEEE 802.11, open system authentication simply consists of two communications. An
authentication is requested by the client, which contains the station ID (typically the MAC
address). This is followed by an authentication response from the AP/router containing a
success or failure message. An example of when a failure may occur is if the client’s MAC
address is explicitly excluded in the AP/router configuration.
2 CONTINUED OVERLEAF
(a) What are the benefits of this authentication scheme? [2]
(b) What are the security vulnerabilities of this authentication scheme? [2]
6. For WEP, data integrity and data confidentiality are achieved using the RC4 stream en-
cryption algorithm. The transmitter of an MAC protocol data unit (MPDU) performs the
following steps, referred to as encapsulation:
1. The transmitter selects an initial vector (IV) value.
2. The IV value is concatenated with the WEP key shared by transmitter and receiver to
form the seed, or key input, to RC4.
3. A 32-bit cyclic redundancy check (CRC) is computed over all the bits of the MAC data
field and appended to the data field. The CRC is a common error-detection code used in
data link control protocols. In this case, the CRC serves as a integrity check value (ICV).
4. The result of step 3 is encrypted using RC4 to form the ciphertext block.
5. The plaintext IV is prepended to the ciphertext block to form the encapsulated MPDU
for transmission.
(a) Draw a block diagram that illustrates the encapsulation process. [3]
(b) Describe the steps at the receiver end to recover the plaintext and perform the integrity
check. [3]
(c) Draw a block diagram that illustrates part b. [3]
7. Perform encryption and decryption using the RSA algorithm for the following
(a) p = 3; q = 11; e = 7; M = 5. [2]
(b) p = 5; q = 11; e = 3; M = 9. [3]
(c) p = 17; q = 31; e = 7; M = 2. [3]
8. For any block cipher, the fact that it is a nonlinear function is crucial to its security. To
see this, suppose that we have a linear block cipher EL that encrypts 128-bit blocks of
plaintext into 128-bit blocks of ciphertext. Let EL(k, m) denote the encryption of a 128-bit
message m under a key k (the actual bit length of k is irrelevant). Thus
Describe how, with 128 chosen ciphertexts, an adversary can decrypt any ciphertext with-
out knowledge of the secret key k. (A “chosen ciphertext” means that an adversary has
the ability to choose a ciphertext and then obtain its decryption. Here, you have 128
plaintext/ciphertext pairs to work with and you have the ability to chose the value of the
ciphertexts.) [4]