Bca505 Notes
Bca505 Notes
Bca505 Notes
Integrity: Ensures that only authorized parties are able to modify computer system assets
andtransmitted information. Modification includes writing, changing status,
deleting, creatingand delaying or replaying of transmitted messages.
Non repudiation: Requires that neither the sender nor the receiver of a message be able to
denythe transmission.
Access control: Requires that access to information resources may be controlled by or the
targetsystem.
Availability: Requires that computer system assets be available to authorized parties when
needed.
SECURITY ATTACKS
There are four general categories of attack which are listed below.
Interruption
An asset of the system is destroyed or becomes unavailable or unusable. This is an attack
onavailability e.g., destruction of piece of hardware, cutting of a communication line or
Disabling of file management system.
Interception
An unauthorized party gains access to an asset. This is an attack on confidentiality.
Unauthorized party could be a person, a program or acomputer.e.g, wire tapping to capture data in
the network, illicit copying of files.
Modification
An unauthorized party not only gains access to but tampers with an asset. This is an attack
onintegrity. e.g., changing values in data file, altering a program, modifying the contents
ofmessages being transmitted in a network.
Fabrication
An unauthorized party inserts counterfeit objects into the system. This is an attack on authenticity.
e.g., insertion of spurious message in a network or addition of records to a file.
Cryptographic Attacks
Passive Attacks
Passive attacks are in the nature of eavesdropping on, or monitoring of, transmissions. The goalof
the opponent is to obtain information that is being transmitted. Passiveattacks are of two types:
Traffic analysis: If we had encryption protection in place, an opponent might still be able
toobserve the pattern of the message. The opponent could determine the location and identity
ofcommunication hosts and could observe the frequency and length of messages beingexchanged.
This information might be useful in guessing the nature of communication that wastaking place.
Passive attacks are very difficult to detect because they do not involve any alteration of
data.However, it is feasible to prevent the success of these attacks.
Active attacks
These attacks involve some modification of the data stream or the creation of a false stream.
Theseattacks can be classified in to four categories:
Replay– involves passive capture of a data unit and its subsequent transmission to produce
anunauthorized effect.
Modification of messages– Some portion of message is altered or the messages are delayed
orrecorded, to produce an unauthorized effect.
Denial of service– Prevents or inhibits the normal use or management of communication
facilities. Another form of service denial is the disruption of an entire network, either by
disablingthe network or overloading it with messages so as to degrade performance.
It is quite difficult to prevent active attacks absolutely, because to do so would require
physicalprotection of all communication facilities and paths at all times. Instead, the goal is to
detect themand to recover from any disruption or delays caused by them.
Basic Concepts
PlaintextIn computing, plaintext is a readable textual material without much processing. It is an original
message not formatted text that a sender wishes to communicate with the receiver. The authentic message
that has to be sent to the receiver’s end in cryptography is given a unique name called plaintext.
Cipher textIn cryptography, cipher text is a text that comes as a result of encryption performed on
plaintext using an algorithm called cipher. This message is a meaningless text and cannot be understood
by anyone. Cipher text is also known as encrypted or encoded text as it is a non-readable form of the
original text. It cannot be read by human and computer without decryption of cipher text. In
cryptography the plaintext is converted to a non-readable text before sending the actual text .
CipherAn algorithm for transforming an intelligible message into one that is unintelligible
bytransposition and/or substitution methods.
KeyA key is a value that is used to encrypt or decrypt a message. It is a numeric or alpha numeric text or
may be special symbols also. In cryptography the selection of key is important as security depends on it. It
can use symmetric or asymmetric algorithms. Some critical information used by the cipher, known
only to the sender& receiver.
CodeAn algorithm for transforming an intelligible message into an unintelligible one using acode-
book.
Cryptography
Cryptographic systems are generally classified along 3 independent dimensions:
Type of operations used for transforming plain text to cipher text
All the encryption algorithms are based on two general principles: substitution, in which
eachelement in the plaintext is mapped into another element, and transposition, in which
elements in the plaintext are rearranged.
Substitution
a b c d e f g h I j k …x,y,z
def gh abc
K=3
H e l l o h a I ok=1-26 k=5 H e l l o k=9 H e l l o
Khoor kdl r mj qqt q n u u
Transposition
Hello 12345 good morning sir
leoHl 42153
lHoel
A stream cipher processes the input elements continuously, producing output element one at
atime, as it goes along.
He ll os ir ho wa re yo uz
Khoor
Cryptanalysis
The process of attempting to discover X or K or both is known as cryptanalysis. Thestrategy used
by the cryptanalysis depends on the nature of the encryption scheme and theinformation available
to the cryptanalyst.
1.Cipher text only– A copy of cipher text alone is known to the cryptanalyst.
2.Known plaintext – The cryptanalyst has a copy of the cipher text and the corresponding
plaintext.
3.Chosen plaintext– The cryptanalysts gains temporary access to the encryption machine.
Theycannot open it to find the key, however; they can encrypt a large number of suitably
chosenplaintexts and try to use the resulting cipher texts to deduce the key.
4.Chosen cipher text– The cryptanalyst obtains temporary access to the decryption
machine, uses it to decrypt several string of symbols, and tries to
use the results to deduce thekey.
3. To create the cipher text from the plain text, Alice uses an encryption algorithm and a key
(say k1). To obtain the plain text from cipher text, Bob uses the decryption algorithm and
the same key(say k1). From this it is concluded that, symmetric key encryption uses a single
key called secret key for both encryption and decryption.
Encryption: C=EK(P)
Decryption: P=DK(C)
Where,
C---Cipher text
P---Plain text
E---Encryption
D---Decryption
K---secret key
4. Blowfish, AES, RC4, DES, RC5, and RC6 are examples of symmetric encryption. The most
widely used symmetric algorithm is AES-128, AES-192, and AES-256.
5. The main disadvantage of the symmetric key encryption is that all parties involved have to
exchange the key used to encrypt the data before they can decrypt it.
2. A message that is encrypted using a public key can only be decrypted using a private
key, while also, a message encrypted using a private key can be decrypted using a public
key. Security of the public key is not required because it is publicly available and can be
passed over the internet. Asymmetric key has a far better power in ensuring the security
of information transmitted during communication.
4. To use asymmetric encryption, there must be a way of discovering public keys. One
typical technique is using digital certificates in a client-server model of communication.
A certificate is a package of information that identifies a user and a server. It contains
information such as an organization’s name, the organization that issued the certificate,
the users’ email address and country, and users public key.
5. When a server and a client require a secure encrypted communication, they send
a query over the network to the other party, which sends back a copy of the
certificate. The other party’s public key can be extracted from the certificate.
Monoalphabetic Cipher
1. Monoalphabetic cipher is a substitution cipher in which for a given key, the cipher alphabet for
each plain alphabet is fixed throughout the encryption process. For example, if ‘A’ is
encrypted as ‘D’, for any number of occurrence in that plaintext, ‘A’ will always get encrypted
to ‘D’.
2. In monoalphabetic cipher relationship among the plain text and cipher text letter is one-to-one.
Example:
Plain text: HELLO
Cipher Text: PJAAR
3. To break a monoalphabetic substitution using a known plaintext attack, we can take advantage
of the fact that any pair of letters in the original plaintext message is replaced by a pair of
letters with the same pattern. In other words, if two letters of paintext are distinct, then their
corresponding letters of cyphertext must also be distinct. To illustrate this, if we know that the
word "AMMUNITION" appears in the plaintext, then we can look for strings of 10 consecutive
letters of cyphertext that have the following pattern:
a) The 2nd and 3rd letters are the same
b) The 5th and 10th letters are the same (and different from the 2nd letter)
c) The 6th and 8th letters are the same (and different from the 2nd and 5th letters)
d) All other letters are distinct.
Once we have found all possible matches, we can use a chi-squared statistic to determine
which one is the most likely match for the known plaintext.
4. Caesar cipher only has 25 possibilities of a key. A direct brute-force attack testing each key is
simplest and fastest for attacking the ciphertext. For example, suppose we intercepted a
ciphertext below and we suspected it had been encrypted with Caesar Cipher.
KIMAIZKQXPMZQA MIAG
It is already apparent that 1 is not the key and we may continue with 2 and so on. With key
= 8, we finally get intelligible result.
CAESARCIPHERISEASY
The methodology behind frequency analysis relies on the fact that in any language, each letter has
its own personality. The most obvious trait that letters have is the frequency with which they
appear in a language. Clearly in English the letter "Z" appears far less frequently than, say, "A".
In times gone by, if you wanted to find out the frequencies of letters within a language, you had to
find a large piece of text and count each frequency. Now, however, we have computers that can do
the hard work for us. But in fact, we don't even need to do this step, as for most languages there are
databases of the letter frequencies, which have been calculated by looking at millions of texts, and
are thus very highly accurate.
From these databases we find that "E" is the most common letter in English, appearing about 12%
of the time (that is just over one in ten letters is an "E"). The next most common letter is "T" at 9%.
Example::https://crypto.interactive-maths.com/frequency-analysis-breaking-the-code.html
Substitution Cipher
Caesar Cipher
Example:
Find the cipher text using Caesar cipher if plain text is :: Meet me after the yoga and k=5
Solution:
Meet me after the yoga
Numerical weight of characters in the above plain text are as follows;
M E E T M E A F T E R Y O G A
1 4 4 19 12 4 0 5 19 4 1 24 14 6 0
2 7
2. Polyalphabetic Cipher is a substitution cipher in which the cipher alphabet for the plain
alphabet may be different at different places during the encryption process. This means the
letter ‘E’ in plaintext may be encrypted to ‘J’ or ‘X’. This is a useful encryption technique
against frequency analysis as the letters frequencies are more
obscured.
3. In polyalphabetic cipher a key is required which actually a keyword (an English word) to
encrypt a plain text, to obtain cipher text. Playfair and Vigenere Cipher are polyalphabetic
ciphers.
Example:
Plain text: HELLO
Cipher Text: RNGPQ
Viginere Cipher
1. The Vigenère cipher is a method of encrypting alphabetic text by using a series of different
Caesar ciphers based on the letters of a keyword. It is a simple form of polyalphabetic
substitution. The method was originally described by Giovan Battista Bellaso in his 1553 book
La cifra del. Sig. Giovan Battista Bellaso; however, the scheme was later misattributed to
Blaise de Vigenère in the 19th century, and is now widely known as the "Vigenère cipher".
2. To encrypt, a table of alphabets can be used, termed a tabula recta, Vigenère square, or
Vigenère table. It consists of the alphabet written out 26 times in different rows, each alphabet
shifted cyclically to the left compared to the previous alphabet, corresponding to the 26
possible Caesar ciphers. At different points in the encryption process, the cipher uses a
different alphabet from one of the rows. The alphabet used at each point depends on a
repeating keyword
3. For example, suppose that the plaintext to be encrypted is: ATTACKATDAWN The person
sending the message chooses a keyword and repeats it until it matches the length of the
plaintext, for example, the keyword "LEMON": LEMONLEMONLE
the first letter of the plaintext, A, is paired with L, the first letter of the key. So use row L and
column A of the Vigenère square, namely L. Similarly, for the second letter of the plaintext,
the second letter of the key is used; the letter at row E and column T is X. The rest of the
plaintext is enciphered in a similar fashion:
Plaintext A T T A C K A T D A W N
Key L E M O N L E M O N L E
Ciphertext L X F O P V E F R N H R
4. Decryption is equally simple. The key letter again identifies the row by searching the
occurrence of that cipher text character in the Vigenere table and its corresponding plain text
letter is used.
Attack on Vigenere cipher
The first operation is to guess the length of the key used to encrypt. This can be done by
performing Kasiski test. This method is developed by Friedrich Kasiski.Kasiski’s insight was
the following;
1. There are common bigrams and trigrams in the plaintext.
2. From time to time, two occurrences of a bigram/trigram will be separated by an exact
multiple of the keylength.
3. This means that the two occurrences will be encrypted in the same way.
This suggests;
1. Find the common bigrams and trigrams in the ciphertext.
2. Find the distance between them.
3. This distance may be a multiple of the keylength.
Example: Assignment#2
Playfair Cipher
1. The Playfair cipher was the first practical digraph substitution cipher. The scheme was
invented in 1854 by Charles Wheatstone but was named after Lord Playfair who promoted
the use of the cipher.Playfair cipher is a polyalphabetic cipher and , was used by the British
during World War I [794]. The playfair cipher is based on the use of 5x5 matrix of character
letter constructed using the keyword.
2. The matrix is constructed first by filling the letters of the keyword,dropping out the
duplicate from left to right and top to bottom and then filling the matrix with the left-order
alphabets in alphabetic order
Example:
Suppose we have a plain text as meet me at the school house and a key as MONARCHY
then the encryption process will perform in the following manner;
2. Now, divide the plain text characters into blocks each block have 2 characters as;
Meetme at theschoolhouse
In the abobe blocks there is a block having same characters i.e, oo so we have to fill a filler
in between them, after inserting the filler the blocks will look like as;
Me et me at th es ch oX ol ho us e
Now in the last block we have only one character so to complete the block we have to add
one more filler (say Y) , now the blocks will become;
Me et me at th es ch oX ol ho us eY
3. ENCRYPTION: Now encrypt the plain text using the above matrix
(a) Encryption of first block Me. ‘M’ and ‘e’ are in the same column so take letter below thom
to replace i.e, MeCL
(b) Encryption of second block et. ‘e’ and ‘t’ nor on same column or same row, hence
form rectangle as shown, and replace letter by pickingup opposite corner letter on same
rowetKL
(c) Encryption of third block me. ‘M’ and ‘e’ are in the same column so take letter below thom
to replace i.e, meCL
(d) Encryption of fourth block at. ‘a’ and ‘t’ nor on same column or same row, hence
form rectangle as shown, and replace letter by pickingup opposite corner letter on same
rowatRS
(e) Encryption of fifth block th. ‘t’ and ‘h’ nor on same column or same row, hence
form rectangle as shown, and replace letter by pickingup opposite corner letter on same
rowthPD
(f) Encryption of sixth block es. ‘e’ and ‘s’ nor on same column or same row, hence
form rectangle as shown, and replace letter by pickingup opposite corner letter on same
rowesIL/JL
(g) Encryption of seventh block ch. ‘c’ and ‘h’ are in same row, hence take letter to the right of
them to replace. chHY
(h) Encryption of eighth block oX. ‘o’ and ‘X’ nor on same column or same row, hence
form rectangle as shown, and replace letter by pickingup opposite corner letter on same
rowoXAV
(i) Encryption of ninth block ol. ‘o’ and ‘l’ nor on same column or same row, hence
form rectangle as shown, and replace letter by pickingup opposite corner letter on same
rowolMP
(j) Encryption of tenth block ho. ‘h’ and ‘o’ are in the same column but from bottom to top so
take letter above them to replace i.e, hoFH
Transposition Techniques
2. A symbol in the first position in the plain text may appear on the 6th position of the cipher
text. A symbol on the 8th position in the plain text may appear on the 2nd position in the
cipher, from above it is clear that transposition cipher reorder the symbols of the plain text.
To encode this message we will first write over two lines (the “rails of the fence”) as
follows:
2. The ciphertext is then read off by writing the top row first, followed by the bottom row:
3. While writing the plain text in zigzag format, we have to start writing the plain text from the
top left and ends at bottom right. If the no of characters are less then we have to insert filler
(X, Y or Z) at the bottom right.
4. This algorithm can be keyed also. Firstly, you need to have a key, which for this cipher is
the number of rows you are going to have. You then start writing the letters of the plaintext
diagonally down to the right until you reach the number of rows specified by the key. You
then bounce back up diagonally until you hit the first row again. This continues until the end
of the plaintext.
Example:
For the plaintext we used above, "defend the east wall", with a key of 3, we get the
encryption process shown below;
Note that at the end of the message we have inserted two "X"s. These are called fillers, and
act as placeholders. We do this to make the message fit neatly in to the grid (so that there are
the same number of letters on the top row, as on the bottom row. Although not necessary, it
makes the decryption process a lot easier if the message has this layout.
The ciphertext is read off row by row to get "DNETLEEDHESWLXFTAAX".
Decryption
The decryption process for the Rail Fence Cipher involves reconstructing the diagonal grid
used to encrypt the message. We start writing the message, but leaving a dash in place of the
spaces yet to be occupied. Gradually, you can replace all the dashes with the corresponding
letters, and read off the plaintext from the table.
We start by making a grid with as many rows as the key is, and as many columns as the
length of the ciphertext. We then place the first letter in the top Left Square, and dashes
diagonally downwards where the letters will be. When we get back to the top row, we place
the next letter in the ciphertext. Continue like this across the row, and start the next row
when you reach the end.
For example, if you receive the ciphertext "TEKOOHRACIRMNREATANFTETYTGHH",
encrypted with a key of 4, you start by placing the "T" in the first square. You then dash the
diagonal down spaces until you get back to the top row, and place the "E" here. Continuing
to fill the top row you get the pattern below.
The first row of the decryption process for the Rail Fence Cipher. We have a table with 4
rows because the key is 4, and 28 columns as the ciphertext has length 28.
Continuing this row-by-row, we get the successive stages shown below.
CipherText: TTNAAPTMTSUOAODWCOIXKNLYPETZ
Decryption
1. Now to decrypt first count the length of the key and cipher text. Now divide the no of
char by length of key to find the block size.
Here,
Length of the key=7
Length of chars in cipher text= 28
Block size= 28/ 7= 4
Now customize the cipher text in blocks each block have 4 characters.
TTNAAPTMTSUOAODWCOIXKNLYPETZ
Now, create a table having 7 columns and 4 rows and fill the block in column wise in
increasing order of the key digits as,
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
To obtain the plain text read the characters row by row.
We can only talk about one-time pad if some important rules are followed. If these rules are
applied correctly, the one-time pad can be proven unbreakable.However, if only one of these rules
is disregarded, the cipher is no longer unbreakable.
The key is at least as long as the message or data that must be encrypted.
The key is truly random (not generated by a simple computer function or such)
Key and plaintext are calculated modulo 10 (digits), modulo 26 (letters) or modulo 2
(binary)
Each key is used only once, and both sender and receiver must destroy their key after use.
There should only be two copies of the key: one for the sender and one for the receiver
(some exceptions exist for multiple receivers)
Example: suppose Alice wants to send the message “ATTACK POSTPONED” to Bob by using a
key “KCATTA DENOPTSOP”
Encryption:
1. First write the plain text and the numerical weights of each alphabet as;
A T T A C K P O S T P O N E D
1 1 19 0 2 10 1 14 18 1 15 1 13 4 3
9 5 9 4
2. Now write the key and the numerical weights of each alphabet as;
K C A T T A D E N O P T S O P
10 2 0 19 1 0 3 4 13 1 15 1 18 1 15
9 4 9 4
3. Now merge these two tables and add the numerical weights of plain text char and key char.
Plain text A T T A C K P O S T P O N E D
char
weight 1 1 19 0 2 10 1 14 18 1 15 14 1 4 3
9 5 9 3
Key char K C A T T A D E N O P T S O P
weight 10 2 0 19 1 0 3 4 13 1 15 19 1 14 15
9 4 8
SUM 11 2 19 19 2 10 1 18 31 3 30 33 3 18 18
1 1 8 3 1
SUM mod 26 11 2 19 19 2 10 1 18 5 7 4 7 5 18 18
1 1 8
Cipher Text L V T T V K S S F H E H F S S
Decryption:
1. First write the Cipher text and the numerical weights of each alphabet as;
Cipher Text L V T T V K S S F H E H F S S
Weight 11 21 19 19 21 10 18 18 5 7 4 7 5 18 18
Key char K C A T T A D E N O P T S O P
weight 10 2 0 19 19 0 3 4 13 14 15 19 18 14 15
Difference 1 19 19 0 2 10 15 14 -8 -7 -11 -12 -13 4 3
Add 26 to negative 1 19 19 0 2 10 15 14 18 19 15 14 13 4 3
value
Plain text char A T T A C K P O S T P O N E D
1. Both Block Cipher and Stream Cipher are belongs to the symmetric key cipher. These two
block cipher and stream cipher are the methods used for converting the plain text into cipher
text.The basic difference between block and stream cipher are as follows;
1. In cryptography, confusion and diffusion are two properties of the operation of a secure
cipher identified by Claude Shannon in his 1945 classified report A Mathematical
Theory of Cryptography. These concepts are also important in the design of robust hash
functions and pseudorandom number generators where association of the generated
values is of paramount importance.
2. Confusion means that each binary digit (bit) of the ciphertext should depend on several
parts of the key, obscuring the connections between the two. The property of confusion
hides the relationship between the ciphertext and the key. This property makes it difficult
to find the key from the ciphertext and if a single bit in a key is changed, the calculation
of the values of most or all of the bits in the ciphertext will be affected. Confusion
increases the ambiguity of ciphertext and it is used by both block and stream ciphers.
3. Diffusion means that if we change a single bit of the plaintext, then (statistically) half of
the bits in the ciphertext should change, and similarly, if we change one bit of the
ciphertext, then approximately one half of the plaintext bits should change. The idea of
diffusion is to hide the relationship between the ciphertext and the plain text. This will
make it hard for an attacker who tries to find out the plain text and it increases the
redundancy of plain text by spreading it across the rows and columns; it is achieved
through transposition of algorithm and it is used by block ciphers only.
Hill Cipher
1. The Hill Cipher was invented by Lester S. Hill in 1929, and like the other Digraphic
Ciphers(Digraph Substitution Ciphers are similar to Monoalphabetic Substitution Ciphers,
except that instead of replacing individual letters in the plaintext, they replace pairs of letters
with another pair of letters (or digraph).) it acts on groups of letters. Unlike the others
though it is extendable to work on different sized blocks of letters. So, technically it is a
polygraphic substitution cipher, as it can work on digraphs, trigraphs (3 letter blocks) or
theoretically any sized blocks.
Example:
In order to encrypt a message using the Hill cipher, the sender and receiver must first agree
upon a key matrix A of size n x n. A must be invertible mod 26. The plaintext will then be
enciphered in blocks of size n. In the following example A is a 2 x 2 matrix and the message
will be enciphered in blocks of 2 characters.
Encryption:
He rb er ty ar dl ………………er
Write the numerical weights
74 17 1 …………………….
E = NWP * M
NWP = E/M = E M-1
a b
K= K-1 = d/ad-bc -b/ad-bc = 1/ ad-bc d -b = 12 -7
c d -c/ad-bc a/ad-bc -c a -5 3
adj of K = ad - bc
=36 -35 =1
Q A1 A2 A3 B1 B2 B3
- 1 0 26 0 1 3
8 0 1 3 1 -8 2
1 1 -8 2 -1 9 1
One good example of a fixed table is the S-box from DES (S5), mapping 6-bit input into a 4-bit output:
Given a 6-bit input, the 4-bit output is found by selecting the row using the outer two bits (the first
and last bits), and the column using the inner four bits. For example, an input "011011" has outer
bits "01" and inner bits "1101"; the corresponding output would be "1001"
1. The traditional symmetric key ciphers are character-oriented ciphers. With the advent of
computer, we need bit-oriented ciphers because the information to be encrypted is not just
text; it can be numbers, graphics, audio or video data. It is convenient to convert these types
of data into a stream of bits, to encrypt the stream, and then to send the encrypted stream.
2. A symmetric key modern block cipher encrypts an N-bits block of plain text & decrypts N-
bits block of cipher text. The encryption or decryption algorithm uses a K-bit key. The
decryption algorithm must be inverse of the encryption algorithm and both operation must
use the same secret key.
3. If message has fewer than N-bits, padding must be added to make it an N-bit block. If the
message has more than N-bits, it should be divided into N-bits blocks and the appropriate
padding must be added to the last block if necessary. The common values of N are
64,128,256 or 512 bits.
1. P- Boxes
2. S-Boxes
3. Circular Shift
P-Box
Straight P-Box
A straight P-Box takes small n-bit inputs, permutates them and provide n-bit output.
n=2
12--- 11, 22 or 12,21
00 = 00 ,00
01 = 01, 10
10 = 10, 01
11 = 11, 11
Compression P–Box
Expansion P–Box
S-Box
It stands for substitution box.
Circular shift
B7 B6 B5 B4 B3 B2 B1 B0
Left shift 3
B4 B3 B2 B1 B0 B7 B6 B5
Right shift 4
B3 B2 B1 B0 B7 B6 B5 B4
Swap
B7 B6 B5 B4 B3 B2 B1 B0
To perform swapping dive the block into two equal halves LHS and RHS
And interchange them
B7 B6 B5 B4 B3 B2 B1 B0
B3 B2 B1 B0 B7 B6 B5 B4
B3 B2 B1 B0
Encryption:
Example: Find two sub keys from 1010000010 if P10 = (3, 5, 2,7,4,10,1,9,8,6) and
P8 = (6,3,7,4,8,5,10,9)
Given:
1. IP(8)={2,6,3,1,2,8,5,7)
2. E/P= (4,1,2,3,2,3,4,1)
3. S0= 0 1 2 3 S1= 0 1 2 3
0 1 0 3 2 0 0 1 2 3
1 3 2 1 0 1 2 0 1 3
2 0 2 1 3 2 3 0 1 0
3 3 1 3 2 3 2 1 0 3
Solution:
Step2: Let divide the resultant permutated bits into two equal halves each of 4-bits
LHS=1011
RHS=1101
Now pass the RHS into E/P
E/P(1101)= 11101011
Step3: Now perform XOR operation between 11101011 and first sub key (k1=10100100)
11101011
10100100
--------------------
01001111
Ste4. Now divide the resultant bits into two equal halves each of 4-bits
LHS=0100
RHS=1111
Now pass the LHS to S0 S-Box and RHS to S1 S-Box
LHS=0100
Take 1st and 4th bit as a row for S-box(S0)
Take 2nd and 3rd bit as col for S-box(S0)
Row=00 now convert it into decimal i.e, 0 now, row=0
Col=10 now convert it into decimal i.e, 2 and col=2
The intersecting value in So S-box at 0th row and 2nd col is 3 i.e 11
Similarly,
RHS=1111
Take 1st and 4th bit as a row for S-box(S0)
Take 2nd and 3rd bit as col for S-box(S0)
Row=11 now convert it into decimal i.e, 3 now, row=3
Col=11 now convert it into decimal i.e, 3 and col=3
The intersecting value in S1 S-box at 3rd row and 3rd col is 3 i.e 11
Step5: Now concatenate the resultant bits as 1111 and pass it to Straight P-Box P4 as,
P(1111)= 1111
Step6: Now perform XOR operation between the left half of IP and 1111 as,
1011
1111
--------
0100
Step7. Now perform the swapping between 0100 and RHS of IP i.e 1101
LHS= 1101
RHS= 0100
Product Cipher
Claude Shannon introduced the concept of product cipher. A product cipher is a complex
cipher, combining of substitution, permutation and other components.
Fiestel Cipher
Base cipher for DES is Fiestel Cipher.
First approach of FiestelCipher
Double DES
1. Double DES comes under multiple encryption. This is the simplest form of multiple
encryption and has two encryption stages with 2 different keys.
2. Given plain text P and 2 encryption keys K1 and K2. Cipher text C will be generated as;
C=E (K2, E(P,K1))
Triple DES
1. To improve the security of DES, Triple DES (3-DES) was proposed. This uses 3 stages
of DES for encryption and decryption.
2. Two versions of Triple DES are used ;
(a) Triple DES with 2 keys
(b) Triple DES with 3 different keys
1. In triple DES with 2 keys there are only 2 keys k1 & k2. The first and third stage used k1
key; the second stage uses k2 key.
2. To make Triple DES compatible with single DES, the middle stage uses decryption at the
encryption site and encryption at the decryption site.
1. Symmetric key encipherment can be done by using modern block cipher. The two
modern block cipher namely DES and AES are designed to encipher and decipher.
2. DES encrypts and decrypts a block of 64bits, AES encrypts and decrypts block of 128
bits.
3. In real life applications the text to be enciphered is of variable length and normally much
larger than 64 and 128 bits.
4. Modes of operations have been devised to encipher text of any size employing either
DES or AES. the following pictorial representation shows 5possible modes of
operations.
3. The following pictorial representation shows the encryption and decryption is this mode;
Example: consider a plain text M=101100010100101an key K=2341
Now concatenate all the cipher blocks to obtain the final cipher text as;
C=0111001010000101
CBC (Cipher Block Chaining)
1. CBC uses a fixed initialization vector (IV) which can be made public.
2. As in ECB mode, the plain text is decomposed into blocks of length n. If the sender
encrypts the sequence, m1,m2,m3……..mt of plain text block of length N using the key
e then we have,
C0=IV
Cj = Ee(Cj-1XORmj)
3. Finally we get the cipher text as C =C1, C2, C3,…………Ct.
4. To decrypt the cipher text, the receiver uses the decryption algorithm , key, which
satisfies the following;
mj = Cj-1XORDd (Cj)
FOR m1 BLOCK
Step-1: Apply the formula Cj = Ee(Cj-1XORmj)
For 1st block i.e i=1
FOR m2 BLOCK
Step-1: Apply the formula Cj = Ee(Cj-1XORmj)
For 2nd block i.e i=2
Step-6: The final cipher text is obtained by concatenating the sequence C1,C2,C3,…..Cn
Example:Consider a plain Text as 101100010100101 and key=2341 and IV=1010 and r=3.
1. Euclidian algorithm was developed by a Mathematician Euclidto find the greatest common
divisor of two positive integers. GCD (a,b) of a and b is the largest number that divides
evenly both a and b.
Example: GCD (60,24)=12
2. If there is no common factor except 1, then numbers i.e, a and b are relatively prime.
Example: GCD (8,15)=1
Step-3: R= A mod B
Step-4: A=B
Ste-5: B=R
Therefore GCD(1970,1066)=2
GCD(4655,12075)=?
RSA algorithm
1. The most common public key algorithm is the RSA cryptosystem, named for its inventors
(Rivest, Shamir and Adleman).
2. The RSA scheme is a block cipher and make use of the expression with exponential.
3. RSA uses two exponents, “e” and “d”, where “e” is public while “d” is private.The sender
knows the value of “e” and only the receiver knows the value of “d”.
C = Me mod N
M = Cd mod N
5. Both sender as well as receivermust know the value of N.
Algorithm (RSA)
N= p*q = 3*11 = 33
Example2: If p=17 and q=11 and M=10. Perform encryption and decryption using RSA.
To calculate “e” divide ɸ(N) by 1,2,3,4,….and take a small prime no. as “e”.
ɸ(N) / 1= 160/1=Divisible
ɸ(N) / 2= 160/2=Divisible
ɸ(N) / 3= 160/3= Not Divisible
so the value of e is 3
So d=107
Example3: In a public key system using RSA, we intercept a cipher text C=10 and send to
user
using public key as “e=5” and N=35. Find the plain text.
Example4: In RSA crypto system it is given N=187,e=17. Obtain the value of “d” here, N,e,d
have their usual meanings. Show all the steps.
Key Management
2. Key management concerns keys at the user level either between users or systems. This is in
contrast to key scheduling; key scheduling typically refers to the internal handling of key
with in the operation of cipher.
The following are the several challenges that an IT organization face when trying to control
and managed their encryption keys.
2. To reduce the number of keys each user establishes a shared secret key with KDC as
shown in the following figure;
1. When the number of users using a KDC increases, the system becomes
unmanageable. To solve this problem, we need to have multiple KDC’s.
2. We divide the world into domains. Each domain can have one or more KDC’s.
1. The concept of flat multiple KDC’s can be extended to a hierarchical KDC’s with
one or more KDC’s at the top of the hierarchy.
3. Suppose, ALICE wants to communicate with BOB who lives in another country. He
sends his request to a local KDC;the local KDC relays the request to the national
KDC; the national KDC forwards the received request to an international KDC. The
request is then relayed to all the way down to a local KDC where BOB belongs.
Creation of Key By KDC
1. The following pictorial representation shows the creation of session key to be used
between ALICE and BOB.
1. ALICE sends a message to KDC to obtain a symmetric session key for the communication
with BOB. The message contains his registered identity and name of the receiver (BOB).
2. The KDC receives the message and creates a “ticket”. The ticket contains session key along
with another ticket having copy of session key and identity of ALICE and BOB which is
encrypted with the BOB’s key(KB), the entire ticket is encrypted with the ALICE’s key
(KA).
3. ALICE receives the ticket, decrypts it and extracts the session key along with the ticket for
BOB. ALICE forwards the ticket to BOB, BOB decrypts it by using his key (K B) and
extracts the session key along with the identity of ALICE and himself. On the basis of this
he came to know that ALICE communicates with me by using this session key.
Message Authentication
1. It allows the sender to send a message to a receiver in such a way that if the message is
modified during the transmission or the route, then the receiver will all most certainly detect
this.
2. Message authentication is also called “Data Origin Authentication”. Message authentication
is said to protect the integrity of the message that it is received and deemed acceptable
arriving in the same condition that it was sent out with no bits inserted, missing or modified.
Message Digest
1. A message digest guarantees the integrity of a message. It guarantees that the message has
not being changed.
2. A message digest however does not authenticate the sender of the message.
2. BOB separates the message from the MAC and then passes the received message to the
same hash function along with the sharable secret key to generate a new MAC. Now he
compares the newly created MAC with the received one, if both the MAC’s are same, then
it is confirmed that the message has not been modified during the transmission.
3. In this approach, there is no need to use two different channels. EVE(user) can view the
message, but cannot forged it because eve does not have the secret key.
Authentication Protocol
1. Authentication is a fundamental aspect of system security. It confirms the identity of any
user trying to use the resource.
Hash Function
1. A cryptographic hash function takes a message of arbitrary length and creates a message
digest of fixed length.
2. The purpose of a hash function is to produce a fingerprint (just for authentication of a file or
a message).
3. To be useful for message authentication a hash function (say H) must have the following
properties;
5. The hash value is appended to the message at the time when the message is assumed to be
final. On the other hand, the receiver authenticates that message by recomputing the hash
value.
Hashing:
1. A hash function is an algorithm that maps large data set of variable length, into a smaller
data set of fixed length. The value returned by a hash function is called hash code, hash sum,
checksum or simply hashes.
2. There are several well-known hash functions used in cryptography. These includes the
message digest hash function MD2, MD4, MD5 and SHA.
2. The fixed size input function is referred to as a compression function. It compress anN -bit
string to create M -bit, where N is normally greater than M. The scheme is referred to as an
iterated cryptographic hash function.
2. This construction was used in the designing of many popular hash algorithms such as ,MD5,
SHA1, SHA2 etc.
2. The message is then considered as “t” blocks, each of n-bits we call each block as
M1,M2,M3…….Mt. we call the digest created at each iteration as H1,H2,H3,……Ht.
3. Before starting the iteration, the digest H0 is set to a fixed value, normally called “Initial
vector (IV)”.
3. In 2002, NIST produced a revised version of the standard SHA that defined three new versions
of SHA with hash value length of 256,384 and 512 bits known as SHA-256,SHA-384 and
SHA-512.
4. These new versions have the same underlying structure and use the same type of modular
arithmetic logical binary operations and SHA-1.
SHA-512
1. SHA-512 is the version of SHA with 512 bits as message digest. SHA-512 is based on the
Markley Damgard scheme.
2. SHA-512 is the latest version, it has more complex structure than the previous versions of
SHA and its message digest is the longest.
3. SHA-512 creates a message digest of 512 bits from multiple blocks each of size 1024 bits of
length.
4. The Initial vector(IV) is initialized to a predetermined value of 512 bits. The algorithm
mixes this initial value with the first block of message to create the first intermediate
message digest of 512 bits.
5. The above digest is then mixes with the second block to create the second intermediate
message digest of 512 bits. Finally, (n-1)th intermediate message digest is mixed with the n th
block to create the final message digest.
5 bits
5 101
00000101 step-1 padding(1 to 512)
1000 512 488 +24 padding 512-64=448 padding + 64 bits