MIT Lab Manual Experiments
MIT Lab Manual Experiments
Experiment No. 1
Aim
Computer data often travels from one computer to another, leaving the safety of its
protected physical surroundings. Once the data is out of hand, people with bad
intention could modify or forge your data, either for amusement or for their own
benefit.
Cryptography can reformat and transform our data, making it safer on its trip between
computers. The technology is based on the essentials of secret codes, augmented by
modern mathematics that protects our data in powerful ways.
Computer Security - generic name for the collection of tools designed to protect
data and to thwart hackers.
LAB-MANUAL
Page 1
Experiment No. 2
Aim
LAB-MANUAL
Page 2
Experiment No. 3
Aim
The first answer to problems of DES is an algorithm called Double DES which includes
double encryption with two keys. It increases the key size to 112 bits, which seems to be
secure. But, there are some problems associated with this approach. issue of education
to single stage: In other words, could there be a key K3 such that EK2 EK21(P))=
EK3(P)? meet-in-the-middle attack:
Works when given a known (P,C) pair
since X = EK1(P) = DK2(C)
attack by encrypting P with all 256 keys K1and store
then decrypt C with all possible 256 keys K2 and match X value
Test the two keys for the second pair of plaintext-cipher text and if they match,
correct keys are found
Triple DES was the answer to many of the shortcomings of DES. Since it is based on the
DES algorithm, it is very easy to modify existing software to use Triple DES. 3DES was
developed in 1999 by IBM by a team led by Walter Tuchman. 3DES prevents a meetin-the-middle attack. 3DES has a 168-bit key and enciphers blocks of 64 bits. It also has
the advantage of proven reliability and a longer key length that eliminates many of the
shortcut attacks that can be used to reduce the amount of time it takes to break DES.
3DES uses three keys and three executions of the DES algorithm. The function follows
an encrypt-decrypt-encrypt (EDE) sequence.
LAB-MANUAL
Page 3
Triple DES runs three times slower than standard DES, but is much more secure if used
properly. With three distinct keys, TDEA has an effective key length of 168 bits making
it a formidable algorithm. As the underlying algorithm is DEA, it offers the same
resistance to cryptanalysis as is DEA. Triple DES can be done using 2 keys or 3 keys.
LAB-MANUAL
Page 4
Experiment No. 4
Aim
Virtually, all symmetric block encryption algorithms in current use are based on a
structure referred to as Fiestel block cipher.
For that reason, it is important to examine the design principles of the Fiestel cipher. We
begin with a comparison of stream cipher with block cipher.
A stream cipher is one that encrypts a digital data stream one bit or one byte at a
time. E.g, vigenere cipher. A block cipher is one in which a block of plaintext is
treated as a whole and used to produce a cipher text block of equal length.
Typically a block size of 64 or 128 bits is used.
most symmetric block ciphers are based on a Feistel Cipher Structure needed
since must be able to decrypt cipher text to recover messages efficiently. block
ciphers look like an extremely large substitution
would need table of 264 entries for a 64-bit block
Instead create from smaller building blocks
Using idea of a product cipher in 1949 Claude Shannon introduced idea of
substitution- permutation (S-P) networks called modern substitution-transposition
product cipher these form the basis of modern block ciphers.
S-P networks are based on the two primitive cryptographic operations we have
seen before:
1. substitution (S-box)
2. Permutation (P-box)
Provide confusion and diffusion of message
Diffusion dissipates statistical structure of plaintext over bulk of cipher text
Confusion makes relationship between cipher text and key as complex as
possible
LAB-MANUAL
Page 5
Experiment No. 5
Aim
RSA algorithm best known and widely regarded as most practical public-key scheme
was proposed by Rivest, Shamir & Adleman in 1977. t is a public-key scheme which
may be used for encrypting messages, exchanging keys, and creating digital signatures.
LAB-MANUAL
Page 6
RSA Example
1. Select primes: p=17 & q=11
2. Compute n = pq =1711=187
3. Compute (n)=(p1)(q-1)=1610=160
4. Select e : gcd(e,160)=1; choose e=7
5. Determine d: de=1 mod 160 and d < 160 Value is d=23 since 237=161= 10160+1
6. Publish public key KU={7,187}
7. Keep secret private key KR={23,17,11}
RSA Example cont
sample RSA encryption/decryption is:
Now given message M = 88 (nb. 88<187)
encryption: C = 887 mod 187 = 11
decryption: M = 1123 mod 187 = 88
Another example of RSA is given as,
Let p = 11, q = 13, e = 11, m = 7
n = pq i.e. n= 11*13 = 143
(n)= (p-1)(q-1) i.e. (11-1)(13-1) = 120
e.d=1 mod (n) i.e. 11d mod 120 = 1 i.e. (11*11) mod 120=1; so d = 11
Public key :{11,143} and private key: {11,143}
C=Me mod n, so ciphertext = 711mod143 = 727833 mod 143; i.e. C = 106
M=Cd mod n, plaintext = 10611 mod 143 = 1008 mod 143; i.e. M = 7
Another example is:
LAB-MANUAL
Page 7
Experiment No. 6
Aim
LAB-MANUAL
Page 8
Suppose the message can be any arbitrary bit pattern. In that case, there is no way to
determine automatically, at the destination whether an incoming message is the cipher
text of a legitimate message. One solution to this problem is to force the plaintext to
have some structure that is easily recognized but that cannot be replicated without
recourse to the encryption function. We could, for example, append an error detecting
code, also known as Frame Check Sequence (FCS) or checksum to each message before
encryption
A prepares a plaintext message M and then provides this as input to a function F that
produces an FCS. The FCS is appended to M and the entire block is then encrypted. At
the destination, B decrypts the incoming block and treats the result as a message with
an appended FCS. B applies the same function F to attempt to reproduce the FCS. If the
calculated FCS is equal to the incoming FCS, then the message is considered authentic.
In the internal error control, the function F is applied to the plaintext, whereas in
external error control, F is applied to the cipher text (encrypted message).
LAB-MANUAL
Page 9
Experiment No. 7
Aim
In virtually all distributed environments, electronic mail is the most heavily used
network-based application. But current email services are roughly like "postcards,
anyone who wants could pick it up and have a look as its in transit or sitting in the
recipients mailbox. PGP provides a confidentiality and authentication service that can
be used for electronic mail and file storage applications. With the explosively growing
reliance on electronic mail for every conceivable purpose, there grows a demand for
authentication and confidentiality services.
The Pretty Good Privacy (PGP) secure email program, is a remarkable phenomenon,
has grown explosively and is now widely used. Largely the effort of a single person,
Phil Zimmermann, who selected the best available crypto algorithms to use &
integrated them into a single program, PGP provides a confidentiality and
authentication service that can be used for electronic mail and file storage applications.
It is independent of government organizations and runs on a wide range of systems, in
both free & commercial versions.
There are five important services in PGP
Authentication (Sign/Verify)
Confidentiality (Encryption/Decryption)
Compression
Email compatibility
Segmentation and Reassembly
The last three are transparent to the user
PGP Notations:
Ks
PRa
PUa
EP
DP
EC
DC
H
||
Z
R64
LAB-MANUAL
Page 10
LAB-MANUAL
Page 11
Page 12
component and signature component appear only once, at the beginning of the first
segment. Reassembly at the receiving end is required before verifying signature or
decryption
RFC 822
RFC 822 defines a format for text messages that are sent using electronic mail and it has
been the standard for Internet-based text mail message. The overall structure of a
message that conforms to RFC 822 is very simple. A message consists of some number
of header lines (the header) followed by unrestricted text (the body). The header is
separated from the body by a blank line. A header line usually consists of a keyword,
followed by a colon, followed by the keyword's arguments; the format allows a long
line to be broken up into several lines. The most frequently used keywords are From, To,
Subject, and Date.
LAB-MANUAL
Page 13
Experiment No. 8
Aim :
To study IP Security
Definition: Internet Protocol security (IPSec) is a framework of open standards for
protecting communications over Internet Protocol (IP) networks through the use of
cryptographic security services. IPSec supports network-level peer authentication, data
origin authentication, data integrity, and data confidentiality (encryption), and replay
protection.
Need for IPSec:
In Computer Emergency Response Team (CERT)s 2001 annual report it listed 52,000
security incidents in which most serious types of attacks included IP spoofing, in which
intruders create packets with false IP addresses and exploit applications that use
authentication based on IP and various forms of eavesdropping and packet sniffing, in
which attackers read transmitted information, including logon information and
database contents. In response to these issues, the IAB included authentication and
encryption as necessary security features in the next-generation IP i.e. IPv6.
Applications of IPSec:
IPSec provides the capability to secure communications across a LAN, across private
and public wide area networks (WANs), and across the Internet.
Secure branch office connectivity over the Internet: A company can build a secure
virtual private network over the Internet or over a public WAN. This enables a business
to rely heavily on the Internet and reduce its need for private networks, saving costs
and network management overhead.
Secure remote access over the Internet: An end user whose system is equipped with IP
security protocols can make a local call to an Internet service provider (ISP) and gain
secure access to a company network. This reduces the cost of toll charges for travelling
employees and telecommuters.
Establishing extranet and intranet connectivity with partners: IPSec can be used to
secure communication with other organizations, ensuring authentication and
confidentiality and providing a key exchange mechanism.
Enhancing electronic commerce security: Even though some Web and electronic
commerce applications have built-in security protocols, the use of IPSec enhances that
security.
The principal feature of IPSec enabling it to support varied applications is that it can
encrypt and/or authenticate all traffic at IP level. Thus, all distributed applications,
LAB-MANUAL
Page 14
including remote logon, client/server, e-mail, file transfer, Web access, and so on, can be
secured.
The following figure shows a typical scenario of IPSec usage. An organization
maintains LANs at dispersed locations. Non secure IP traffic is conducted on each LAN.
The IPSec protocols operate in networking devices, such as a router or firewall that
connect each LAN to the outside world. The IPSec networking device will typically
encrypt and compress all traffic going into the WAN, and decrypt and decompress
traffic coming from the WAN; these operations are transparent to workstations and
servers on the LAN. Secure transmission is also possible with individual users who dial
into the WAN. Such user workstations must implement the IPSec protocols to provide
security.
Benefits of IPSec
IPSec in a firewall/router provides strong security to all traffic crossing the perimeter
IPSec in a firewall is resistant to bypass
IPSec is below transport layer (TCP, UDP), hence transparent to applications
IPSec can be transparent to end users
IPSec can provide security for individual users if needed (useful for offsite workers
and setting up a secure virtual sub network for sensitive applications)
Routing Applications:
IPSec also plays a vital role in the routing architecture required for internetworking. It
assures that:
Router advertisements come from authorized routers
Neighbor advertisements come from authorized routers
redirect messages come from the router to which initial packet was sent
A routing update is not forged
LAB-MANUAL
Page 15
IPSec Documents
The IPSec specification consists of numerous documents. The most important of these,
issued in November of 1998, are RFCs 2401, 2402, 2406, and 2408:
RFC 2401: An overview of security architecture
RFC 2402: Description of a packet authentication extension to IPv4 and IPv6
RFC 2406: Description of a packet encryption extension to IPv4 and IPv6
RFC 2408: Specification of key management capabilities
Support for these features is mandatory for IPv6 and optional for IPv4. In both cases,
the security features are implemented as extension headers that follow the main IP
header. The extension header for authentication is known as the Authentication header;
that for encryption is known as the Encapsulating Security Payload (ESP) header. In
addition to these four RFCs, a number of additional drafts have been published by the
IP Security Protocol Working Group set up by the IETF. The documents are divided
into seven groups, as depicted in following figure:
LAB-MANUAL
Page 16
IPSec Services
IPSec architecture makes use of two major protocols (i.e., Authentication Header and
ESP protocols) for providing security at IP level. This facilitates the system to
beforehand choose an algorithm to be implemented, security protocols needed and any
cryptographic keys required to provide requested services. The IPSec services are as
follows:
Connectionless Integrity:- Data integrity service is provided by IPSec via AH which
prevents the data from being altered during transmission.
Data Origin Authentication:- This IPSec service prevents the occurrence of replay
attacks, address spoofing etc., which can be fatal
Access Control:- The cryptographic keys are distributed and the traffic flow is
controlled in both AH and ESP protocols, which is done to accomplish access control
over the data transmission.
Confidentiality:- Confidentiality on the data packet is obtained by using an
encryption technique in which all the data packets are transformed into ciphertext
packets which are unreadable and difficult to understand.
Limited Traffic Flow Confidentiality:- This facility or service provided by IPSec
ensures that the confidentiality is maintained on the number of packets transferred
or received. This can be done using padding in ESP.
Replay packets Rejection:- The duplicate or replay packets are identified and
discarded using the sequence number field in both AH and ESP.
LAB-MANUAL
Page 17
Security Associations
Since IPSEC is designed to be able to use various security protocols, it uses Security
Associations (SA) to specify the protocols to be used. SA is a database record which
specifies security parameters controlling security operations. They are referenced by the
sending host and established by the receiving host. An index parameter called the
Security Parameters Index (SPI) is used. SAs are in one direction only and a second SA
must be established for the transmission to be bi-directional. A security association is
uniquely identified by three parameters:
Security Parameters Index (SPI): A bit string assigned to this SA and having local
significance only. The SPI is carried in AH and ESP headers to enable the receiving
system to select the SA under which a received packet will be processed.
IP Destination Address: Currently, only unicast addresses are allowed; this is the
address of the destination endpoint of the SA, which may be an end user system or a
network system such as a firewall or router.
Security Protocol Identifier: This indicates whether the association is an AH or ESP
security association.
LAB-MANUAL
Page 18
Experiment No. 9
Aim :
Page 19
There are things applications needs very often. So why make these over and over again?
Web services can offer application components like: currency conversion, weather
reports, or even language translation as services.
Connect existing software.
Web services can help to solve the interoperability problem by giving different
applications a way to link their data.
With Web services you can exchange data between different applications and different
platforms.
Web Services Platform Elements
Web Services have three basic platform elements: SOAP, WSDL and UDDI.
What is SOAP?
SOAP is an XML based protocol to let applications exchange information over HTTP.
Or more simple : SOAP is a protocol for accessing a Web Service.
SOAP stands for Simple Object Access Protocol
SOAP is a communication protocol
SOAP is a format for sending messages
SOAP is designed to communicate via Internet
SOAP is platform independent
SOAP is language independent
SOAP is based on XML
SOAP is simple and extensible
SOAP allows you to get around firewalls
SOAP is a W3C standard
Web Services Example
Any application can have a Web Service component.
Web Services can be created regardless of programming language.
A Web Service Example
In the following example we will use ASP.NET to create a simple Web Service that
converts the temperature from Fahrenheit to Celsius, and vice versa:
<%@ WebService Language="VBScript" Class="TempConvert" %>
Imports System
Imports System.Web.Services
Public Class TempConvert: Inherits WebService
<WebMethod()> Public Function FahrenheitToCelsius
(ByVal Fahrenheit As String) As String
LAB-MANUAL
Page 20
dim fahr
fahr=trim(replace(Fahrenheit,",","."))
if fahr="" or IsNumeric(fahr)=false then return "Error"
return ((((fahr) 32)/ 9) * 5)
end function
<WebMethod()> Public Function CelsiusToFahrenheit
(ByVal Celsius As String) As String
dim cel
cel=trim(replace(Celsius,",","."))
if cel="" or IsNumeric(cel)=false then return "Error"
return ((((cel) * 9) / 5) + 32)
end function
end class
This document is saved as an .asmx file. This is the ASP.NET file extension for XML
Web Services.
Example Explained
Note: To run this example, you will need a .NET server.
The first line in the example states that this is a Web Service, written in VBScript, and
has the class name "TempConvert":
<%@ WebService Language="VBScript" Class="TempConvert" %>
The next lines import the namespace "System.Web.Services" from the .NET framework:
Imports System
Imports System.Web.Services
The next line defines that the "TempConvert" class is a WebService class type:
Public Class TempConvert :Inherits WebService
The next steps are basic VB programming. This application has two functions. One to
convert from Fahrenheit to Celsius, and one to convert from Celsius to Fahrenheit.
The only difference from a normal application is that this function is defined as a
"WebMethod()".
Use "WebMethod()" to convert the functions in your application into web services:
<WebMethod()> Public Function FahrenheitToCelsius
(ByVal Fahrenheit As String) As String
dim fahr
fahr=trim(replace(Fahrenheit,",","."))
if fahr="" or IsNumeric(fahr)=false then return "Error"
LAB-MANUAL
Page 21
LAB-MANUAL
Page 22
Celsius to Fahrenheit:
How To Do It
Submit
LAB-MANUAL
Page 23