Lecture6 Integrity
Lecture6 Integrity
Security
Lecture-6: Confidentiality & Integrity
Today’s Content…
• Confidentiality
• Modern Cryptography
• Block Cipher
• Stream Cipher
• Integrity
• Hash Function
Confidentiality can be achieved using
encryption/decryption
Encryption Decryption
Secure Network
E ^d@#*^
D
&!h^*hi ^d@#*^
&!h^*hi
Message
(I love you) Message
(I love you)
E: Encryption- Charlie cannot see what is being sent over the channel
D: Decryption- Bob can successfully decrypt the message
Modern Cryptography
Symmetric Cipher
• Encryption
𝑌𝑖 = 𝑋𝑖 ⊕ 𝑠𝑖
• Decryption
𝑋𝑖 = 𝑌𝑖 ⊕ 𝑠𝑖
• The keystream is denoted by the symbol “s”
How is the keystream generated ?
• Truly random keystream
• Generated by a true random number generator
• Keystream generated looks totally random
• Occurrence of equal no. of 0’s and 1’s
• Equal no. of 01, 11, 10, 00
• No distinguishable pattern etc.
How is the keystream generated ?
• Truly random keystream
• Generated by a true random number generator
• Keystream generated looks totally random
• Occurrence of equal no. of 0’s and 1’s
• Equal no. of 01, 11, 10, 00
• No distinguishable pattern etc.
• Examples of TRNGs – stem from random physical process
• Coin toss
• Timing of keystroke clicks, mouse movement
• Thermal noise
• Rolling of dice etc.
How is the keystream generated ?
• Truly random keystream
• Generated by a true random number generator
• Keystream generated looks totally random
• Occurrence of equal no. of 0’s and 1’s
• Equal no. of 01, 11, 10, 00
• No distinguishable pattern etc.
• Examples of TRNGs – stem from random physical process
• Coin toss
• Timing of keystroke clicks, mouse movement
• Thermal noise
• Rolling of dice etc.
• But generating random keystream from such sources is very slow !!
Pseudorandom number generator (PRNG)
• PRNG’s uses computational algorithms that can produce long sequences of
apparently random results
• Keystream “looks like” random but is not random
Pseudorandom number generator (PRNG)
• PRNG’s uses computational algorithms that can produce long sequences of
apparently random results
• Keystream “looks like” random but is not random
• E.g., 001100010001011100110001000101110011000100010111 …….
• Looks random but on a closer look, stream 0011000100010111 is repeating
continuously
• The key stream has a period of 16 , i.e., every 17th bit is same
• We are interested in PRNG which has a large period (e.g., period = 280)
Pseudorandom number generator (PRNG)
• PRNG’s uses computational algorithms that can produce long sequences of
apparently random results
• Keystream “looks like” random but is not random
• E.g., 001100010001011100110001000101110011000100010111 …….
• Looks random but on a closer look, stream 0011000100010111 is repeating
continuously
• The key stream has a period of 16 , i.e., every 17th bit is same
• We are interested in PRNG which has a large period (e.g., period = 280)
• PRNGs generate keystreams that are deterministic
• Often, they are computed with a function.
Pseudorandom number generator (PRNG)
𝑠0 = 𝑠𝑒𝑒𝑑
𝑠𝑖+1 = 𝑓(𝑠𝑖 )
Si Yi Si
Xi ⊕ ⊕ Xi
Design Considerations for Stream Ciphers
• A pseudorandom number generator uses a function that produces a
deterministic stream of bits that eventually repeats. The longer the period
of repeat the more difficult it will be to do cryptanalysis.
• The keystream should approximate the properties of a true random
number stream as close as possible. For example, there should be an
approximately equal number of 1s and 0s. If the keystream is treated as a
stream of bytes, then all of the 256 possible byte values should appear
approximately equally often. The more random-appearing the keystream
is, the more randomized the ciphertext is, making cryptanalysis more
difficult.
• The output of the pseudorandom number generator is conditioned on the
value of the input key. To guard against brute-force attacks, the key needs
to be sufficiently long. A key length of at least 128 bits is desirable.
CIA goals
• Confidentiality
• Integrity
• Availability
• Encryption does not protect data from modification by another party
• Need a way to ensure that data arrives at destination in its original
form as sent by the sender
• Ensured by hash functions and message authentication code
• And it is coming from an authenticated source
• Ensured by message authentication code
Hash Function
Properties of cryptographic hash function
Properties of cryptographic hash function
Why Important? Given hash, no one shoulde be able to get the original input x
• Prevents attackers from reversing the hash function.
Example:
Real-World Attack:
• Brute-force attack: Try all possible inputs until a matching hash is found (very slow for
strong hash functions).
Definition: Given an input x1x_1x1 and its hash H(x1)H(x_1)H(x1), it should be computationally
infeasible to find another input x2x_2x2 such that:
Given a hash and it's input, it should be computationally
H(x1)=H(x2)H(x_1) = H(x_2)H(x1)=H(x2)
infeasible to find another input that produces same hash
(i.e., two different inputs should not produce the same hash.)
Why Important?
• Ensures data integrity—if a document’s hash is signed, an attacker should not be able to
replace it with another document having the same hash.
Example:
• An attacker should not be able to create a fraudulent document B with the same H(A).
Real-World Attack:
• If second preimage resistance is weak, an attacker can create different data with the same
hash, allowing fraudulent file replacements.
3. Collision Resistance
Definition: It should be computationally infeasible to find any two different inputs x1x_1x1
and x2x_2x2 such that:
H(x1)=H(x2)H(x_1) = H(x_2)H(x1)=H(x2)
(A collision occurs when two different inputs produce the same hash.)
It shoulbe compuatationally infeasible to find to inputs that produces
Why Important?
same hash
• Prevents fraudulent document substitution (digital signatures, certificates).
Example:
• If a hash function has a collision, an attacker could replace a legitimate transaction with a
fake one having the same hash.
Real-World Attack:
• MD5 and SHA-1 are broken because researchers have found collisions.
Here's why:
f 𝐻1 f 𝐻2 f 𝐻3 f 𝐻4
g h
IV
Iterated Hash Function
𝑥1 𝑥2 𝑥3 𝑥4
𝐻2 𝐻3 𝐻4 g h
f 𝐻1 f f f
IV