Information Security Lab Manual
Information Security Lab Manual
LAB MANUAL
Information
SECURITY
B.Tech Programme
CSE
(ETCS-401)
CONTENTS
1. Introduction
4. Detail of Experiments
6. References
Information Security Laboratory
1. INTRODUCTION
With the introduction of the computer, the need for automated tools for protecting files
and other information stored on the computer became evident. This is especially the case
for a shared system, such as time-sharing system, and the need is even more acute for
systems that can be accessed over a public telephone network, data network or the
Internet. The generic name for the collection of tools designed to protect data and to
thwart hackers is computer security.
The second major change that affected security is the introduction of distributed systems
and the use of networks and communications facilities for carrying data between terminal
user and computer and between computer and computer. Information security measures
are needed to protect data during their transmission. In fact the term network security is
somewhat misleading, because virtually all business, government, and academic
organizations interconnect their data processing equipment with a collection of
interconnected networks. Such a collection is often referred to as an internet and the term
internet security is used.
Security aspects come into play when it is necessary or desirable to protect the
information transmission from an opponent who may present a threat to
confidentiality, authenticity and so on. All the techniques for providing security
have two components:
(a) A security-related transformation on the information to be sent. Examples
include the encryption of the message, which scrambles the message so
that it is unreadable by the opponent, and the addition of a code based on
the contents of the message, which can be used to verify the identify of the
sender.
(b) Some secret information shared by the two principals and it is hoped,
unknown to the opponent. An example is an encryption key used in
conjunction with the transformation to scramble the message before
transmission and unscramble it on reception.
2. Lab Requirements
Hardware requirements:
RAM
1. Regularity: 30
Weekly performance in the lab
Attendance
File
2. Viva Voce: 10
NOTE: For the regularity, marks are awarded to the student out of 10 for
each experiment performed in the lab and at the end the average marks
are giving out of 30.
Information Security Laboratory
Marking Scheme:
Total Marks: 60
4. Detail of Experiments
1. Write a program to make study of different security protocols like WEP/ WPA2
PSK, 802.1x EAP security protocol. And Implement RC4 Algorithm.
2. Write a Program to implement AES.
3. Write a program to perform Encryption / Decryption using Caesar cipher.
Experiment No 1
In 2003 the Wi-Fi Alliance announced that WEP had been superseded by Wi-Fi Protected Access (WPA).
In 2004, with the ratification of the full 802.11i standard (i.e. WPA2), the IEEE declared that both
WEP-40 and WEP-104 have been deprecated
WEP was included as the privacy component of the original IEEE 802.11 standard ratified in 1997.[5]
[6]
WEP uses the stream cipher RC4 for confidentiality,[7] and the CRC-32checksum for integrity.[8] It
was deprecated in 2004 and is documented in the current standard. [9]
A 64-bit WEP key is usually entered as a string of 10 hexadecimal (base 16) characters (0–9 and A–F).
Each character represents 4 bits, 10 digits of 4 bits each gives 40 bits; adding the 24-bit IV produces
the complete 64-bit WEP key (4 bits × 10 + 24 bits IV = 64 bits of WEP key). Most devices also allow
the user to enter the key as 5 ASCII characters (0–9, a–z, A–Z), each of which is turned into 8 bits
Information Security Laboratory
using the character's byte value in ASCII (8 bits × 5 + 24 bits IV = 64 bits of WEP key); however, this
restricts each byte to be a printable ASCII character, which is only a small fraction of possible byte
values, greatly reducing the space of possible keys.
A 128-bit WEP key is usually entered as a string of 26 hexadecimal characters. 26 digits of 4 bits each
gives 104 bits; adding the 24-bit IV produces the complete 128-bit WEP key (4 bits × 26 + 24 bits IV =
128 bits of WEP key). Most devices also allow the user to enter it as 13 ASCII characters (8 bits × 13
+ 24 bits IV = 128 bits of WEP key).
A 152-bit and a 256-bit WEP systems are available from some vendors. As with the other WEP variants,
24 bits of that is for the IV, leaving 128 or 232 bits for actual protection. These 128 or 232 bits are
typically entered as 32 or 58 hexadecimal characters (4 bits × 32 + 24 bits IV = 152 bits of WEP key, 4
bits × 58 + 24 bits IV = 256 bits of WEP key). Most devices also allow the user to enter it as 16 or 29
ASCII characters (8 bits × 16 + 24 bits IV = 152 bits of WEP key, 8 bits × 29 + 24 bits IV = 256 bits of
WEP key).
WPA2
WPA2 is a security scheme that specifies two main aspects of your wireless security:
Regardless of which authentication type you've set up your network to use, WPA2 always uses a scheme
called AES-CCMP to encrypt your data over the air for the sake of confidentiality, and to thwart
various other kinds of attacks.[Ref]
So when the system use AES-CCMP, which user with which username/password has the key of the AES
encryption?
It means after that each user is authenticated, the system encrypts all traffic with temporal 128-bit key and
AES.
Information Security Laboratory
WPA is an 802.11i-based security solution from the Wi-Fi Alliance that addresses the vulnerabilities of
WEP. WPA uses Temporal Key Integrity Protocol (TKIP) for encryption and dynamic encryption key
generation by using either a pre-shared key, or RADIUS/802.1x-based authentication. The mechanisms
introduced into WPA were designed to address the weakness of the WEP solution without requiring
hardware upgrades. WPA2 is the next generation of Wi-Fi security and is also based on the 802.11i
standard. It is the approved Wi-Fi Alliance interoperable implementation of the ratified IEEE 802.11i
standard. WPA 2 offers two classes of certification: Enterprise and Personal. Enterprise requires
support for RADIUS/802.1x-based authentication and pre-shared key (Personal) requires only a
common key shared by the client and the AP.
Regardless of which authentication type you've set up your network to use, WPA2 always uses a scheme
called AES-CCMP to encrypt your data over the air for the sake of confidentiality, and to thwart
various other kinds of attacks.
802.1X is "EAP over LANs" or EAPoL. EAP stands for "Extensible Authentication Protocol", which
means it's kind of a plug-in scheme for various authentication methods. Some examples:
Information Security Laboratory
Do you want to authenticate your users with usernames and passwords? Then "PEAP" is a good
EAP type to use.
Do you want to authenticate your users via certificates? Then "EAP-TLS" is a good EAP type to
use.
Are the devices on your network all GSM smartphones with SIM cards? Then you can use
"EAP-SIM" to do GSM SIM-card style authentication to get on your network. etc. etc.
If you set up your wireless router to use 802.1X, it needs to have a way to authenticate your users via some
EAP type. Some routers may have the ability for you to input a list of usernames and passwords right
on the router, and the router knows how to do the whole authentication all by itself. But most will
probably require you configure RADIUS. RADIUS is a protocol that allows you to keep your
username and password database on a central server, so you don't have to make changes on each
separate wireless router each time you add or delete a user or a user changes his password or
something. Wireless routers that do 802.1X generally don't know how to authenticate users directly,
they just know how to gateway between 802.1X and RADIUS so that the wireless client machines are
actually getting authenticated by a RADIUS server on the network, and it's the RADIUS server that
knows how to deal with various EAP types.
If your wireless router's user interface has "802.1X" on a list of encryption types, then it probably means
"802.1X with dynamic WEP", which is an old scheme where 802.1X is used for authentication, and
per-user per-session WEP keys are dynamically generated as part of the authentication process, and
thus WEP is ultimately the encryption method used.
RC4 Algorithm:
import java.io.*;
class rc4
{
int temp=0;
String ptext;
String key;
Information Security Laboratory
ptexti[i]=(int)ptextc[i];
for(int i=0;i<key.length();i++)
keyi[i]=(int)keyc[i];
for(int i=0;i<255;i++)
s[i]=i; k[i]=keyi[i
%key.length()];
}
int j=0;
Information Security Laboratory
for(int i=0;i<255;i++)
{ j=(j+s[i]+k[i])%256;
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
int i=0;
j=0;
int z=0;
for(int l=0;l<ptext.length();l++)
{ i=(l+1)%256;
j=(j+s[i])%256;
temp=s[i];
s[i]=s[j];
s[j]=temp;
z=s[(s[i]+s[j])%256];
cipher[l]=z^ptexti[l];
decrypt[l]=z^cipher[l];
}
System.out.print(“\n\nENCRYPTED:\t\t”);
display(cipher);
System.out.print(“\n\nDECRYPTED:\t\t”);
display(decrypt);
{
Information Security Laboratory
convert[l]=(char)disp[l];
System.out.print(convert[l]);
}
}}
OUTPUT:
ENTER PLAIN TEXT :RC4 PROGRAM
ENTER KEY TEXT A
ENCRYPTED: ??-??±?µFJ|
DECRYPTED: RC4 PROGRAM
Information Security Laboratory
Experiment No 2
For instance, if there are 16 bytes, , these bytes are represented as this matrix:
The key size used for an AES cipher specifies the number of repetitions of transformation rounds
that convert the input, called the plaintext, into the final output, called the ciphertext. The number
of cycles of repetition are as follows:
Each round consists of several processing steps, each containing four similar but different stages,
including one that depends on the encryption key itself. A set of reverse rounds are applied to
transform ciphertext back into the original plaintext using the same encryption key.
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* MCrypt API available online:
* http://linux.die.net/man/3/mcrypt
*/
#include <mcrypt.h>
#include <math.h>
#include <stdint.h>
Information Security Laboratory
OUTPUT:
Plain Text : AES SymmetricEncryptionDecryption
Cipher Text
:sY6vkQrWRg0fvRzbqSAYxepeBIXg4AySj7Xh3x4vDv8TBTkNiTfca7wW/dxiMMJl
Experiment No 3
Problem Statement
Write a program for Cesar Cipher algorithm to Encrypt and Decrypt the data.
Theory
In cryptography, a Caesar cipher, also known as a Caesar's cipher, the shift cipher,
Caesar's code or Caesar shift, is one of the simplest and most widely known encryption
techniques. It is a type of substitution cipher in which each letter in the plaintext is
replaced by a letter some fixed number of positions down the alphabet. For example, with
a shift of 3, A would be replaced by D, B would become E, and so on. The method is
named after Julius Caesar, who used it to communicate with his generals.
The encryption step performed by a Caesar cipher is often incorporated as part of more
complex schemes, such as the Vigenère cipher, and still has modern application in the
ROT13 system. As with all single alphabet substitution ciphers, the Caesar cipher is
easily broken and in practice offers essentially no communication security.
Example
The transformation can be represented by aligning two alphabets; the cipher alphabet is
the plain alphabet rotated left or right by some number of positions. For instance, here is a
Caesar cipher using a left rotation of three places (the shift parameter, here 3, is used as
the key):
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: DEFGHIJKLMNOPQRSTUVWXYZABC
When encrypting, a person looks up each letter of the message in the "plain" line and
writes down the corresponding letter in the "cipher" line. Deciphering is done in reverse.
Ciphertext: WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ
Plaintext: the quick brown fox jumps over the lazy dog
The encryption can also be represented using modular arithmetic by first transforming the
letters into numbers, according to the scheme, A = 0, B = 1,..., Z = 25. Encryption of a
letter x by a shift n can be described mathematically, Decryption is performed similarly,
(There are different definitions for the modulo operation. In the above, the result is in the
range 0...25. I.e., if x+n or x-n are not in the range 0...25, we have to subtract or add 26.)
Information Security Laboratory
Encryption
#include<stdio.h>
int main()
{
char message[100], ch;
int i, key;
message[i] = ch;
}
else if(ch >= 'A' && ch <= 'Z'){
ch = ch + key;
message[i] = ch;
}
}
return 0;
}
Output
Information Security Laboratory
Decryption
1 #include<stdio.h>
2
3 int main()
4 {
5 char message[100], ch;
6 int i, key;
7
8 printf("Enter a message to decrypt: ");
9 gets(message);
10 printf("Enter key: ");
11 scanf("%d", &key);
12
13 for(i = 0; message[i] != '\0'; ++i){
14 ch = message[i];
15
16 if(ch >= 'a' && ch <= 'z'){
17 ch = ch - key;
18
19 if(ch < 'a'){
20 ch = ch + 'z' - 'a' + 1;
21 }
22
23 message[i] = ch;
24 }
25 else if(ch >= 'A' && ch <= 'Z'){
26 ch = ch - key;
27
28 if(ch < 'A'){
29 ch = ch + 'Z' - 'A' + 1;
30 }
31
32 message[i] = ch;
33 }
34 }
35
36 printf("Decrypted message: %s", message);
37
38 return 0;
39 }
Output
Enter a message to decrypt: ebdh
Enter key: 4
Decrypted message: axzd
Information Security Laboratory
Experiment No 4
Problem Statement
Write a program to perform Encryption / Decryption using Mono alphabetic techniques
Theory
Better than Caesar Cipher. If, instead the “cipher” line can be any permutation of the key
26 alphabetic characters, then there are 26! Or greater than 4 * 10 26 possible keys. This is
10 orders of magnitude greater than the key space for DES and would seem to as a Mono-
alphabetic substitution cipher, because a single cipher alphabet is used per message. There
is however, another line of attack. If one analytically knows the nature of the plain text,
then the analyst can exploit the regularities of the language.
A monoalphabetic substitution is one where a letter of plaintext always produces the same
letter of cipher text.
The operation is very similar to the Caesar Cipher and Atbash, with the exception that the
cipher alphabet does not have the order which it had in the previous examples (which are
just special cases of monoalphabetic substitutions). An example of a monoalphabetic
substitution is shown below.
PLAINTEXT abcdefghijklmnopqrstuvwxyz
CIPHERTEXT QRSKOWEIPLTUYACZMNVDHFGXJB
One may naïvely think that this cipher is secure, after all there are 26! Different cipher
26
alphabets (4 x 10 ) to choose from, however the letter frequencies and underlying
patterns will be unchanged - and as such the cipher can be solved by pen and paper
techniques. The best way to see how the cryptanalysis is performed is by doing some
analysis.
These more advanced techniques include looking systematically at the position of letters
in words in order to identify vowels, pattern words, and looking at the letter frequencies,
though common pairings (TH, HE etc.) may come up.
The most common English letters are ETAIN. It is highly likely that in any ciphertext, we
have some matches - though it is not a certainty. It should also be noted that the most
commontrigraph (three letter sequence) in English is 'THE'.
When cryptanalysing more complex ciphers such as Vigenère one of the first steps could
be to try and reduce the cipher into a series of monoalphabetic ciphers.
Of course the analysis may be done automatically by a computer program which observes
letter positions and frequencies etc.
Example
Information Security Laboratory
a b c d e f g h i j k l m
Z Y X W V U T S R Q P O N
n o p q r s t u v w x y Z
M L K J I H G F E D C B A
Limitations
Monoalphabetic ciphers are easy to break because they reflect the frequency data of the original
alphabet.
A countermeasure is to provide multiple substitutes, known as homophones, for a single letter.
C code:
//MONOALPHABATIC CIPHER
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char
pt[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char
ct[26]={'Z','Y','X','W','V','U','T','S','R','Q','P','O','N','M','L','K','J','I','H','G','F','E','D','C','B','A'};
char p[20]={'\0'},c[20]={'\0'},r[20]={'\0'};
int i,j;
clrscr();
printf("\n enter the plain text:");
gets(p);
//converting plain text into cipher text (encryption)
for(i=0;i<strlen(p);i++)
{
for(j=0;j<26;j++)
{
if(pt[j]==p[i])
{
c[i]=ct[j];
}
}
}
printf("\n cipher text is: %s",c);
{
for(j=0;j<26;j++)
{
if(ct[j]==c[i])
{
r[i]=pt[j];
}
}
}
printf("\n \n plain text is: %s",r);
getch();
}
Output:
Information Security Laboratory
Experiment No 5
Problem Statement
Write a program to perform Encryption / Decryption using Play Fair techniques
Theory
The Playfair cipher uses a 5 by 5 table containing a key word or phrase. Memorization of
the keyword and 4 simple rules was all that was required to create the 5 by 5 table and use
the cipher.
To generate the key table, one would first fill in the spaces in the table with the letters of
the keyword (dropping any duplicate letters), then fill the remaining spaces with the rest
of the letters of the alphabet in order (usually omitting "Q" to reduce the alphabet to fit,
other versions put both "I" and "J" in the same space). The key can be written in the top
rows of the table, from left to right, or in some other pattern, such as a spiral beginning in
the upper-left-hand corner and ending in the center.The keyword together with the
conventions for filling in the 5 by 5 table constitute the cipher key.
To encrypt a message, one would break the message into digraphs (groups of 2 letters)
such that, for example, "HelloWorld" becomes "HE LL OW OR LD", and map them out
on the key table. The two letters of the digraph are considered as the opposite corners of a
rectangle in the key table. Note the relative position of the corners of this rectangle. Then
apply the following 4 rules, in order, to each pair of letters in the plaintext:
1. If both letters are the same (or only one letter is left), add an "X" after the first
letter. Encrypt the new pair and continue. Some variants of Playfair use "Q"
instead of "X", but any uncommon monograph will do.
2. If the letters appear on the same row of your table, replace them with the letters to
their immediate right respectively (wrapping around to the left side of the row if a
letter in the original pair was on the right side of the row).
3. If the letters appear on the same column of your table, replace them with the
letters immediately below respectively (wrapping around to the top side of the
column if a letter in the original pair was on the bottom side of the column).
4. If the letters are not on the same row or column, replace them with the letters on
the same row respectively but at the other pair of corners of the rectangle defined
by the original pair. The order is important – the first letter of the encrypted pair is
the one that lies on the same row as the first letter of the plaintext pair.
To decrypt, use the INVERSE (opposite) of the first 3 rules, and the 4th as-is (dropping
any extra "X"s (or "Q"s) that don't make sense in the final message when finished).
Example
Using "playfair example" as the key, (assuming I and J are interchangeable) the table
becomes:
PLAYF
IREXM
Information Security Laboratory
B C D G
H
Information Security Laboratory
KNOQS
TUVWZ
HI DE TH EG OL DI NT HE TR EX ES TU MP
^
1. The pair HI forms a rectangle, replace it with BM
2. The pair DE is in a column, replace it with OD
3. The pair TH forms a rectangle, replace it with ZB
4. The pair EG forms a rectangle, replace it with XD
5. The pair OL forms a rectangle, replace it with NA
6. The pair DI forms a rectangle, replace it with BE
7. The pair NT forms a rectangle, replace it with KU
8. The pair HE forms a rectangle, replace it with DM
9. The pair TR forms a rectangle, replace it with UI
10. The pair EX (X inserted to split EE) is in a row, replace it with XM
11. The pair ES forms a rectangle, replace it with MO
12. The pair TU is in a row, replace it with UV
13. The pair MP forms a rectangle, replace it with IF
BM OD ZB XD NA BE KU DM UI XM MO UV IF
Thus the message "Hide the gold in the tree stump" becomes
"BMODZBXDNABEKUDMUIXMMOUVIF".
Information Security Laboratory
Experiment No 6
Problem Statement
Write a program to perform Encryption / Decryption using Hill Cipher techniques
Theory
Operation
Each letter is first encoded as a number. Often the simplest scheme is used: A = 0, B =1,
..., Z=25, but this is not an essential feature of the cipher. A block of n letters is then
considered as a vector of n dimensions, and multiplied by an n × n matrix, modulo 26. (If
one uses a larger number than 26 for the modular base, then a different number scheme
can be used to encode the letters, and spaces or punctuation can also be used.) The whole
matrix is considered the cipher key, and should be random provided that the matrix is
invertible in (to ensure decryption is possible). A Hill cipher is another way of
working out the equation of a matrix.
Consider the message 'ACT', and the key below (or GYBNQKURP in letters):
Since 'A' is 0, 'C' is 2 and 'T' is 19, the message is the vector:
which corresponds to a ciphertext of 'POH'. Now, suppose that our message is instead
'CAT', or:
Information Security Laboratory
which corresponds to a ciphertext of 'FIN'. Every letter has changed. The Hill cipher has
achieved Shannon's diffusion, and an n-dimensional Hill cipher can diffuse fully across n
symbols at once.
Decryption
In order to decrypt, we turn the ciphertext back into a vector, then simply multiply by the
inverse matrix of the key matrix (IFKVIVVMI in letters). (There are standard methods to
calculate the inverse matrix; see matrix inversion for details.) We find that in the
inverse matrix of the one in the previous example is:
We have not yet discussed one complication that exists in picking the encrypting matrix.
Not all matrices have an inverse. The matrix will have an inverse if and only if its
determinant is not zero, and does not have any common factors with the modular base.
Thus, if we work modulo 26 as above, the determinant must be nonzero, and must not be
divisible by 2 or 13. If the determinant is 0, or has common factors with the modular base,
then the matrix cannot be used in the Hill cipher, and another matrix must be chosen
(otherwise it will not be possible to decrypt). Fortunately, matrices which satisfy the
conditions to be used in the Hill cipher are fairly common.
So, modulo 26, the determinant is 25. Since this has no common factors with 26, this
matrix can be used for the Hill cipher.The risk of the determinant having common
factors with the modulus can be eliminated by making the modulus prime.
Consequently a useful variant of the Hill cipher adds 3 extra symbols (such as a space, a
period and a question mark) to increase the modulus to 29.
Security
While matrix multiplication alone does not result in a secure cipher it is still a useful step
when combined with other non-linear operations, because matrix multiplication can
provide diffusion. For example, an appropriately chosen matrix can guarantee that small
differences before the matrix multiplication will result in large differences after the matrix
multiplication. Some modern ciphers use indeed a matrix multiplication step to provide
diffusion. For example, the MixColumns step in AES is a matrix multiplication. The
function g in Twofish is a combination of non-linear S-boxes with a carefully chosen
matrix multiplication (MDS). Recently, some publications tried to make the Hill cipher
secure.
Key size
The key size is the binary logarithm of the number of possible keys. There are
2
matrices of dimension n × n. Thus or about 4.7n is an upper bound on the
key size of the Hill cipher using n × n matrices. This is only an upper bound because not
every matrix is invertible and thus usable as a key. The number of invertible matrices can
be computed via the Chinese Remainder Theorem. I.e., a matrix is invertible modulo 26 if
and only if it is invertible both modulo 2 and modulo 13. The number of invertible n × n
matrices modulo 2 is equal to the order of the general linear group GL(n,Z2). It is
Equally, the number of invertible matrices modulo 13 (i.e. the order of GL(n,Z13)) is
The number of invertible matrices modulo 26 is the product of those two numbers. Hence
it is
Additionally it seems to be prudent to avoid too many zeroes in the key matrix, since they
reduce diffusion. The net effect is that the effective keyspace of a basic Hill cipher is
2
about 4.64n − 1.7. For a 5 × 5 Hill cipher, that is about 114 bits. Of course, key search is
not the most efficient known attack.
Information Security Laboratory
Experiment No 7
Transposition Technique
Problem Statement
Write a program to perform Encryption / Decryption using Transposition Technique
techniques .
Theory
The Rail Fence cipher is a form of transposition cipher that gets its name from the way in
which it is encoded. In the rail fence cipher, the plaintext is written downwards on
successive "rails" of an imaginary fence, then moving up when we get to the bottom. The
message is then read off in rows. For example, using three "rails" and a message of 'WE
ARE DISCOVERED. FLEE AT ONCE', the cipherer writes out:
W...E...C...R...L...T...E
.E.R.D.S.O.E.E.F.E.A.O.C.
..A...I...V...D...E...N..
(The cipherer has broken this ciphertext up into blocks of five to help avoid errors.)
Route cipher
In a route cipher, the plaintext is first written out in a grid of given dimensions, then read
off in a pattern given in the key. For example, using the same plaintext that we used for
rail fence:
WRIORFEOE
EESVELANJ
ADCEDETC
X
The key might specify "spiral inwards, clockwise, starting from the top right". That would
give a cipher text of:
EJXCTEDECDAEWRIORFEONALEVSE
Information Security Laboratory
Route ciphers have many more keys than a rail fence. In fact, for messages of reasonable
length, the number of possible keys is potentially too great to be enumerated even by
modern machinery. However, not all keys are equally good. Badly chosen routes will
leave excessive chunks of plaintext, or text simply reversed, and this will give
cryptanalysts a clue as to the routes.
An interesting variation of the route cipher was the Union Route Cipher, used by Union
forces during the American Civil War. This worked much like an ordinary route cipher,
but transposed whole words instead of individual letters. Because this would leave certain
highly sensitive words exposed, such words would first be concealed by code. The cipher
clerk may also add entire null words, which were often chosen to make the ciphertext
humorous. See for an example.
Columnar transposition
In a columnar transposition, the message is written out in rows of a fixed length, and then
read out again column by column, and the columns are chosen in some scrambled order.
Both the width of the rows and the permutation of the columns are usually defined by a
keyword. For example, the word ZEBRAS is of length 6 (so the rows are of length 6), and
the permutation is defined by the alphabetical order of the letters in the keyword. In this
case, the order would be "6 3 2 4 1 5".
In a regular columnar transposition cipher, any spare spaces are filled with nulls; in an
irregular columnar transposition cipher, the spaces are left blank. Finally, the message is
read off in columns, in the order specified by the keyword. For example, suppose we use
the keyword ZEBRAS and the message WE ARE DISCOVERED. FLEE AT ONCE. In a
regular columnar transposition, we write this into the grid as:
632415
WEARED
ISCOVE
REDFLE
EATONC
EQKJEU
Providing five nulls (QKJEU) at the end. The ciphertext is then read off as:
632415
WEARED
ISCOVE
REDFLE
EATONC
E
To decipher it, the recipient has to work out the column lengths by dividing the message
length by the key length. Then he can write the message out in columns again, then re-
order the columns by reforming the key word.
Double transposition
As an example, we can take the result of the irregular columnar transposition in the
previous section, and perform a second encryption with a different keyword, STRIPE,
which gives the permutation "564231":
564231
E V L N A
CDTESE
A R O F O
DEECWI
REE
If multiple messages of exactly the same length are encrypted using the same keys, they
can be anagrammed simultaneously. This can lead to both recovery of the messages, and
to recovery of the keys (so that every other message sent with those keys can be read).
During World War I, the German military used a double columnar transposition cipher,
changing the keys infrequently. The system was regularly solved by the French, naming it
Übchi, who were typically able to quickly find the keys once they'd intercepted a number
of messages of the same length, which generally took only a few days. However, the
French success became widely-known and, after a publication in Le Matin, the Germans
changed to a new system on 18 November 1914.
During World War II, the double transposition cipher was used by Dutch Resistance
groups, the French Maquis and the British Special Operations Executive (SOE), which
was in charge of managing underground activities in Europe. It was also used by agents
of the American Office of Strategic Services and as an emergency cipher for the German
Army and Navy.
Until the invention of the VIC cipher, double transposition was generally regarded as the
most complicated cipher that an agent could operate reliably under difficult field
conditions.
Information Security Laboratory
Experiment No 8
Problem Statement
Write a program to perform Encryption/Decryption using Diffie-Helmen Key exchange.
techniques
Theory
Diffie Hellman was the first public key algorithm ever invented, in 1976. Alice and Bob
want to be able to generate a key to use for subsequent message exchange. The key
generating exchange can take place over an unsecure channel that allows eavesdropping.
The ingredients to the protocol are: p, a large prime and g, a primitive element of Zn. This
i
means that all numbers n=1, ... , p-1 can be represented as n = g . These two numbers do
not need to be kept secret. For example, Alice could send them to Bob in the open. The
protocol runs as follows:
3. Alice computes
x
k=Y mod p
4. Bob computes
y
k=X mod p
Information Security Laboratory
Experiment No 9
RSA Algorithm
Problem Statement
Write a program for simple RSA algorithm to encrypt and decrypt the data.
Theory
Cryptography has a long and colorful history. The message to be encrypted, known as
the plaintext, are transformed by a function that is parameterized by a key. The output of
the encryption process, known as the ciphertext, is then transmitted, often by messenger
or radio. The enemy, or intruder, hears and accurately copies down the complete
ciphertext. However, unlike the intended recipient, he does not know the decryption key
and so cannot decrypt the ciphertext easily. The art of breaking ciphers is called
cryptanalysis the art of devising ciphers (cryptography) and breaking them
(cryptanalysis) is collectively known as cryptology.
There are several ways of classifying cryptographic algorithms. They are generally
categorized based on the number of keys that are employed for encryption and
decryption, and further defined by their application and use. The three types of algorithms
are as follows:
1. Secret Key Cryptography (SKC): Uses a single key for both encryption and
decryption. It is also known as symmetric cryptography.
2. Public Key Cryptography (PKC): Uses one key for encryption and another for
decryption. It is also known as asymmetric cryptography.
3. Hash Functions: Uses a mathematical transformation to irreversibly "encrypt"
information
Public-key cryptography has been said to be the most significant new development in
cryptography. Modern PKC was first described publicly by Stanford University professor
Martin Hellman and graduate student Whitfield Diffie in 1976. Their paper described a
two-key crypto system in which two parties could engage in a secure communication over
a non-secure communications channel without having to share a secret key.Generic PKC
employs two keys that are mathematically related although knowledge of one key does
not allow someone to easily determine the other key. One key is used to encrypt the
plaintext and the other key is used to decrypt the ciphertext. The important point here is
that it does not matter which key is applied first, but that both keys are required for the
process to work. Because pair of keys is required, this approach is also called asymmetric
cryptography.In PKC, one of the keys is designated the public key and may be advertised
as widely as the owner wants. The other key is designated the private key and is never
revealed to another party. It is straight forward to send messages under this scheme.
The RSA algorithm is named after Ron Rivest, Adi Shamir and Len Adleman, who
invented it in 1977. The RSA algorithm can be used for both public key encryption and
digital signatures. Its security is based on the difficulty of factoring large integers.
Algorithm
1. Generate two large random primes, P and Q, of approximately equal size.
2. Compute N = P x Q
3. Compute Z = (P-1) x (Q-1).
4. Choose an integer E, 1 < E < Z, such that GCD (E, Z) = 1
5. Compute the secret exponent D, 1 < D < Z, such that E x D ≡ 1 (mod Z)
Information Security Laboratory
6. The public key is (N, E) and the private key is (N, D).
Note that we don't have to calculate the full value of 13 to the power 7 here. We can
make use of the fact that a = bc mod n = (b mod n).(c mod n) mod n so we can break
down a potentially large number into its components and combine the results of easier,
smaller calculations to calculate the final value.
Information Security Laboratory
Experiment No 10
DES Algorithm
Problem Statement
Write a program for DES algorithm to Encrypt and Decrypt the data.
Theory
The DES (Data Encryption Standard) algorithm is the most widely used encryption
algorithm in the world. For many years, and among many people, "secret code making"
and DES have been synonymous. And despite the recent coup by the Electronic Frontier
Foundation in creating a $220,000 machine to crack DES-encrypted messages, DES will
live on in government and banking for years to come through a life- extending version
called "triple-DES."
How does DES work? This article explains the various steps involved in DES-encryption,
illustrating each step by means of a simple example. Since the creation of DES, many
other algorithms (recipes for changing data) have emerged which are based on design
principles similar to DES. Once you understand the basic transformations that take place
in DES, you will find it easy to follow the steps involved in these more recent algorithms.
But first a bit of history of how DES came about is appropriate, as well as a look toward
the future.
The National Bureau of Standards Coaxes the Genie from the Bottle
On May 15, 1973, during the reign of Richard Nixon, the National Bureau of Standards
(NBS) published a notice in the Federal Register soliciting proposals for cryptographic
algorithms to protect data during transmission and storage. The notice explained why
encryption was an important issue.
Over the last decade, there has been an accelerating increase in the accumulations and
communication of digital data by government, industry and by other organizations in the
private sector. The contents of these communicated and stored data often have very
significant value and/or sensitivity. It is now common to find data transmissions which
constitute funds transfers of several million dollars, purchase or sale of securities,
warrants for arrests or arrest and conviction records being communicated between law
enforcement agencies, airline reservations and ticketing representing investment and
value both to the airline and passengers, and health and patient care records transmitted
among physicians and treatment centers.
The increasing volume, value and confidentiality of these records regularly transmitted
and stored by commercial and government agencies has led to heightened recognition and
concern over their exposures to unauthorized access and use. This misuse can be in the
form of theft or defalcations of data records representing money, malicious modification
of business inventories or the interception and misuse of confidential information about
people. The need for protection is then apparent and urgent.
a useful means of protecting the content of data stored on various media, providing
encryption of adequate strength can be devised and validated and is inherently integrable
into system architecture. The National Bureau of Standards solicits proposed techniques
and algorithms for computer data encryption. The Bureau also solicits recommended
techniques for implementing the cryptographic function: for generating, evaluating, and
protecting cryptographic keys; for maintaining files encoded under expiring keys; for
making partial updates to encrypted files; and mixed clear and encrypted data to permit
labelling, polling, routing, etc. The Bureau in its role for establishing standards and aiding
government and industry in assessing technology, will arrange for the evaluation of
protection methods in order to prepare guidelines.
NBS waited for the responses to come in. It received none until August 6, 1974, three
days before Nixon's resignation, when IBM submitted a candidate that it had developed
internally under the name LUCIFER. After evaluating the algorithm with the help of the
National Security Agency (NSA), the NBS adopted a modification of the LUCIFER
algorithm as the new Data Encryption Standard (DES) on July 15, 1977.
DES was quickly adopted for non-digital media, such as voice-grade public telephone
lines. Within a couple of years, for example, International Flavors and Fragrances was
using DES to protect its valuable formulas transmitted over the phone ("With Data
Encryption, Scents Are Safe at IFF," Computerworld 14, No. 21, 95 (1980).)
Meanwhile, the banking industry, which is the largest user of encryption outside
government, adopted DES as a wholesale banking standard. Standards for the wholesale
banking industry are set by the American National Standards Institute (ANSI). ANSI
X3.92, adopted in 1980, specified the use of the DES algorithm.
DES works on bits, or binary numbers--the 0s and 1s common to digital computers. Each
group of four bits makes up a hexadecimal, or base 16, number. Binary "0001" is equal to
the hexadecimal number "1", binary "1000" is equal to the hexadecimal number "8",
"1001" is equal to the hexadecimal number "9", "1010" is equal to the hexadecimal
number "A", and "1111" is equal to the hexadecimal number "F".
For example, if we take the plaintext message "8787878787878787", and encrypt it with
the DES key "0E329232EA6D0D73", we end up with the ciphertext
"0000000000000000". If the ciphertext is decrypted with the same secret DES key
"0E329232EA6D0D73", the result is the original plaintext "8787878787878787".
This example is neat and orderly because our plaintext was exactly 64 bits long. The same
would be true if the plaintext happened to be a multiple of 64 bits. But most messages
will not fall into this category. They will not be an exact multiple of 64 bits (that is, an
exact multiple of 16 hexadecimal numbers).
For example, take the message "Your lips are smoother than vaseline". This plaintext
Information Security Laboratory
message is 38 bytes (76 hexadecimal digits) long. So this message must be padded with
some extra bytes at the tail end for the encryption. Once the encrypted message has been
decrypted, these extra bytes are thrown away. There are, of course, different padding
schemes--different ways to add extra bytes. Here we will just add 0s at the end, so that the
total message is a multiple of 8 bytes (or 16 hexadecimal digits, or 64 bits).
The plaintext message "Your lips are smoother than vaseline" is, in hexadecimal,
(Note here that the first 72 hexadecimal digits represent the English message, while "0D"
is hexadecimal for Carriage Return, and "0A" is hexadecimal for Line Feed, showing that
the message file has terminated.) We then pad this message with some 0s on the end, to
get a total of 80 hexadecimal digits:
If we then encrypt this plaintext message 64 bits (16 hexadecimal digits) at a time, using
the same DES key "0E329232EA6D0D73" as before, we get the ciphertext:
This is the secret code that can be transmitted or stored. Decrypting the ciphertext restores
the original message "Your lips are smoother than vaseline". (Think how much better off
Bill Clinton would be today, if Monica Lewinsky had used encryption on her Pentagon
computer!)
M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110
1111
L = 0000 0001 0010 0011 0100 0101 0110 0111
R = 1000 1001 1010 1011 1100 1101 1110 1111
The first bit of M is "0". The last bit is "1". We read from left to right.
Information Security Laboratory
DES operates on the 64-bit blocks using key sizes of 56- bits. The keys are actually stored
as being 64 bits long, but every 8th bit in the key is not used (i.e. bits numbered 8, 16, 24,
32, 40, 48, 56, and 64). However, we will nevertheless number the bits from 1 to 64,
going left to right, in the following calculations. But, as you will see, the eight bits just
mentioned get eliminated when we create subkeys.
The 64-bit key is permuted according to the following table, PC-1. Since the first entry in
the table is "57", this means that the 57th bit of the original key K becomes the first bit of
the permuted key K+. The 49th bit of the original key becomes the second bit of the
permuted key. The 4th bit of the original key is the last bit of the permuted key. Note only
56 bits of the original key appear in the permuted key.
PC-1
57 49 41 33 25 17 9
1 58 50 42 34 26 18
10 2 59 51 43 35 27
19 11 3 60 52 44 36
63 55 47 39 31 23 15
7 62 54 46 38 30 22
14 6 61 53 45 37 29
21 13 5 28 20 12 4
Next, split this key into left and right halves, C0 and D0, where each half has 28 bits.
With C0 and D0 defined, we now create sixteen blocks Cn and Dn, 1<=n<=16. Each pair
of blocks Cn and Dn is formed from the previous pair Cn-1 and Dn-1, respectively, for n =
1, 2, ..., 16, using the following schedule of "left shifts" of the previous block. To do a left
Information Security Laboratory
shift, move each bit one place to the left, except for the first bit, which is cycled to the end
of the block.
Iteration Number of
Number Left
Shifts
1 1
2 1
3 2
4 2
5 2
6 2
7 2
8 2
9 1
10 2
11 2
12 2
13 2
14 2
15 2
16 1
This means, for example, C3 and D3 are obtained from C2 and D2, respectively, by two
left shifts, and C16 and D16 are obtained from C15 and D15, respectively, by one left shift.
In all cases, by a single left shift is meant a rotation of the bits one place to the left, so that
after one left shift the bits in the 28 positions are the bits that were previously in positions
2, 3,..., 28, 1.
C0 = 1111000011001100101010101111
D0 = 0101010101100110011110001111
C1 = 1110000110011001010101011111
D1 = 1010101011001100111100011110
C2 = 1100001100110010101010111111
D2 = 0101010110011001111000111101
C3 = 0000110011001010101011111111
D3 = 0101011001100111100011110101
C4 = 0011001100101010101111111100
D4 = 0101100110011110001111010101
C5 = 1100110010101010111111110000
D5 = 0110011001111000111101010101
C6 = 0011001010101011111111000011
D6 = 1001100111100011110101010101
Information Security Laboratory
C7 = 1100101010101111111100001100
D7 = 0110011110001111010101010110
C8 = 0010101010111111110000110011
D8 = 1001111000111101010101011001
C9 = 0101010101111111100001100110
D9 = 0011110001111010101010110011
C10 = 0101010111111110000110011001
D10 = 1111000111101010101011001100
C11 = 0101011111111000011001100101
D11 = 1100011110101010101100110011
C12 = 0101111111100001100110010101
D12 = 0001111010101010110011001111
C13 = 0111111110000110011001010101
D13 = 0111101010101011001100111100
C14 = 1111111000011001100101010101
D14 = 1110101010101100110011110001
C15 = 1111100001100110010101010111
D15 = 1010101010110011001111000111
C16 = 1111000011001100101010101111
D16 = 0101010101100110011110001111
We now form the keys Kn, for 1<=n<=16, by applying the following permutation table to
each of the concatenated pairs CnDn. Each pair has 56 bits, but PC-2 only uses 48 of
these.
PC-2
14 17 11 24 1 5
3 28 15 6 21 10
23 19 12 4 26 8
16 7 27 20 13 2
41 52 31 37 47 55
30 40 51 45 33 48
44 49 39 56 34 53
46 42 50 36 29 32
Therefore, the first bit of Kn is the 14th bit of CnDn, the second bit the 17th, and so on,
ending with the 48th bit of Kn being the 32th bit of CnDn.
Example: For the first key we have C1D1 = 1110000 1100110 0101010 1011111
1010101 0110011 0011110 0011110
Information Security Laboratory
There is an initial permutation IP of the 64 bits of the message data M. This rearranges
the bits according to the following table, where the entries in the table show the new
arrangement of the bits from their initial order. The 58th bit of M becomes the first bit of
IP. The 50th bit of M becomes the second bit of IP. The 7th bit of M is the last bit of IP.
IP
58 50 42 34 26 18 10 2
60 52 44 36 28 20 12 4
62 54 46 38 30 22 14 6
64 56 48 40 32 24 16 8
57 49 41 33 25 17 9 1
59 51 43 35 27 19 11 3
61 53 45 37 29 21 13 5
63 55 47 39 31 23 15 7
Example: Applying the initial permutation to the block of text M, given previously, we
get
M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110
1111
IP = 1100 1100 0000 0000 1100 1100 1111 1111 1111 0000 1010 1010 1111 0000 1010
1010
Information Security Laboratory
Here the 58th bit of M is "1", which becomes the first bit of IP. The 50th bit of M is "1",
which becomes the second bit of IP. The 7th bit of M is "0", which becomes the last bit
of IP.
Next divide the permuted block IP into a left half L0 of 32 bits, and a right half R0 of 32
bits.
We now proceed through 16 iterations, for 1<=n<=16, using a function f which operates
on two blocks--a data block of 32 bits and a key Kn of 48 bits--to produce a block of 32
bits. Let + denote XOR addition, (bit-by-bit addition modulo 2). Then for n going
from 1 to 16 we calculate
Ln = Rn-
1 Rn = Ln-1 + f(Rn-1,Kn)
This results in a final block, for n = 16, of L16R16. That is, in each iteration, we take the
right 32 bits of the previous result and make them the left 32 bits of the current step. For
the right 32 bits in the current step, we XOR the left 32 bits of the previous step with the
calculation f .
It remains to explain how the function f works. To calculate f, we first expand each block
Rn-1 from 32 bits to 48 bits. This is done by using a selection table that repeats some of
the bits in Rn-1 . We'll call the use of this selection table the function E. Thus E(Rn-1) has a
32 bit input block, and a 48 bit output block.
Let E be such that the 48 bits of its output, written as 8 blocks of 6 bits each, are obtained
by selecting the bits in its inputs in order according to the following table:
E BIT-SELECTION TABLE
32 1 2 3 4 5
4 5 6 7 8 9
8 9 10 11 12 13
12 13 14 15 16 17
16 17 18 19 20 21
20 21 22 23 24 25
24 25 26 27 28 29
28 29 30 31 32 1
Information Security Laboratory
Thus the first three bits of E(Rn-1) are the bits in positions 32, 1 and 2 of Rn-1 while the
last 2 bits of E(Rn-1) are the bits in positions 32 and 1.
(Note that each block of 4 original bits has been expanded to a block of 6 output bits.)
Next in the f calculation, we XOR the output E(Rn-1) with the key Kn:
Kn + E(Rn-1).
We have not yet finished calculating the function f . To this point we have expanded Rn-1
from 32 bits to 48 bits, using the selection table, and XORed the result with the key Kn .
We now have 48 bits, or eight groups of six bits. We now do something strange with each
group of six bits: we use them as addresses in tables called "S boxes". Each group of six
bits will give us an address in a different S box. Located at that address will be a 4 bit
number. This 4 bit number will replace the original 6 bits. The net result is that the eight
groups of 6 bits are transformed into eight groups of 4 bits (the 4-bit outputs from the S
boxes) for 32 bits total.
Kn + E(Rn-1) =B1B2B3B4B5B6B7B8,
S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8)
To repeat, each of the functions S1, S2,..., S8, takes a 6-bit block as input and yields a 4-
bit block as output. The table to determine S1 is shown and explained below:
S1
Column Number
Row
No. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
1 0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
Information Security Laboratory
2 4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
3 15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
If S1 is the function defined in this table and B is a block of 6 bits, then S1(B) is
determined as follows: The first and last bits of B represent in base 2 a number in the
decimal range 0 to 3 (or binary 00 to 11). Let that number be i. The middle 4 bits of B
represent in base 2 a number in the decimal range 0 to 15 (binary 0000 to 1111). Let that
number be j. Look up in the table the number in the i-th row and j-th column. It is a
number in the range 0 to 15 and is uniquely represented by a 4 bit block. That block is the
output S1(B) of S1 for the input B. For example, for input block B = 011011 the first bit is
"0" and the last bit "1" giving 01 as the row. This is row 1. The middle four bits are
"1101". This is the binary equivalent of decimal 13, so the column is column number 13.
In row 1, column 13 appears 5. This determines the output; 5 is binary 0101, so that the
output is 0101. Hence S1(011011) = 0101.
S1
14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
S2
15 1 8 14 6 11 3 4 9 7 2 13 12 0 5 10
3 13 4 7 15 2 8 14 12 0 1 10 6 9 11 5
0 14 7 11 10 4 13 1 5 8 12 6 9 3 2 15
13 8 10 1 3 15 4 2 11 6 7 12 0 5 14 9
S3
10 0 9 14 6 3 15 5 1 13 12 7 11 4 2 8
13 7 0 9 3 4 6 10 2 8 5 14 12 11 15 1
13 6 4 9 8 15 3 0 11 1 2 12 5 10 14 7
1 10 13 0 6 9 8 7 4 15 14 3 11 5 2 12
S4
7 13 14 3 0 6 9 10 1 2 8 5 11 12 4 15
13 8 11 5 6 15 0 3 4 7 2 12 1 10 14 9
10 6 9 0 12 11 7 13 15 1 3 14 5 2 8 4
3 15 0 6 10 1 13 8 9 4 5 11 12 7 2 14
S5
2 12 4 1 7 10 11 6 8 5 3 15 13 0 14 9
14 11 2 12 4 7 13 1 5 0 15 10 3 9 8 6
4 2 1 11 10 13 7 8 15 9 12 5 6 3 0 14
11 8 12 7 1 14 2 13 6 15 0 9 10 4 5 3
Information Security Laboratory
S6
12 1 10 15 9 2 6 8 0 13 3 4 14 7 5 11
10 15 4 2 7 12 9 5 6 1 13 14 0 11 3 8
9 14 15 5 2 8 12 3 7 0 4 10 1 13 11 6
4 3 2 12 9 5 15 10 11 14 1 7 6 0 8 13
S7
4 11 2 14 15 0 8 13 3 12 9 7 5 10 6 1
13 0 11 7 4 9 1 10 14 3 5 12 2 15 8 6
1 4 11 13 12 3 7 14 10 15 6 8 0 5 9 2
6 11 13 8 1 4 10 7 9 5 0 15 14 2 3 12
S8
13 2 8 4 6 15 11 1 10 9 3 14 5 0 12 7
1 15 13 8 10 3 7 4 12 5 6 11 0 14 9 2
7 11 4 1 9 12 14 2 0 6 10 13 15 3 5 8
2 1 14 7 4 10 8 13 15 12 9 0 3 5 6 11
Example: For the first round, we obtain as the output of the eight S boxes:
f = P(S1(B1)S2(B2)...S8(B8))
The permutation P is defined in the following table. P yields a 32-bit output from a 32-bit
input by permuting the bits of the input block.
16 7 20 21
29 12 28 17
1 15 23 26
5 18 31 10
2 8 24 14
32 27 3 9
19 13 30 6
22 11 4 25
we get
R1 = L0 + f(R0 , K1 )
In the next round, we will have L2 = R1, which is the block we just calculated, and then
we must calculate R2 =L1 + f(R1, K2), and so on for 16 rounds. At the end of the sixteenth
round we have the blocks L16 and R16. We then reverse the order of the two blocks into
the 64-bit block
R16L16
-1
and apply a final permutation IP as defined by the following table:
IP-1
40 8 48 16 56 24 64 32
39 7 47 15 55 23 63 31
38 6 46 14 54 22 62 30
37 5 45 13 53 21 61 29
36 4 44 12 52 20 60 28
35 3 43 11 51 19 59 27
34 2 42 10 50 18 58 26
33 1 41 9 49 17 57 25
That is, the output of the algorithm has bit 40 of the preoutput block as its first bit, bit 8 as
its second bit, and so on, until bit 25 of the preoutput block is the last bit of the output.
Example: If we process all 16 blocks using the method defined previously, we get, on the
16th round,
We reverse the order of these two blocks and apply the final permutation to
85E813540F0AB405.
Decryption is simply the inverse of encryption, follwing the same steps as above, but
reversing the order in which the subkeys are applied.
The DES algorithm turns a 64-bit message block M into a 64-bit cipher block C. If each
64-bit block is encrypted individually, then the mode of encryption is called Electronic
Code Book (ECB) mode. There are two other modes of DES encryption, namely Chain
Block Coding (CBC) and Cipher Feedback (CFB), which make each cipher block
dependent on all the previous messages blocks through an initial XOR operation.
Cracking DES
Before DES was adopted as a national standard, during the period NBS was soliciting
comments on the proposed algorithm, the creators of public key cryptography, Martin
Hellman and Whitfield Diffie, registered some objections to the use of DES as an
encryption algorithm. Hellman wrote: "Whit Diffie and I have become concerned that the
proposed data encryption standard, while probably secure against commercial assault,
may be extremely vulnerable to attack by an intelligence organization" (letter to NBS,
October 22, 1975).
Diffie and Hellman then outlined a "brute force" attack on DES. (By "brute force" is
meant that you try as many of the 2^56 possible keys as you have to before decrypting the
ciphertext into a sensible plaintext message.) They proposed a special purpose "parallel
computer using one million chips to try one million keys each" per second, and estimated
the cost of such a machine at $20 million.
Fast forward to 1998. Under the direction of John Gilmore of the EFF, a team spent
$220,000 and built a machine that can go through the entire 56-bit DES key space in an
average of 4.5 days. On July 17, 1998, they announced they had cracked a 56-bit key in
56 hours. The computer, called Deep Crack, uses 27 boards each containing 64 chips, and
is capable of testing 90 billion keys a second.
Despite this, as recently as June 8, 1998, Robert Litt, principal associate deputy attorney
general at the Department of Justice, denied it was possible for the FBI to crack DES:
"Let me put the technical problem in context: It took 14,000 Pentium computers working
for four months to decrypt a single message . . . . We are not just talking FBI and NSA
[needing massive computing power], we are talking about every police department."
Responded cryptograpy expert Bruce Schneier: " . . . the FBI is either incompetent or
lying, or both." Schneier went on to say: "The only solution here is to pick an algorithm
with a longer key; there isn't enough silicon in the galaxy or enough time before the sun
burns out to brute- force triple-DES" (Crypto-Gram, Counterpane Systems, August 15,
1998).
Information Security Laboratory
Triple-DES
Triple-DES is just DES with two 56-bit keys applied. Given a plaintext message, the first
key is used to DES- encrypt the message. The second key is used to DES-decrypt the
encrypted message. (Since the second key is not the right key, this decryption just
scrambles the data further.) The twice-scrambled message is then encrypted again with
the first key to yield the final ciphertext. This three-step procedure is called triple-DES.
Triple-DES is just DES done three times with two keys used in a particular order. (Triple-
DES can also be done with three separate keys instead of only two. In either case the
resultant key space is about 2^112.)
Information Security Laboratory
Experiment No 11
Wireshark:
Wireshark is a free and open source packet analyzer. It is used for network troubleshooting,
analysis, software andcommunications protocol development, and education. Originally
named Ethereal, the project was renamed Wireshark in May 2006 due to trademark issues. [4]
Wireshark is cross-platform, using the Qt widget toolkit in current releases to implement its user
interface, and using pcap to capture packets; it runs on Linux, OS X, BSD, Solaris, some
other Unix-like operating systems, and Microsoft Windows. There is also a terminal-based (non-
GUI) version called TShark. Wireshark, and the other programs distributed with it such as
TShark, are free software, released under the terms of the GNU General Public License.
Functionality:
Wireshark is very similar to tcpdump, but has a graphical front-end, plus some integrated sorting
and filtering options.
Wireshark lets the user put network interface controllers that support promiscuous mode into that
mode, so they can see all traffic visible on that interface, not just traffic addressed to one of the
interface's configured addresses and broadcast/multicast traffic. However, when capturing with
a packet analyzer in promiscuous mode on a port on a network switch, not all traffic through the
switch is necessarily sent to the port where the capture is done, so capturing in promiscuous mode
is not necessarily sufficient to see all network traffic. Port mirroring or various network
taps extend capture to any point on the network. Simple passive taps are extremely resistant to
tampering[citation needed].
On GNU/Linux, BSD, and OS X, with libpcap 1.0.0 or later, Wireshark 1.4 and later can also
put wireless network interface controllers into monitor mode.
If a remote machine captures packets and sends the captured packets to a machine running
Wireshark using the TZSP protocol or the protocol used by OmniPeek, Wireshark dissects those
packets, so it can analyze packets captured on a remote machine at the time that they are captured
History:
In the late 1990s, Gerald Combs, a computer science graduate of the University of Missouri–
Kansas City, was working for a small Internet service provider. The commercial protocol analysis
products at the time were priced around $1500[5] and did not run on the company's primary
platforms (Solaris and Linux), so Gerald began writing Ethereal and released the first version
around 1998.[1] The Ethereal trademark is owned by Network Integration Services.
In May 2006, Combs accepted a job with CACE Technologies. Combs still held copyright on
most of Ethereal's source code (and the rest was re-distributable under the GNU GPL), so he used
the contents of the Ethereal Subversion repository as the basis for the Wireshark repository.
However, he did not own the Ethereal trademark, so he changed the name to Wireshark. [6] In
2010 Riverbed Technology purchased CACE[7] and took over as the primary sponsor of
Wireshark. Ethereal development has ceased, and an Ethereal security advisory recommended
switching to Wireshark.[8]
Wireshark has won several industry awards over the years, [9] including eWeek,[10] InfoWorld,[11]
[12][13][14][15]
and PC Magazine.[16] It is also the top-rated Information Security Laboratory
Information Security Laboratory
packet sniffer in the Insecure.Org network security tools survey and was the SourceForge Project
of the Month in August 2010.
Combs continues to maintain the overall code of Wireshark and issue releases of new versions of
the software. The product website lists over 600 additional contributing authors.
Features:
Wireshark is a data capturing program that "understands" the structure (encapsulation) of different
networking protocols. It can parse and display the fields, along with their meanings as specified
by different networking protocols. Wireshark uses pcap to capture packets, so it can only capture
packets on the types of networks that pcap supports.
Data can be captured "from the wire" from a live network connection or read from a file of
already-captured packets.
Live data can be read from a number of types of networks, including Ethernet, IEEE
802.11, PPP, and loopback.
Captured network data can be browsed via a GUI, or via the terminal (command line)
version of the utility, TShark.
Captured files can be programmatically edited or converted via command-line switches to
the "editcap" program.
Data display can be refined using a display filter.
Plug-ins can be created for dissecting new protocols. [19]
VoIP calls in the captured traffic can be detected. If encoded in a compatible encoding, the
media flow can even be played.
Raw USB traffic can be captured.[20]
Wireless connections can also be filtered as long as they transverse the monitored Ethernet.
[clarification needed]
Various settings, timers, and filters can be set that ensure only triggered traffic appear.
[clarification needed]
Wireshark's native network trace file format is the libpcap format supported by libpcap and
WinPcap, so it can exchange captured network traces with other applications that use the same
format, including tcpdump and CA NetMaster. It can also read captures from other network
analyzers, such as snoop, Network General's Sniffer, and Microsoft Network Monitor.
Security:
Capturing raw network traffic from an interface requires elevated privileges on some platforms.
For this reason, older versions of Ethereal/Wireshark and tethereal/TShark often ran
with superuser privileges. Taking into account the huge number of protocol dissectors that are
called when traffic is captured, this can pose a serious security risk given the possibility of a bug
in a dissector. Due to the rather large number of vulnerabilities in the past (of which many have
allowed remote code execution) and developers' doubts for better future
development, OpenBSD removed Ethereal from its ports tree prior to OpenBSD 3.6. [21]
Elevated privileges are not needed for all operations. For example, an alternative is to run
tcpdump or the dumpcap utility that comes with Wireshark with superuser privileges to capture
packets into a file, and later analyze the packets by running Wireshark with restricted privileges.
Information Security Laboratory
To emulate near realtime analysis, each captured file may be merged bymergecap into growing
file processed by Wireshark. On wireless networks, it is possible to use the Aircrack wireless
security tools to capture IEEE 802.11 frames and read the resulting dump files with Wireshark.
As of Wireshark 0.99.7, Wireshark and TShark run dumpcap to perform traffic capture. Platforms
that require special privileges to capture traffic need only dumpcap run with those privileges.
Neither Wireshark nor TShark need to or should be run with special privileges.
Information Security Laboratory
Experiment No 12
Addressing Table
Parameters R1 R3
Objectives
Part 1: Enable Security Features
Part 2: Configure IPsec Parameters on R1
Part 3: Configure IPsec Parameters on R3
Part 4: Verify the IPsec VPN
Scenario
In this activity, you will configure two routers to support a site-to-site IPsec VPN for traffic flowing from
their respective LANs. The IPsec VPN traffic will pass through another router that has no knowledge of the
VPN. IPsec provides secure transmission of sensitive information over unprotected networks such as the
Internet. IPsec acts at the network layer, protecting and authenticating IP packets between participating IPsec
devices (peers), such as Cisco routers.
----------------------------------------------------------------
Technology Technology-package Technology-package
Current Type Next reboot
-----------------------------------------------------------------
ipbase ipbasek9 Permanent ipbasek9
security securityk9 Evaluation securityk9
uc None None None
data None None None
d. Repeat Steps 1a to 1c with R3.
interface: Serial0/0/0
Crypto map tag: VPN-MAP, local addr 10.1.1.2
interface: Serial0/0/0
Crypto map tag: VPN-MAP, local addr 10.1.1.2
1. If you are a victim of Denial of Service (Dos) then what you do?
4. If you have to generate a hash function then what characteristics are needed in a
secure hash function?
7. Explain SSL Protocol. How does it protect internet users from various threats?
11. What are the two basic ways of transforming plain text into cipher text?
14. What is the difference between Substitution Cipher and Transposition Cipher?
18. What is the output of plain text Hello there, my name is Atul if we use Ceasar
Cipher to encode it?
28. If A wants to send a message securely to B, what would be the typical steps
involved?
30. Describe the advantages and disadvantages of symmetric and asymmetric key
cryptology.
34. What is the important aspect that establishes trust in digital signatures?
36. Why is the SSL layer positioned between the application lyer and the transport
layer?
TEXT BOOKS:
1. Godbole," Information Systems Security", Wiley
2. Merkov, Breithaupt," Information Security", Pearson Education