Module 1
Tasneem Mirza
Cryptography, which translates as "secret
writing," refers to the science of concealing the
meaning of data so only specified parties
understand a transmission's contents.
Network security consists of the policies and
practices adopted to prevent and monitor
unauthorized access, misuse, modification, or
denial of a computer network.
3 valuable components of a computer based
system :
Hardware
Software
Data
The ways in which there could be loss /harm to
Information :
1. Data could be disclosed to unauthorized parties.
2. Data could be modified in illegitimate ways.
3. Legitimate users may not have access to the
data.
Goals of security :
1. Data should not be disclosed to
unauthorized parties.
Confidentiality
2. Data should not be modified in
illegitimate ways.
Integrity
3. Data should be accessible to
authorized parties at appropriate times.
Availability
1. Confidentiality
Only authorized people can access protected
data.
Issues relating confidentiality :
1. Who determines which people are authorized to
access the current system?
2. What is the meaning of accessing the data? The
authorized party can access whole
database/part of the database?
3. Can someone who is authorized, disclose those
data to other parties?
2. Integrity :
Assets can be modified only by authorized
parties.
Modifications includes changing, deleting and
creating.
3. Availability :
If a person has legitimate access to a particular
set of objects, that access should not be
prevented.
A vulnerability is a weakness in the system that
might be exploited to cause loss/harm.
A threat is a set of circumstances that has the
potential to cause loss/harm.
Eg : An administrator account “admin” with the
password “admin” is a vulnerability.
An outsider hence gaining access to sensitive
information is a threat.
Vulnerability is a flaw in the system that can
cause a threat.
Act that exploits vulnerability.
Difference between threat and attack
Threat can be either intentional /unintentional
whereas attack is intentional.
Threat is a circumstance that has potential to
cause loss or damage whereas attack is
attempted to cause damage.
Threat to the information system doesn’t mean
information was altered or damaged but attack
on the information system means there might be
chance to alter, damage, or obtain information
when attack was successful.
Types of threats :
Consider a sender S and a recipient R.
If S entrusts the message to T, who then delivers it to R,
then T becomes the Transmission medium.
If an outsider O wants to access the message ( to read,
change or destroy it) then O is an interceptor or intruder.
Any time after S transmits it via T, the message is
vulnerable to exploitation and O might try to access the
message in any of the following ways :
1. Interruption (Block)
Prevents the message from reaching R, thereby
affecting the availability of message.
2. Interception.
Read or listen to the message thereby affecting
the confidentiality of the message
3. Modification
An unauthorized party(O) not only gains access but
tampers with an asset
Seizing the message and changing it in some way.
Changing values in a data file.
Threatens integrity
4. Fabrication
Fabricate an authentic looking message arranging for
it to be delivered as if it came from S, thereby
affecting the integrity and authentication of the
message
S R S R
O
S R S R
O O
◦ Hackers :
A computer enthusiast as an individual who enjoys
exploring the details of computers and how to
stretch their capabilities, as opposed to most users
who prefer to learn only the minimum necessary.
◦ Crackers :
A cracker is one who breaks security on a system.
Crackers are hardcore hackers characterized more
as professional security breakers and thieves.
1. Attacks threatening confidentiality
a) Snooping : refers to unauthorized access or interception of
data or listening to a conversation
For example, if you login to a website that uses no
encryption, your username and password can be sniffed off
the network by someone who can capture the network traffic
between you and the web site.
Encryption is used to make information non-intelligible to
the snooper.
b) Traffic Analysis :
Although the encipherment of data may make it non
intelligible for the interceptor, he/she can obtain some other
type of information by monitoring the line traffic. Eg: the
nature of information (like text or image files) that is
transmitted
2. Attacks Threatening Integrity:
a) Modification :
The integrity of data can be threatened by modification.
In a message modification attack, an intruder alters
packet header addresses to direct a message to a different
destination or modify the data on a target machine.
b)Masquerading:
An attacker can modify the communication data to
pretend (spoof) as a legal sender or receiver to obtain the
information to which it does not have access.
For example an attacker might steal the bank card and
PIN of a bank customer and pretend that he/she is the
customer.
c) Replaying
The attacker obtains a copy of the message sent by a user and later tries to
replay/send it.
For example: A person sends a request to his bank to ask for payment to the
attacker, who had done a job for him. The attacker intercept the message and sends
it again to cause another payment from the Bank.
In a replay attack, it doesn't matter if the attacker who intercepted the original
message can read or decipher the key. All he or she has to do is capture and resend
the entire thing
One method to avoid becoming a victim is to have a password for each transaction
that's only used once and discarded(OTP)
Another preventative measure for this type of attack is using timestamps on all
messages. This prevents hackers from resending messages sent longer ago than a
certain length of time, thus reducing the window of opportunity for an attacker to
eavesdrop.
Another method to avoid becoming a victim is to have a password for each
transaction that's only used once and discarded.
.
d) Repudiation
The sender of the message might later deny that
he/she has sent the message and the receiver of
the message might deny that he has received the
message.
An example of denial by sender would be a bank
customer asking her bank to send some money to
a third party but later denying that he had made
such a request
An eg. of denial by receiver could occur when a person buys
from a manufacturer and pays electronically, but the
manufacturer later denies having received the payment and
asks to be paid.
3. Attacks threatening availability:
Denial of service
It is a very common attack.
It may slow down or totally interrupt the service of a
system.
The attacker can use several strategies to achieve this.
He might send so many bogus requests to a server that
the server crashes because of the heavy load. Hence
service is not available to the client.
Passive attack:
A benign kind of attack, that means, that the
eavesdropper or the attacker does not modify
or delete the information, but just receives
the information and observes the content.
Active attack:
The attacker actually modifies or deletes or
inserts information, therefore , it is a
potentially more harmful kind of attack
Taxonomy of attacks
Six security services
Standards have been defined for security services
to achieve security goals and prevent security
attacks.
1 Data confidentiality :
The protection of data from unauthorized disclosure.
2. Data integrity :
The assurance that data received are exactly as sent
by an authorized entity, i.e. contain
no modification
no insertion
no deletion
3. Authentication :
The authentication service is concerns with
assuring that a communication is authentic.
The recipient of the message should be sure
that the message came from the source that it
claims to be and vice versa.
Eg: consider a person, using online banking
service. Both the user and the bank should be
assured of identities of each other
4. Non repudiation :
Protection against denial by one of the entities involved in a
communication of having participated in the communication.
Nonrepudiation can be related to
Origin: proof that the message was sent by the specified
party
Destination: proof that the message was received by the
specified party
Example
Imagine a user of online banking who has made a
transaction, but later denied that. How the bank can protect
itself in a such situation?
5. Access control :
Provides protection against unauthorized
access to the data.
6. Availability service :
Protects a system to ensure its availability
Particularly, it addresses denial-of-service
attacks.
Designed to detect, prevent or recover from a security
attack
Security mechanisms are used to implement security
services.
Security Mechanisms:
Encipherment
Digital signature
Access Control mechanisms
Data Integrity mechanisms
Authentication Exchange
Traffic Padding
Routing Control
Notarisation
Cryptography : (Greek word)- Secret writing
The science and art of transforming messages to make them
secure and immune to attacks
Components involved in cryptography :
Key Key
plaintext ciphertext plaintext
Encryption Decryption
Plaintext :Original message before being transformed.
Ciphertext : Message after transformation.
Encryption : Process of transforming the plaintext into
ciphertext.
Decryption : Process of transforming the ciphertext back into
plain text.
Cipher – Encryption and Decryption algorithms.
Key – A number or a set of numbers that the cipher
(algorithm) operates on.
For the process of encryption
Input – Encryption algorithm, plaintext, key.
Output –Cipher text
For the process of decryption
Input – Decryption algorithm, ciphertext, key.
Output –Plain text
Notations used to describe the transformations :
C=E(P) C-ciphertext, P-plaintext, E-encryption algorithm
P=D(C) or
P=D(E(P)) D- Decryption algorithm.
Bob, Alice want to communicate “securely”
Trudy (intruder) may intercept, delete, add messages
Alice Bob
data, control
channel
messages
secure secure
secure data
data
sender receiver
receiver
Trudy
Cryptography
Means hidden writing, the practice of using encryption to conceal
text
Cryptanalysis
Study of encryption and encrypted message, with the goal of
finding the hidden meaning of the messages.
Both the cryptographer and the cryptanalyst attempt to translate
the coded material back to it’s original form. But a cryptographer
works on behalf of a legitimate sender or receiver, whereas a
cryptanalyst works on behalf of an unauthorized interceptor.
Cryptographic algorithms
Symmetric key Asymmetric key
(Shared secret key) (Public key)
Symmetric key –
Same key is used for encryption and decryption.
Hence the key is called the shared secret key.
Drawbacks of symmetric key :
◦ Key must remain secret at both ends
◦ In large networks, there are many keys pairs to be
managed
◦ Sound cryptographic practices dictates that the key be
changed frequently
◦ The shared secret key must be transmitted through an
insecure transmission channel.
Asymmetric key encryption
• Uses 2 keys public and private key
• Public Key- known to all
• Private key – known only to the receiver.
Every communicating entity creates 2 keys public and
private.
Every communicating entity distributes it’s public key
to every other entity and keeps it’s private key to
itself.
If Alice wants to send a message to Bob, Alice
encrypts the message with Bob’s public key and when
Bob receives the message, it decrypts it with its own
private key.
Stream ciphers
◦ Encrypts one bit/character at a time
Block ciphers
◦ Break plaintext message in equal-size blocks
◦ Encrypts each block as a unit
Stream cipher
Converts one symbol of plaintext into a symbol of ciphertext.
i.e Encrypts data symbol by symbol
Call the plaintext stream P, the ciphertext stream C, and the key stream K.
Keystream may be a stream of predetermined values or
May be created by an algorithm or can be a single value.
Note : Monoalphabetic cipher
k={k,k,k…….}
Block Cipher:
Encrypts a group of plaintext symbols to produce a group of
ciphertext symbols of the same size.
A single key is used to encrypt the block even if the key is
made
up of multiple values.
1. Substitution Cipher
A substitution cipher replaces one symbol/character with another.
a) Monoalphabetic Cipher
b) Polyalphabetic Cipher
A) Monoalphabetic Cipher : (Stream cipher)
The letter is always replaced by the same alphabet regardless of
its position in the text.
The relationship between a character in the plaintext to a
character in the ciphertext is one –to- one.
If the algorithm says that letter A in the plain text is changed to
letter D, then every letter A is changed to letter D.
Types of monoalphabetic cipher
1. Additive cipher
Also called as shift cipher.
A numerical value is assigned to each letter(upper/lower case)
The secret key is an integer in Z26 ie from {0 to 25}
The encryption algorithm adds the key to the plaintext
character.
The decryption algorithm subtracts the key from the
plaintext character.
C=(P+k) mod 26
P=(C-k) mod 26
P= plaintext character
C= ciphertext character
k=key
Use the additive cipher with key = 15 to encrypt the message
“hello”.
Note that the cipher is monoalphabetic because two instances
of the same plaintext character (l) are encrypted as the same
character (A).
Use the additive cipher with key = 15 to decrypt the
message “WTAAD”.
Solution
We apply the decryption algorithm to the plaintext
character by character. The result is “hello”. Note that
the operation is in modulo 26, which means that we
need to add 26 to a negative result (for example 15
becomes 11).
2. Caeser Cipher
Julius Caeser used an additive cipher to communicate
with
his officers.
Hence called Caeser’s cipher.
He used a key of 3 for his communications.
3. Multiplicative ciphers
In multiplicative ciphers, the encryption algorithm
specifies multiplication of the plaintext by the key and
the decryption algorithm specifies the division of the
ciphertext by the key.
However since opeartions are in Z
26, decryption here
means multiplying the mutiplicative inverse of the key.
C=(P x k) mod 26
P=(C x K-1) mod 26
The modular multiplicative inverse of an
integer a modulo m is an integer x such that
a.x mod m =1
OR
The multiplicative inverse of a in Zm is x.
This no. x is between 0 to m-1.
For eg :
4 is the multiplicative inverse of 3 in Z11-
Since
4.3 mod 11=1
An integer may or may not have a multiplicative inverse.
We say that multiplicative inverse of a in Zm exists if
gcd(a,m)=1.
Find the multiplicative inverse of 8 in Z10.
There is no multiplicative inverse because gcd (10, 8)
= 2 ≠ 1.
In other words, we cannot find any number between 0 and 9
such that when multiplied by 8 mod 10 =1.
Using extended Euclidean algorithm to find multiplicative inverse
i.e find multiplicative inverse of b in zn
Find the multiplicative inverse of 11 in Z26.
The gcd (26, 11) is 1; the inverse of 11 is 7 or 19.
11x19 mod 26 =1
Find the multiplicative inverse of 23 in Z100.
The gcd (100, 23) is 1; the inverse of 23 is 13 or 87.
What is the key domain for any multiplicative cipher?
The key needs to be in Z26. This set has only 12 members: 1,
3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25.
Use multiplicative cipher to encrypt the message “hello”
with a key of 7. The ciphertext is “XCZZU”.
Decryption
Find the multiplicative inverse of 7 in Z26.
Ans-15
To decrypt X---
(23 x 15) mod 26= 7----h
B) Polyalphabetic cipher
Each occurrence of a character can have a different
substitute.
The relationship between a character in the plaintext to
a character in the ciphertext is one –to- many.
Eg : A could be changed to D in the beginning of the text
, to N in the middle and so on.
The key here is a stream of subkeys.
Types of Polyaphabetic cipher
1. Autokey cipher
Key is a stream of subkeys, in wich each subkey is used
to encrypt the corresponding character in the plaintext.
The first subkey is a predetermined value secretly
agreed upon by Alice and Bob.
The second subkey is the value of the first plaintext
character(between 0 and 25).
The third subkey is the value of the second plaintext and
so on.
Assume that Alice and Bob agreed to use an autokey
cipher with initial key value k1 = 12. Now Alice wants to
send Bob the message “Attack is today”. Enciphering is
done character by character.
2. Playfair cipher
Polyalphabetic cipher used by the British
Army during World War I.
The secret key in this cipher is made of 25
letters arranged in a 5x5 matrix(letters I
and J are considered the same when
encrypting).
Different arrangements of the letters in the
matrix can create many different secret
keys.
An example of a secret key in the Playfair
Cipher
Before encryption
1. If the 2 letters in a pair are the same, a bogus letter is
inserted to separate them.
2. After inserting bogus letters, if the number of characters
in the plaintext is odd, one extra bogus characters is
added at the end to make the number of characters
even.
Cipher rules for encryption :
1. If the 2 letters in a pair are located in the same row of
the secret key, the corresponding encrypted character
for each letter is the letter to the right in the same
row(with wrapping to the beginning of the row if the
plaintext letter is the last character in the row)
2. If the 2 letters in a pair are located in the same column
of the secret key, the corresponding encrypted character
for each letter is the letter beneath it in the same
column(with wrapping to the beginning of the column if
the plaintext letter is the last character in the column)
3. If the 2 letters in a pair are not in the same row/ same
column of the secret key, the corresponding encrypted
character for each letter is the letter that is in its own
row but in the same column as the other letter
Encrypt the plaintext “hello” using the above key
The cipher is a polyalphabetic cipher since 2 occurences of the letter
“l “are encrypted as “Q” and “B”
3. Vigenere cipher
The key stream is a repetition of an initial secret key
stream of length m, where 1≤m≤ 26
P=P1 P2 P3……… C=C1 C2 C3…….
K=[(k1,k2,k3…..)(k1,k2,k3…….)]
Encryption Ci=Pi+ki Decryption Pi=Ci-Ki
Difference between Vignere and previous two
polyalphabetic ciphers is that the key stream in Vignere
cipher does not depend on the plaintext characters.
It depends only on the position of the character in the
plaintext
i.e keystream can be created without knowing the
plaintext
Encrypt the message “She is listening” using the
6-character keyword “PASCAL”. The initial key
stream is (15, 0, 18, 2, 0, 11). The key stream is
the repetition of this initial key stream (as many
times as needed).
Additive cipher is a special case of Vignere cipher where m=1
4. One time pad (OTP) cipher(Vernam Cipher)
Devised by Gilbert Vernam for AT&T.
Immune to most cryptanalytic attacks.
Impossible to crack if used correctly. Hence also called perfect
cipher.
Here each character from the plaintext is encrypted by a modular
addition which a number from the secret random key pad which
is of the same length as the plain ext.
Characteristics of OTP :
1. Key is truly random
2. Never reused
3. Kept secret.
Drawbacks :
1. Need of unlimited no. of keys
2. Overhead of distributing (sender and receiver) and storing the keys
One such OTP is the Vernam cipher devised by Gilbert
Vernam for AT&T.
Basic encryption involves an arbitrarily long non repeating
sequence of numbers that are combined with the plain text.
Eg: Message to be encrypted---
VERNAM CIPHER
Step 1: Convert the letters to their numeric equivalents
V E R N A M C I P H E R
21 4 17 13 0 12 2 8 15 7 4 17
Assume the random 2 digit no. series (key)
76 48 16 82 44 03 58 11 60 05 10 88
Step 2: Add the numeric equivalent and the corresponding random no.
Random no + numeric equivalent =sum
Sum 97 52 33 95 44 15 60 19 75 12 14 105
Step 3 : Perform sum mod 26
19 0 7 17 18 15 8 19 23 12 14 1
Ciphertext ----
t a h r s p i t x m o b
Decryption
Step 1
a = (numeric equivalent of ciphertext - key)
Step 2
a mod 26
(if a negative then keep adding 26 till you get a positive no.)
Step 3
Convert numeric equivalent back to alphabet
Eg of decryption
t a h r s p i t x m o b
19 0 7 17 18 15 8 19 23 12 14 1
76 48 16 82 44 03 58 11 60 05 10 88
a= -57 -48 -9 -65 -26 12 -50 8 -37 7 4 -87
a mod 26
21 4 17 13 0 12 2 8 15 7 4 17
V E R N A M C I P H E R
Eg 2 plaintext H E L L O
7 4 11 11 14
key 23 12 2 10 11
(Msg+ key) 30 16 13 21 25
(Msg+ key) mod 26 4 16 13 21 25
E Q N V Z --- CIPHERTEXT
Decryption
4 16 13 21 25
key 23 12 2 10 11
(Ciphertext-key) -19 4 11 11 14
(Ciphertext-key) mod 26 7 4 11 11 14
H E L L O ----- Plaintext
5. Hill cipher
Invented by Lester S. Hill
The plaintext is divided is divided into equal sized
blocks.
Hence Hill cipher is a block cipher.
In Hill cipher, the key is a square matrix of size mxm
where m is the size of the block.
The key matrix in the Hill cipher needs to have a multiplicative inverse.
Assume block size is 3
Hence key matrix is 3 x 3
Let K= 2 3 15
5 8 12
1 13 4
The key matrix should have a multiplicative inverse
How to find?
Find the determinant of the key i.e
2(8x4-13x12)-3(5x4-12x1)+15(5x13-8x1)=583
583 mod 26=11, gcd(11,26)=1
Hence matrix is invertible mod 26
Assume text to be encrypted is CRYPTOGRAPHY.
C R Y P T O G R A P H Y
2 17 24 |15 19 14| 6 17 0 | 15 7 24
P = 2 15 6 15
17 19 17 7
24 14 0 24
Encryption --
(K.P ) mod 26 =
2 3 15 2 15 6 15 25 11 11 21
5 8 12 17 19 17 7 = 18 5 10 3 =C
1 13 4 24 14 40 2 7 6 19 20
C= 25 18 7 11 5 6 11 10 19 21 3 20
Decryption
Decryption Key K-1
To find K-1 (USING THE ADJOINT METHOD)
K= 2 3 15
5 8 12
1 13 4
Step 1 Find cofactor of matrix K
+-+
- + -
+-+
For finding new K11- 8x4 – 12x13 = -124
For finding new K12- -(5x4 – 12x1) = -8
For finding new K13- 13x5 – 8x1 = 57
For finding new K21- -(4x3– 15x13)= 183
Co factor matrix - -124 -8 57
183 -7 -23
-84 51 1
Step 2 Adjoint is obtained by taking the transpose of the
cofactor matrix
-124 183 -84
-8 -7 51
57 -23 1
Step 3 Find the det(k) mod 26 =11
Step 4 Find the multiplicative inverse of 11 in Z 26 = 19
Step 5 Multiply 19 by the adjoint matrix
-124 183 -84
19x -8 -7 51
57 -23 1
= -2356 3477 1596
-152 -133 969
1083 -437 19
Taking mod 26 we get the inverse K-1
K-1 = 10 19 16
4 23 7
17 5 19
To decrypt P=K-1xC
P=
10 19 16 25 11 11 21
4 23 7 18 5 10 3
17 5 19 7 6 19 20
= 704 301 604 587
563 201 407 293 mod 26
648 326 598 752
P= 2 15 6 15
17 19 17 7
24 14 0 24
P=C R Y P T O G R A P H Y
2 17 24 15 19 14 6 17 0 15 7 24
Hill cipher for a 2x2 matrix
Step 1 : Find the determinant of the matix
Step 2 :Check if the multiplicative inverse of the
determinant exists. If exists compute the multiplicative
inverse
Step 3 : Find the Adjugate Matrix
The adjugate matrixis a matrix of the same size as the
original. For a 2 x 2 matrix, it is just moving the
elements to different positions and changing a couple of
signs. That is, we swap the top left and bottom right
numbers in the key matrix, and change the sign of the
the top right and bottom left numbers. Algebraically this
is given below.
Step 4 : Multiply the Multiplicative Inverse of the
determinant by the Adjugate Matrix
Step 5 : Take the anwers in modulo 26 which gives us
the inverse of the matrix.
Message to encrypt = HELLO WORLD
HELLO WORLD has been encrypted
to
SLHZY ATGZT
Message to decrypt = SLHZYATGZT
SLHZYATGZT has been decrypted to
HELLO WORLD
3. Transposition cipher (Block cipher)
Substitution cipher - Plaintext letters were replaced by other
letters
Transposition ciphers use the letters of the plaintext
message, but they permute the order of the letters (reorders
letters)
Key is a mapping between the position of the symbols in the
plaintext and cipher text.
Types
1. Keyed transposition cipher
2. Keyless transposition cipher
1. Keyed transposition cipher
(Assume a block of 4 characters)
Plaintext 2 4 1 3
Ciphertext 1 2 3 4
In encryption we move the character at position 2 to position 1,
character at position 4 to 2 and so on.
Eg: Encrypt : hello my dear
1. Remove spaces
2. Divide the text into blocks of 4 characters.
3. Add bogus character(s) at the end.
hell omyd earz
Ciphertext: elhl mdoy azer
After decryption : hell omyd earz
Difficult
A brute force attack would involve trying possible
arrangements of the letters until the word is
determined.
For a 5 letter word there are 5!=120 ways to
arrange five distinct letters, and exactly one of
them should result in a word.
2. Keyless transposition cipher
Rearrangement of the characters of the plain text into
columns.
Eg: 5 column transposition
Here the plaintext is written in rows of 5 and arranged
one row after another --
c1 c2 c3 c4 c5
c6 c7 c8 c9 c10
c11……
The resulting ciphertext is formed by reading down the
columns.
Eg: plaintext - THIS IS A MESSAGE HI TSEC
T H I S I
S A M E S
S A G E H
I T S E C
CIPHERTEXT--- TSSIH AATIM GSSEE EISHC
For decryption – Arrange the characters in 4 rows and 5
columns.
Note :When the message length not a multiple of 5 then add
infrequent letter x at the end.