CS - 1-15 - Merged
CS - 1-15 - Merged
(Contact Session – 1)
Confidentiality
Integrity
Availability
Confidentiality
Integrity
Availability
Accountability
Security Attacks
Repudiation
Attacking Integrity
Snooping,
Confidentiality PASSIVE
Traffic Analysis
Modification,
Masquerading,
Replaying, Integrity ACTIVE
Repudiation
Denial of Service
Availability ACTIVE
(DoS)
Sample mapping:
mechanisms to services
Sender Receiver
Secret Secret
Information Information
Opponent
• A logical information channel is established by defining a route through the Internet from source to destination and by the
cooperative use of communication protocols (e.g., TCP/IP) by the sender and receiver.
• An opponent may present a threat to the confidentiality of the message that is being transmitted.
• Using a secret information, sender secures the original message (encrypted or ciphered) and using the same or different
secret information receiver recovers the original message (decrypted or deciphered).
• A trusted third party distributes the secret information to both the sender and receiver.
1. Cryptography
2. Steganography
Cryptography:
i. Symmetric-Key cryptography
ii. Asymmetric (or Public) Key cryptography
iii. Data Integrity
iv. Mutual Trust
Mathematically have:
Y = EK(X)
X = DK(Y)
Data Integrity
Ensuring data correctness.
Hashing
A fixed-length message digest is created out of a variable-
length message. The digest is normally much smaller than the
message.
Mutual Trust
Different methods for key generation and distribution. Entity
authentication and notarization methods.
Thank You!
Network Security
(CS - 2)
• CIA Traid
• Security Attacks
• Security Mechanisms
• Security Services
Sender Receiver
Secret Secret
Information Information
Opponent
1. Cryptography
2. Steganography
Mathematically have:
Y = EK(X)
X = DK(Y)
Assume encryption algorithm is known -> Implies a secure channel to distribute key.
To send a secure message, the sender first encrypts the message using receiver’s
public key.
To decrypt the message, the receiver uses its own private key.
Receiver’s Receiver’s
public key private key
Mutual Trust
Different methods for key generation and distribution. Entity authentication and
notarization methods.
Steganography:
• An alternative to encryption
• Hides existence of message
• Done by using only a subset of letters/words in a longer message marked in
some way
• Hiding in LSB in graphic image or sound file
• Drawback
❑ High overhead to hide relatively few info bits
Steganography:
https://towardsdatascience.com/steganography-hiding-an-image-inside-another-77ca66b2acb1
nordvpn.com/blog/brute-force-attack/
Known plaintext
– The attacker has access to the ciphertext and its corresponding plaintext.
The goal is to guess secret key or to deduce the encryption algorithm.
Chosen plaintext
– Choose arbitrary plaintext to be encrypted and receive the corresponding
ciphertext.
Chosen ciphertext
– The attacker has the capability to make the victim decrypt any ciphertext and
send back the result. This result can be used to guess the secret key.
Unconditional security
– No matter how much computer power or time is available, the cipher cannot be
broken since the ciphertext provides insufficient information to uniquely determine
the corresponding plaintext.
Computational security
– Given limited computing resources (e.g. time needed for calculations is greater
than age of universe), the cipher cannot be broken.
• Substitution Ciphers
• Transposition Ciphers
Substitution Ciphers
Mapping
Plain: abcdefghijklmnopqrstuvwxyz
Key: DKVQFIBJWPESCXHTMYAUOLRGZN
Encryption
Plaintext: if we wish to replace letters
Ciphertext: WI RF RWAJ UH YFTSDVF SFUUFYA
If the cryptanalyst knows the nature of the plaintext (e.g. English text), then the
regularities of the language can be exploited.
• For example, "th lrd s m shphrd shll nt wnt" letters are not equally used.
• The cryptanalyst can have tables of single, double & triple letter frequencies for
various languages.
…FPOMBZWPFUPZH…
Guess P & Z are e and t
Guess ZW is th (di-gram or digram) and hence ZWP is the (trigram)
Similarly, analyze the sequence ZWSZ in the first line. We do not know that
these four letters form a complete word, but if they do, it is of the form th_t.
Thank You!
Network Security
(CS - 3)
Substitution ciphers
• Ceaser Cipher
• Monoalphabetic Cipher
Not even the large number of keys in monoalphabetic cipher provides security.
To reduce the "spikyness" of the underlying plaintext (natural language text), one
approach is to encrypt more than one letter at once.
2. If both plaintext letters fall in the same matrix row, replace each letter with the letter
to right (wrapping back to start from end). For example, on is encrypted as NA.
3. If both plaintext letters fall in the same matrix column, replace each with the letter
below it (again wrapping to top from bottom). For example, mu is encrypted as CM.
4. Otherwise, each letter is replaced by the letter in the same row and in the column of
the other letter of the pair. For example, hs becomes BP and ea becomes IM (or JM,
as per encipherer’s wish.)
BITS Pilani, Pilani Campus
Security of Playfair Cipher
Security is much improved over monoalphabetic cipher.
It was widely used for many years
– E.g. by US & British military in WW1
But, concluded that it can be broken, given a few hundred letters as still it has
much of plaintext structure.
Makes cryptanalysis harder with more alphabets to guess and to flatter frequency
distribution.
Uses a key to select which alphabet is used for each letter of the message.
For example, the message “we are discovered save yourself” would be encrypted
using the key deceptive as -
Key: deceptivedeceptivedeceptive
Plaintext: wearediscoveredsaveyourself
Ciphertext: ZICVTWONGRZGVTWAVZHCQYGLMGJ
Key: deceptivedeceptivedeceptive
Plaintext: wearediscoveredsaveyourself
Ciphertext: ZICVTWONGRZGVTWAVZHCQYGLMGJ
An attacker looking at only the ciphertext would detect the repeated sequences VTW at
a distance of 9 letters and make the assumption that the keyword is either three or
nine letter in length. This becomes a good guess when the message is long.
• Introduced by an AT&T engineer named Gilbert Vernam that works on binary data
(bits) rather than letters.
• Vernam proposed the use of a running loop of tape that eventually repeated
the key, so that in fact the system worked with a very long but repeating keyword.
• It can be broken with sufficient ciphertext, the use of known or probable plaintext
sequences, or both.
Joseph Mauborgne proposed using a random key that is as long as the message, in
a way that the key need not to be repeated.
The key is to be used to encrypt and decrypt a single message, and then discarded.
Each new message requires a new key of the same length as of its length.
CT: ANKYODKYUREPFJBYOJDSPLREYIUNOFDOIUERFPLUYTS
Key: pxlmvmsydofuyrvzwcptnlebnenjfkdnnjfhnflzzie
PT: mr mustard with the candlestick in the hall
CT: ANKYODKYUREPFJBYOJDSPLREYIUNOFDOIUERFPLUYTS
Key: mfugpmiydfkhllawqortenxzafnbvtodfsnvgwermfn
PT: miss scarlet with the knife in the library
Suppose the cryptanalyst had managed to find these two keys. Two plausible
plaintexts are produced.
How the cryptanalyst can decide which is the correct decryption?
BITS Pilani, Pilani Campus
One-Time Pad
– Relation between Security and Implementation
The one-time pad offers complete security but, in practice, has two fundamental
difficulties.
Thank You!
Network Security
(CS - 4)
The plaintext is written down as a sequence of diagonals and then read off as a
sequence of rows.
Example:
CT: MEMATRHTGPRYETEFETEOAAT
Key: 4 3 1 2 5 6 7
a t t a c k p
o s t p o n e
d u n t i l t
w o a m x y z
CT: TTNAAPTMTSUOAODWCOIXKNLYPETZ
Second Iteration:
PT: TTNAAPTMTSUOAODWCOIXKNLYPETZ
Key: 4 3 1 2 5 6 7
t t n a a p t
m t s u o a o
d w c o i x k
n l y p e t z
CT: NSCYAUOPTTWLTMDNAOIEPAXTTOKZ
It uses a finite number of values and loops back from either end
where needed.
For Integers in 𝑍𝑛
𝐴 ≡ 𝐵 𝑚𝑜𝑑 𝑛
It can also be said that A and B are in the same Equivalence Class.
In abstract algebra with sets, we can combine two elements of the set,
perhaps in several ways, to obtain a third element of the set.
These operations are subject to specific rules, which define the nature
of the set.
Obeys:
Closure: If a and b belong to G, then a • b is also in G.
Associative: a • (b • c) = (a • b) • c for all a, b, c in G.
Identity element: For each a in G, there is an element e in G such that
e•a=a•e=a
Inverse element: For each a in G, there is an element a’ in G such that
a • a’ = a’ • a = e.
BITS Pilani, Pilani Campus
Group
Example:
𝑍6 = 0, 1, 2, 3, 4, 5 and the binary operation is addition modulo 6.
Added
thrice
Added
twice
More Information
Exercise
1. The set of all integers under multiplication?
2. The set of all even integers under addition?
3. The set of all odd integers under addition?
Thank You!
Network Security
(CS – 5)
RANDOM NUMBERS
Random Numbers
Random numbers play an important role in encryption for various network security
applications.
• An opponent should not be able to predict future elements of the sequence on the
basis of previous elements.
• random.org
• The randomness requirement for a PRNG is that the generated bit stream
should appear random even though it is deterministic.
• There is no single test that can determine if a PRNG generates numbers that
have the characteristic of randomness.
• The best that can be done is to apply a sequence of tests to the PRNG. If the
PRNG exhibits randomness on the basis of multiple tests, then it can be
assumed to satisfy the randomness requirement.
Frequency test: Determining whether the number of ones and zeros in a sequence
is approximately the same as would be expected for a truly random sequence.
Maurer’s universal statistical test: The focus of this test is the number of bits
between matching patterns.
– The purpose of the test is to detect whether or not the sequence can be
significantly compressed without loss of information. A significantly compressible
sequence is considered to be non-random.
1. Forward unpredictability: If the seed is unknown, the next output bit in the
sequence should be unpredictable in spite of any knowledge of previous bits in the
sequence.
No correlation between a seed and any value generated from that seed should be
evident.
• The sender need to find a way to deliver the seed to the receiver in a
secure fashion.
PSEUDORANDOM NUMBER
GENERATORS
Pseudorandom number generators
For example,
Consider the values 𝑎 = 7, 𝑐 = 0, 𝑚 = 32, and 𝑥0 = 1. This generates the
sequence {7,17,23,1,7,etc.}.
𝑋1 = 7 ∗ 1 + 0 𝑚𝑜𝑑 32 = 7 𝑚𝑜𝑑 32 = 7
𝑋2 = 7 ∗ 7 + 0 𝑚𝑜𝑑 32 = 49 𝑚𝑜𝑑 32 = 17
𝑋3 = 7 ∗ 17 + 0 𝑚𝑜𝑑 32 = 119 𝑚𝑜𝑑 32 = 23
𝑋4 = 7 ∗ 23 + 0 𝑚𝑜𝑑 32 = 161 𝑚𝑜𝑑 32 = 1
𝑋5 = 7 ∗ 1 + 0 𝑚𝑜𝑑 32 = 7 𝑚𝑜𝑑 32 = 7
1. The function should be a full-duration generating function. That is, the function
should generate all the numbers between 0 and 𝑚 before repeating.
1. First of all, choose two prime numbers 𝑝 and 𝑞 of the same equivalence
class.
– For example, the prime numbers 7 and 11 satisfy
» 7 ≡ 11 ≡ 3 (mod 4) for the given modulo 4
2. Compute 𝑛 = 𝑝 * 𝑞
Stream Cipher
Stream Cipher
• The output of the generator, called a keystream, is combined one byte at a time
with the plaintext stream using the bitwise exclusive-OR (XOR) operation.
For example, if the plaintext byte is 01101100 and the keystream byte is 11001100,
then the resulting ciphertext byte is:
Thank You!
Network Security
(Contact Session – 6)
• S at all times, contains a permutation of all 8-bit numbers from 0 through 255.
• Otherwise, for a key of length keylen bytes, the first keylen elements of T are
copied from K, and then K is repeated.
Example:
For keylen=3
𝑆0 =0 𝑇0 = 𝐾[0]
𝑆1 =1 𝑇1 = 𝐾[1]
𝑆2 =2 𝑇2 = 𝐾[2]
𝑆3 =3 𝑇3 = 𝐾[0]
𝑆4 =4 𝑇4 = 𝐾[1]
𝑆5 =5 𝑇5 = 𝐾[2]
𝑆6 =6 𝑇6 = 𝐾[0]
… …
This involves starting with S[0] and going through to S[255], and for each, swapping
with another byte in S according to a scheme dictated by T[i]:
Stream generation involves cycling through all elements of S, where for each S[i],
swapping with another byte in S according to the current configuration of S.
• The greatest common divisor of two integers is the largest integer that can divide
both of them.
1. gcd(a,0) = a
2. gcd(a,b) = gcd(b,r), where r is the remainder of dividing a by b
• The first fact tells us that if the second integer is 0, the GCD is the first one.
• The second fact allows us to change the value of a and b until b becomes 0.
gcd(36, 10) 6
gcd(10, 6) 4
gcd(6, 4) 2
gcd(4, 2) 0
gcd(2, 0) = 2
• Given two integers a and b, we often need to find other two integers, s and t, such
that
𝑠 × 𝑎 + 𝑡 × 𝑏 = gcd(𝑎, 𝑏)
• The extended Euclidean algorithm can calculate the gcd(a,b) and at the same
time calculate the value of s and t.
q r1 r2 r s1 s2 s t1 t2 t
5 161 28 21 1 0 1 0 1 -5
1 28 21 7 0 1 -1 1 -5 6
3 21 7 0 1 -1 4 -5 6 -23
7 0 -1 4 6 -23
Addition Multiplication
+ 0 1 2 3 4 × 0 1 2 3 4
0 0 1 2 3 4 0 0 0 0 0 0
1 1 2 3 4 0 1 0 1 2 3 4
2 2 3 4 0 1 2 0 2 4 1 3
3 3 4 0 1 2 3 0 3 1 4 2
4 4 0 1 2 3 4 0 4 3 2 1
Additive inverse Multiplicative inverse
𝑎 0 1 2 3 4 𝑎 0 1 2 3 4
−𝑎 0 4 3 2 1 𝑎−1 - 1 3 2 4
• Galois showed that for a field to be finite, the number of elements should be 𝑝𝑛 ,
where 𝑝 is a prime and 𝑛 is a positive integer.
• The finite fields are usually called Galois fields and denoted as GF(𝑝𝑛 ).
• This field can be the set 𝑍𝑝 , {0, 1, 2, …, (p-1)}, with two arithmetic operations
(addition and multiplication).
• Recall fields, that in this set each element has an additive inverse and that non-zero
elements have a multiplicative inverse (no multiplicative inverse for 0).
• GF(2) with the set {0, 1} and two operations, addition and multiplication.
Addition Multiplication
+ 0 1 2 3 4 × 0 1 2 3 4
It’s a GF(5)
0 0 1 2 3 4 0 0 0 0 0 0
1 1 2 3 4 0 1 0 1 2 3 4
2 2 3 4 0 1 2 0 2 4 1 3
3 3 4 0 1 2 3 0 3 1 4 2
4 4 0 1 2 3 4 0 4 3 2 1
Additive inverse Multiplicative inverse
a 0 1 2 3 4 a 0 1 2 3 4
-a 0 4 3 2 1 𝑎−1 - 1 3 2 4
Thank You!
Network Security
(Contact Session – 7)
• The finite fields are usually called Galois fields and denoted as
GF(𝑝𝑛 ).
• This field can be the set 𝑍𝑝 , {0, 1, 2, …, (p-1)}, with two arithmetic
operations (addition and multiplication).
Addition Multiplication
+ 0 1 2 3 4 × 0 1 2 3 4
It’s a GF(5)
0 0 1 2 3 4 0 0 0 0 0 0
1 1 2 3 4 0 1 0 1 2 3 4
2 2 3 4 0 1 2 0 2 4 1 3
3 3 4 0 1 2 3 0 3 1 4 2
4 4 0 1 2 3 4 0 4 3 2 1
Additive inverse Multiplicative inverse
a 0 1 2 3 4 a 0 1 2 3 4
-a 0 4 3 2 1 𝑎−1 - 1 3 2 4
Polynomial Arithmetic
Polynomial Arithmetic
• What is a polynomial?
• Example: 𝒙𝟑 + 𝟐𝒙𝟐 − 𝟓𝒙 + 𝟗
(polynomial with a single variable 𝑥)
• Multiplication
𝑓 𝑥 = 𝑞 𝑥 × 𝑔 𝑥 + 𝑟(𝑥)
𝑓 𝑥 = 𝑥 3 +𝑥 2 +2
𝑔 𝑥 = 𝑥2 − 𝑥 + 1
𝑞 𝑥 =𝑥+2
𝑟 𝑥 =𝑥
Block Cipher
Block Cipher
• There are 2^n possible different plaintext blocks and, for the encryption to be
reversible, each block must produce a unique ciphertext block.
Product Cipher
• Execution of two or more simple ciphers in sequence in such a way that the final
result or product is cryptographically stronger than any of the component
ciphers.
LE0 RE0
• The plaintext is divided into two equal halves LEi and REi. E stands
F K1
for Encryption., L stands for left and R stands for right. Initially i = 0.
• A subkey Ki+1 is derived from the key K. So, initially the derived key
is K1. LE1 RE1
• A function F is defined which takes subkey Ki+1 and right half REi of F K2
the data as inputs.
• The output of the function F is XORed with the left half of the data
(LEi) and made the new right half (REi+1). LE2 RE2
• Right half (REi) of the previous round makes the left half for the next K16
round (LEi+1).
LE16 RE16
• The iteration is repeated 16 times and the left and right halves are
swapped.
LE17 RE17
• The final output is the ciphertext. Output (Ciphertext)
LD0 RD0
• The same steps are used for decryption. (D stands LD1 RD1
for Decryption). K1
LD16 RD16
• Confusion and Diffusion is induced through multiple
iterations.
F K16
LE17 RE17
Input (Ciphertext)
Thank You!
Network Security
(Contact Session – 8)
• There are 2^n possible different plaintext blocks and, for the encryption to be
reversible, each block must produce a unique ciphertext block.
LE0 RE0
• The plaintext is divided into two equal halves LEi and REi. E stands
for Encryption., L stands for left and R stands for right. Initially i = 0. F K1
• A subkey Ki+1 is derived from the key K. So, initially the derived key
is K1. LE1 RE1
• A function F is defined which takes subkey Ki+1 and right half REi of F K2
the data as inputs.
• The output of the function F is XORed with the left half of the data
(LEi) and made the new right half (REi+1). LE2 RE2
• Right half (REi) of the previous round makes the left half for the next K16
round (LEi+1).
LE16 RE16
• The iteration is repeated 16 times and the left and right halves are
swapped.
LE17 RE17
• The final output is the ciphertext. Output (Ciphertext)
LD0 RD0
• The same steps are used for decryption. (D stands LD1 RD1
for Decryption). K1
LD16 RD16
• Confusion and Diffusion are induced through multiple
iterations.
F K16
LE17 RE17
Input (Ciphertext)
AES Algorithm
Confusion and Diffusion
• Diffusion means each plaintext letter affect the value of many
cipher text letters. For example, a plaintext letter ‘B’ need not be
ciphertext letter ‘E’ all the time. It could be something else also.
• Confusion means the statistical relationship between the rule to
encrypt and the ciphertext produced should be as complex as
possible.
4×4
Key Expansion
Round 2 Round 2 key (16 bytes)
4 transformations
W0 W1 W2 W3
Left shift by 1
Substitution box
Round constant
0000 0011
row column
0111 1011
(Substituted
values for B1)
Key Expansion
Round 2 Round 2 key (16 bytes)
4 transformations
XOR Round 1
W0 W1 W2 W3
• At this stage, the initialization is complete and we are ready for rounds.
𝐾9
𝐾10
0000 0011
row column
0111 1011
2 3 1 1 b1 b5 b9 b31
1 2 3 1 b2 b6 b10 b14
1 1 2 3
× b3 b7 b11 b15
3 1 1 2 b4 b8 b12 b16
b1 b5 b9 b31
b2 b6 b10 b14
XOR
b3 b7 b11 b15
b4 b8 b12 b16
Thank You!
Network Security
(Contact Session – 9)
Modes of Operation
Modes of operation
Hash Functions
Hash Functions
• Hash functions are used to detect changes to the message, i.e., data integrity.
1. Append padding bits: The message is padded so that its length is congruent
to 896 modulo 1024 [length ≡ 896 modulo 1024].
2. Append length: A block of 128 bits (containing length of the original message)
is appended to the message.
• The outcome of the first two steps yield a message that is an integer multiple
of 1024 bits in length.
3. Initialize hash buffer (H): A 512-bit buffer, organized as eight 64-bit registers
(a, b, c, d, e, f, g, h), is used to hold intermediate and final results.
• These registers are initialized with the following 64-bit integers (hexadecimal
values):
Additive
Derived from the Constant 𝐾𝑡 .
current 1024-bit block Derived from
being processed. first 80 prime
numbers.
2. SHA-3 must preserve the nature of SHA-2. That is, the algorithm must process comparatively small
blocks (512 or 1024 bits) at a time instead of requiring that the entire message be buffered in
memory before processing it.
• MAC assures data integrity and that the identity of the sender is valid.
• This technique assumes that two communicating parties, say A and B, share a
secret key. When A has a message to send to B, it calculates the MAC as a
function of the message and the key.
• Uses the key to encrypt the message digest, which ultimately produces the
output as MAC.
• Step 3: Append M to S1
• Step 4: Message digest algorithm Step 5: XOR key with opad to produce S2
• Complete Picture
• Two MACs that are based on the use of a block cipher mode of operation.
Thank You!
Network Security
(Contact Session – 10)
• Two MACs that are based on the use of a block cipher mode of operation.
• Refinement adopted by NIST for use with AES and triple DES. It is specified
in NIST Special Publication 800-38B.
• Two cases:
– When the message is a multiple of cipher length block.
– When the message is not a multiple of cipher length block.
To decrypt the message, the receiver uses its own private key.
Receiver’s Receiver’s
public key private key
Example:
1. Let 𝑎 = 6, and 𝑝 = 11, → 610 𝑚𝑜𝑑 11 = 1
2. Let 𝑎 = 6, and 𝑝 = 11, → 611 𝑚𝑜𝑑 11 = 6
BITS Pilani, Pilani Campus
Euler’s Theorem
• Euler’s Totient
• Gives the number of positive integers less than 𝑛 and relatively prime to 𝑛.
It implies that ∅ 𝑝 = 𝑝 − 1.
∅ 𝑛 = ∅ 𝑝𝑞 = ∅ 𝑝 × ∅ 𝑞 = (𝑝 − 1) × (𝑞 − 1)
• Euler’s theorem sates that for every 𝑎 and 𝑛 that are relatively prime:
𝒂∅(𝒏) ≡ 𝟏 (𝒎𝒐𝒅 𝒏)
Let 𝑝 = 3 and 𝑝 = 5, 𝑛 = 𝑝𝑞 = 15
∅ 𝑛 = 𝑝−1 𝑞−1 =2×4=8
For 𝑎 = 14, 148 ≡ 1 (𝑚𝑜𝑑 𝑛)
• Decryption:
• Given the ciphertext 𝐶 = 11
• Decrypt 𝐶 as: 𝑚 = 1123 𝑚𝑜𝑑 187 = 88
r1 = 100 mod 19 = 5
r2 = 100 mod 29 = 13
r3 = 100 mod 31 = 7
Broadcast attack
• This attack can be done if one entity sends the same message to a group of
recipients with the same low encryption exponent.
𝐶1 = 𝑃3 𝑚𝑜𝑑 𝑛1
𝐶2 = 𝑃3 𝑚𝑜𝑑 𝑛2
𝐶3 = 𝑃3 𝑚𝑜𝑑 𝑛3
➢ Here, nine values of 𝑚 maps to the same value of 𝑐 - these are known as
unconcealed messages.
• For this reason, short messages must be padded with random bits at
the front and end to thwart this type of attack.
• Appending the plaintext with some padding bits for improved security.
Thank You!
Network Security
(Contact Session – 11)
Discrete Logarithm
For any integer 𝑏 and a primitive root 𝑎 of prime number 𝑝, we can find a unique
exponent 𝑖 such that
𝑏 ≡ 𝑎𝑖 𝑚𝑜𝑑 𝑝
The exponent 𝑖 is referred to as the discrete logarithm of 𝑏 for the base 𝑎, 𝑚𝑜𝑑 𝑝.
1. Both agree on two publicly known numbers: a prime number 𝑝 and an integer 𝛼
that is a primitive root of 𝑝.
2. User A selects a random integer 𝑋𝐴 < 𝑝 and computes 𝑌𝐴 = 𝛼 𝑋𝐴 𝑚𝑜𝑑 𝑝.
3. Similarly, user B selects a random integer 𝑋𝐵 < 𝑝 and computes 𝑌𝐵 = 𝛼 𝑋𝐵 𝑚𝑜𝑑 𝑝.
4. Each side keeps the value 𝑋 private and makes the value 𝑌 available publicly to
the other side.
5. User A computes the key as 𝐾 = (𝑌𝐵 ) 𝑋𝐴 𝑚𝑜𝑑 𝑝
6. User B computes the key as 𝐾 = (𝑌𝐴 ) 𝑋𝐵 𝑚𝑜𝑑 𝑝
7. These calculation at steps 5 and 6 produces identical results, i.e., 𝐾.
BITS Pilani, Pilani Campus
Diffie - Hellman Key Exchange
- Example
1. Let us say 𝑝 = 23 and one of its primitive roots e = 7.
2. User A selects XA = 3 and calculates YA = eXA mod p = 73 mod 23 = 21.
3. User B selects XB = 6 and calculates YB = eXB mod p = 76 mod 23 = 4.
4. User A sends the number 21 to B.
5. User B sends the number 4 to A.
6. A calculates the shared secret as K = YBXA mod p = 43 mod 23 = 18.
7. B calculates the shared secret as K = YAXB mod p = 216 mod 23 = 18
8. Both and A and B calculates the same shared key (K) as 18.
Because 𝑋𝐴 and 𝑋𝐵 are private, an adversary only has the following ingredients to
work with: 𝑝, 𝛼, 𝑌𝐴, and 𝑌𝐵 .
Thus, the adversary is forced to take a discrete logarithm to determine the key.
Key Distribution
Key Distribution
Frequent key changes are usually desirable to limit the amount of data
compromised if an attacker learns the key.
2. A third party can select the key and physically deliver it to A and B.
3. If A and B have previously and recently used a key, one party can transmit
the new key to the other, encrypted using the old key.
Session key
• Used for a certain duration and then discarded.
• Each session key is obtained from the KDC over the same networking facilities
used for end-user communication.
A and B can now securely communicate using conventional encryption and the
session key 𝐾𝑠 .
But the protocol is insecure against an adversary who can intercept messages
and then either relay the intercepted message or substitute another message
(Man-in-the-middle attack).
BITS Pilani, Pilani Campus
Symmetric Key Distribution
using Asymmetric Encryption
Secret Key Distribution with Confidentiality and Authentication
It is assumed that A and B have already exchanged their public keys.
General schemes -
1. Public announcement
2. Publicly available directory
3. Public-key authority
4. Public-key certificates
Any participant can send his/her Public Key (PU) to any other participant or
broadcast the key to the community at large.
PUAlice
PUAlice
Drawback: Anyone can forge such a public announcement. E.g. some user could
pretend to be user A and broadcast such a public key. Until the time user A
discovers the forgery and alerts other participants, the forger is able to read all
encrypted messages intended for A.
BITS Pilani, Pilani Campus
Distribution of Public Keys
(Asymmetric Keys)
Publicly Available Directory
1. A trusted organization or authority maintains a directory with a {Name, Public Key} entry for
each participant.
2. Each participant registers a public key with the directory authority (either in person or by some
form of secure authenticated communication).
3. A participant may replace the existing key with a new one at any time.
4. Participants could also access the directory electronically. For this purpose, secure,
authenticated communication from the authority to the participant is mandatory.
Thank You!
Network Security
(Contact Session – 12)
1. Any participant can read a certificate to determine the name and public key
of the certificate owner.
2. Any participant can verify that the certificate originated from the certificate
authority and is not counterfeit.
3. Only the certificate authority can create and update certificates.
4. Any participant can verify the currency (freshness) of the certificate.
• B also receives its certificate from CA in the same CB = E (PRCA, [TB || IDB || PUB])
manner.
• A and B now exchange their certificates directly without CA
CA.
• B decrypts the certificate of A using the public key of CB
CA and retrieves TA, IDA and PUA. In the same manner,
A also decrypts the certificate of B.
• If time stamp (T) is old the certificate must be
considered expired.
BITS Pilani, Pilani Campus
X.509 Certificate
• X.509 defines the certificate structure to be used for public key distribution.
• Each certificate contains the public key of a user and is signed with the private
key of a trusted certification authority.
User’s ID
User’s PU
CA Information
Signed Certificate
CA’s PR CA’s PU
Hash Code
Version
• Version: default is 1, if issuer and subject ids are
Certificate Serial Number
present then it is 2. With certain extensions it is 3.
Algorithm
Parameters
• Certificate Serial Number: A unique number
Issuer Name associated with the certificate.
Not Before
• Algorithms and Parameters: Algorithm used to
Not After sign the certificate. Redundant because last field
Subject Name also has it.
Algorithm
• Issuer Name: X.500 format name of the CA.
Public Key and Parameters
Issuer’s Unique Id • Duration of Validity: In terms of not before and
Subject’s Unique Id not after.
Extensions
Algorithm CA Sign • Subject Name: Name of the user who holds the
Encrypted Hash + Parameters All versions certificate.
BITS Pilani, Pilani Campus
X.509 Certificate Structure
ITU-T X.509
• If all users subscribe to the same CA, then there is a common trust of that CA.
• But, if there is a large community of users, it may not be practical for all users to
subscribe to the same CA.
• Because it is the CA that signs certificates, each participating user must have a
copy of the CA’s own public key to verify signatures.
• With many users, it may be more practical for there to be a number of CAs, each
of which securely provides its public key to some fraction of users.
• Suppose that A has obtained a certificate from certification authority X1 and B has
obtained a certificate from CA X2.
X2<<X1>> X1<<X2>>
X1 X2 X1 X2
A B A B
2. A then goes back to the directory and obtains the certificate of B signed by X2.
– Because A now has a trusted copy of X2’s public key, A can obtain B’s public
key.
Notions:
A to obtain B’s public key: X1 <<X2>> X2 <<B>>
B to obtain A’s public key: X2 <<X1>> X1 <<A>>
BITS Pilani, Pilani Campus
Obtaining a user’s certificate
Multiple users
• An arbitrarily long path of CAs can be followed to produce a chain. A chain with
N elements would be expressed as:
X1 <<X2>> X2 <<X3>> X3 <<X4>> …Xn<<B>>
• In this case, each pair of CAs in the chain must have created certificates for
each other.
• All these certificates of CAs by CAs need to appear in the directory, and the
user needs to know how they are linked to follow a path to another user’s public
key certificate.
Digital Signature
Digital Signature Standard
• 𝑟 = 𝑔𝑘 𝑚𝑜𝑑 𝑝 𝑚𝑜𝑑 𝑞
• 𝑠 = 𝑘 −1 (𝐻 𝑚 + 𝑥𝑟 ) 𝑚𝑜𝑑 𝑞
• The values r and s are signatures of the sender that are transmitted to the
receiver.
User Authentication
User/Entity Authentication
• The party that tries to prove the identity of the claimant is called the
verifier.
• Three categories –
• Something Known: A secret known only by the claimant that can be checked
by the verifier. E.g. password, PIN, secret key, etc.
• Something Possessed: Something possessed that can prove claimant’s
identity. E.g. passport, driver’s license, ID card, credit card, etc.
• Something Inherent: An inherent characteristic of the claimant. E.g.
conventional signatures, voice, facial characteristics, retinal pattern,
fingerprints, etc.
• Each user has its identification that is public and a password that is
private.
• Two categories –
• Fixed password Four approaches
• One-time password
Three approaches
• The system keeps a table that is sorted by user identification. When a password is
received, it is matched in the table.
Second Approach
• To store the hash of the password in the password file.
• Any user can read the contents of the file, but, it is impossible to guess the value
of the password due to hash.
• Possible attack – Dictionary attack.
BITS Pilani, Pilani Campus
Fixed Password
Third Approach
• Third approach is about salting the password.
• A random string, called as salt, is concatenated to the password.
• The salted password is then hashed.
Fourth Approach
• Two identification techniques are combined.
First Approach
• The user and the system agree upon a list of passwords.
• Each password on the list can be used only once.
• Drawbacks -
• Need to keep a long list of passwords.
• If synchronization is missed, complexity would be more.
• The user and the system agree to sequentially update the password.
• P1 can be used to generate P2, further P2 can be used to generate P3, and so on.
• The user and the system create a sequentially updated password using a hash
function.
• The user and the system agree upon an original password, 𝑃0 , and a counter, n.
• The system calculates ℎ𝑛 (𝑃0 ), where ℎ𝑛 means applying a hash function n
times.
Thank You!
Network Security
(Contact Session – 13)
✓ Tickets contain time stamps (TS1 and TS2) with lifetimes. So that
they cannot be replayed after their lifetime expired.
• The client (C) requests a ticket from AS providing its IDC, TGS Kerberos
id (IDTGS) and Timestamp (TS1). Client(C A TGS Server
) S (V)
• The AS responds with a message, encrypted with a key
derived from the user’s password (KC), that contains the
ticket. IDC || IDTGS || TS1
• TGS decrypts the ticket with the key (KTGS) and decrypts the
authenticator to verify the client (ID and address). E(KC,TGS [KC, V || IDV || TS4 || TicketV])
• After verifying the value of the returned time stamp, client can obtain
the service from the server.
End of this client-server authentication
dialogue, the client and the server have
TicketV = E (KV ,[KC, V ||IDC || ADC || IDV || TS4 || Lifetime4]) authenticated each other and can
exchange service messages.
AuthenticatorC = E (KC, V [IDC || ADC || TS5])
E-Mail Security
E-Mail Security
With the explosively growing reliance on email, there grows a demand for
email authentication and confidentiality services.
PGP provides a confidentiality and authentication service that can be used for
email and file storage applications.
Key Rings
• Suppose a user, Alice, may need to send messages to many people.
• Alice needs a ring of public keys, with each person’s public key.
• The PGP designers specified a ring of private/public keys.
• Each user needs to have two sets of rings: a ring of private/public keys and a
ring of public keys of other people.
Two scenarios:
1. Alice needs to send a message to another person in the community:
a) She uses her private key to sign the digest.
b) She uses receiver’s public key to encrypt a newly created session key.
c) She encrypts the message and signed digest with the session key created.
• R64:
• Most e-mail systems allow the
message to consist of only
ASCII characters.
PGP Message
Generation (from
User A to User B)
PGP Message
Reception (from
User A to User B)
S/MIME
S/MIME
• In the RFC 5322 context, messages are viewed as having an envelope and
contents.
• The envelope contains whatever information is needed to accomplish
transmission and delivery.
• The contents compose the object to be delivered to the recipient.
• A message consists of some number of header lines (the header) followed by
unrestricted text (the body).
• The header is separated from the body by a blank line.
Envelope
E-Mail Message
Contents
(RFC-5322)
▪ Any MIME compliant system must support the first 3 headers. Other headers
are optional.
Types
– Enveloped Data
– Signed Data
– Clear-Signed Data
– Signed and Enveloped data - combination of above three
Thank You!
Network Security
(Contact Session – 14)
S/MIME
S/MIME
– Enveloped Data
– Signed Data
– Clear-Signed Data
– Signed and Enveloped data - combination of above three
1. Sender selects the digest algorithm and computes the message digest.
2. The digest is encrypted using sender’s private key.
3. A block called SignerInfo is prepared that contains sender’s public key
certificate, message digest algorithm, encryption algorithm used and
encrypted message digest.
4. The SignerInfo block followed by content is called the Signed Data.
5. It is encoded into base-64 encoding.
• Clear signing uses the multipart content type in MIME to transmit body and
signature separately.
• The body needs to be encoded in some way so that it is not altered during
transit.
• Thus, only S/MIME enabled mail readers can use the signature.
1. Fragmentation
2. Compression
3. Message Integrity
4. Confidentiality
5. Framing
– To create these secrets, one pre-master secret must be established between the
two parties.
Client Server
CertificateRequest
• If server needs the client to Certificate Types
authenticate itself, it sends the Certificate Authorities
• It carries messages from other three protocols as well as the data coming from
the application layer.
Fragmentation
Compression
MAC Addition
Encryption
• It is a contract between two parties that creates a secure channel between them.
• If the connection is needed for two-way secure exchange, then two security
associations are required.
• The SAs can be more involved if the two parties need message integrity and
authentication.
• If Alice wants to send messages to many people and Bob needs to receive
messages from many people, SA can be very complex.
• Also, each side needs to have both inbound and outbound SAs to allow
bidirectional communication.
• Security policy defines the type of security applied to a packet when it is to be sent or
when it has arrived.
• Each host that is using the IPSec protocol needs to keep a Security Policy Database
(SPD).
• Each entry in the SPD can be accessed using a combination of multiple indexes
including source address, destination address, name, protocol, source port, and
destination port.
SA: Source Address
Index Policy DA: Destination Address
P: Protocol
<SA, DA, Name, P, SPort, DPort>
SPort: Source port
<SA, DA, Name, P, SPort, DPort> DPort: Destination port
BITS Pilani, Pilani Campus
Security Policy Database (SPD)
Outbound SPD
Malicious Software
Malicious Software
• A secret entry point into a program that allows someone to gain access without
going through the usual security procedure.
• The logic bomb is code embedded in some legitimate program that is set to
explode when certain conditions met.
• Examples of conditions that can be used as triggers for a logic bomb are:
• Once triggered, a bomb may alter or delete data or entire files, cause a
machine halt, or do some other damage.
• The modification includes injecting the original program with a routine to make
copies of the virus program, which can then go on to infect other programs.
• Spread scenario
1. Like the biological virus, a computer virus carries in its instructional code the
recipe for making perfect copies of itself.
3. Whenever the infected computer comes into contact with an uninfected piece of
software, a fresh copy of the virus passes into the new program.
Thank You!
Network Security
(Contact Session – 15)
Malicious Software
Malicious Software
Computer Virus
• The modification includes injecting the original program with a routine to make
copies of the virus program, which can then go on to infect other programs.
• Spread scenario
1. Like the biological virus, a computer virus carries in its instructional code the
recipe for making perfect copies of itself.
3. Whenever the infected computer comes into contact with an uninfected piece of
software, a fresh copy of the virus passes into the new program.
• Polymorphic virus
• Creates copies during replication that are functionally equivalent
but have distinctly different bit patterns.
• The virus code is variably encrypted. A decryptor is placed at the
beginning of the virus.
Polymorphic Virus
Polymorphic Virus
• Code alternations
https://people.ece.ubc.ca/irenek/techpaps/virus/virusf.html#:~:text=The%20generic%20decryption%20engine%20is,code%2C%20and%20decrypts%20t
he%20virus.
Polymorphic Virus
• Code alternations
Polymorphic Virus
• Generic coding
• This technique exploits the fact that “scan string” (or virus signature)
represents actual code and can NEVER contain code that occur in a
"normal" program.
Polymorphic Virus
• Polymorphic generators
• The virus requests the generator to create an encrypted copy of the virus
code and the generator itself, plus a decryptor.
• Polymorphic generators infect a file by replacing the first byte of the file
with a jump command to the end of the file.
• A worm is a program that can replicate itself and send copies from computer to
computer across network connections.
“The primary difference between a virus and a worm is that viruses must be
triggered by the activation of their host; whereas worms are stand-alone malicious
programs that can self-replicate and propagate independently”
https://www.kaspersky.com/resource-center/threats/computer-viruses-vs-worms
4. Rate limiting: This class limits the rate of traffic from an infected host.
5. Rate halting: This approach immediately blocks outgoing traffic when a threshold is
exceeded.
• In this case, the copy is aborted because Smith does not have write
permission to <Library>.
Confidentiality
Integrity
Availability
Security Attack: Any action that compromises the security of information owned
by an organization.
• Substitution Cipher
• Caesar Cipher
• Monoalphabetic Cipher
• Playfair Cipher
• Polyalphabetic Ciphers - Vigenère Cipher
• Vernam Cipher
• One-Time Pad
• Transposition Cipher – Rail Fence Technique
24
In abstract algebra with sets, we can combine two elements of the set,
perhaps in several ways, to obtain a third element of the set.
gcd(36, 10) 6
gcd(10, 6) 4
gcd(6, 4) 2
gcd(4, 2) 0
gcd(2, 0) = 2
29
Key Expansion
Round 2 Round 2 key (16 bytes)
4 transformations
IDC || IDTGS
E (KC, TicketTGS)
With the explosively growing reliance on email, there grows a demand for
email authentication and confidentiality services.
Thank You!