Lab Manual
Lab Manual
COLLEGE OF ENGINEERING
S. No. 18, Plot No. 5/3, Karvenagar, PUNE – 411 052
Tel: 020-25473160 Fax: 020-25470909
Website: www.mmcoe.edu.in
BE (INFORMATION TECHNOLOGY)
(SEMESTER – I)
COMPUTER LABORATORY-VII
2015 course
Prepared By
Mrs. Preeti S. Joshi
Part A:
Section -I
1. Write a program in C++ or Java to implement RSA algorithm for key generation
and cipher verification.
2. Develop and program in C++ or Java based on number theory such as Chinese
remainder.
3. Write a program in C++ or java to implement SHA1 algorithm using libraries (API)
4. Configure and demonstrate use of vulnerability assessment tool such as Snort tool
for intrusion or SSL Web security.
PROGRAM OUTCOMES
COURSE OBJECTIVES:
1.To Understand
Marathwada the Security
Mitra Mandal’s issues
College in networks,Pune
of Engineering and Applications
52 software.
2. To understand the machine learning principles and analytics of learning algorithms.
COURSE OUTCOMES:
1. Understand basics of Information security and Use basic cryptography techniques in application
development and apply methods for authentication, access control, intrusion detection and
prevention.
2.To learn encryption standards and algorithms of symmetric and asymmetric encryption
3. To learn data integrity algorithms, web security requirements and to apply the scientific
method to digital forensics and perform forensic investigations.
4.To learn legal,ethical, and professional issues in information security and develop computer
forensics awareness
6. To use computer forensics tools.To implement and port controlled and secured access to
software systems, networks and to build learning software in various domains.
CO - PO MAPPING :
Program outcomes
Course
Outcome
1 2 3 4 5 6 7 8 9 10 11 12
414453.1 3 3 3 3 3 3 - - 2 - - 2
414453.2 3 3 3 3 3 3 - - 2 - - 2
414453.3 3 3 3 3 3 3 - - 2 - - 2
414453.4 - - - - - - 3 1 1 - - -
414453.5 - - - - - - 3 1 1 - - -
414453.6 3 3 3 3 3 3 - - 3 - - 1
Assignment & CO Mapping:
Assignment No. 1 X x
Assignment No. 2 X X
Assignment No. 3 X X
Assignment No. 4 X
AIM: Write a program in C++ or Java to implement RSA algorithm for key generation and cipher
verification.
OBJECTIVE : To Study
Concept of Public key and Private Key
Public Key algorithm
Working of RSA algorithm
THEORY :
Asymmetric/Public key Algorithm
This type of algorithm rely on one key for encryption and a different but related key for decryption.
These algorithms have the following important characteristic:
It is computationally infeasible to determine the decryption key given only knowledge of the
cryptographic algorithm and the encryption key.
In addition, some algorithms, such as RSA, also exhibit the following characteristic:
Either of the two related keys can be used for encryption, with the other used for decryption.
Encryption algorithm: The encryption algorithm performs various transformations on the plaintext.
Public and private keys: This is a pair of keys that have been selected so that if one is used for
encryption, the other is used for decryption. The exact transformations performed by the algorithm
depend on the public or private key that is provided as input.
Ciphertext: This is the scrambled message produced as output. It depends on the plaintext and the key.
For a given message, two different keys will produce two different ciphertexts. Decryption algorithm:
This algorithm accepts the ciphertext and the matching key and produces the original plaintext.
2. Each user places one of the two keys in a public register or other accessible file. This is the public
key. The companion key is kept private. Each user maintains a collection of public keys obtained from
others.
3. If B wishes to send a confidential message to A, B encrypts the message using A's public key.
4. When A receives the message, she decrypts it using her private key. No other recipient can decrypt
the message because only A knows A's private key.
RSA Algorithm
RSA(which stands for Ron Rivest, Adi Shamir, and Len Adelman),an algorithm for public- key
cryptography involves three steps key generation,encryption and decryption.The RSA scheme is a
block cipher in which the plaintext and ciphertext are integers between 0 and n − 1. A typical size of n
is 1024 bits, or 309 decimal digits. Thus, the plaintext is encrypted in blocks, with each block having a
binary value less than some number n. That is, the block size must be less than or equal to log2(n).
Encryption and decryption are of the following form, for some plaintext block M and ciphertext block
C:
C = Me mod n
M = Cd mod n
Both sender and receiver must know the value of n. The sender knows the value of e, and only the
receiver knows the value of d. Thus, this is a public-key encryption algorithm with a public key of PU
= {e, n} and a PR = {d, n}.
Algorithm
Marathwada Mitra Mandal’s College of Engineering ,Pune 52
1. Key Generation
2. Encryption
Plaintext: M < n
Ciphertext: C = Me (mod n)
3. Decryption
Ciphertext: C
Plaintext: M = Cd(mod n)
Example
Select primes p=11, q=3.
n=pq=11.3=33
Φ(n) = (p-1)(q-1) = 10.2 = 20
Choose e=3
Check gcd(e, p-1) = gcd(3, 10) = 1 (i.e. 3 and 10 have no common factors except 1),
and check gcd(e,q-1)=gcd(3,2)=1
therefore gcd(e, Φ(n)) = gcd(e, (p-1)(q-1)) = gcd(3, 20) = 1
compute d = e-1 mod Φ(n) = 3-1 mod 20
i.e. find a value for d such that Φ(n) divides (ed-1)
i.e. find d such that 20 divides 3d-1.
Simple testing (d = 1, 2,...) gives d = 7
Check: ed-1 = 3.7 - 1 = 20, which is divisible by Φ(n).
Conclusion: Thus RSA algorithm is used to implement asymmetric key cryptography and used to
solve the man-in-the-middle attack, which is drawback in Diffie-Hellman algorithm.
FAQs:
Assignment Number: 2
AIM :Develop and program in C++ or Java based on number theory such as Chinese remainder
OBJECTIVE:
Marathwada Mitra Mandal’s College of Engineering ,Pune 52
To Study
THEORY:
Relative prime
Two integers are termed relative prime if the only common factor between them is 1. Any integer can
be broken down into certain multiples of prime numbers. this is called prime factorization. When you
prime factorize two integers and the only common number is 1,then the two integers are relative prime.
for ex.
18 = 2 x 3 x 3
35 = 7 x 5
18 = 2 x 3 x 3
21 = 3 x 7
Set of Residues
Zn=(0,1,2…………….(n-1)}
Let m1, m2, …, mk be pairwise relatively prime integers. That is, gcd(m i, mj) = 1 for 1£i<j £k. Let
aiÎZmi for 1£i £k and set M=m1m2…mk. Then there exists a unique A ÎZm such that Aºai mod mi for i
= 1…k.
Where
Example
Answer:
M=1813 =37*49,
m1= 37, m2=49
A=973
A=(A mod m1,A mod m2)={11,42}
x≡3mod5
x≡2mod7
Answer
1. M = 3×5×7 = 105
2. M1=105/3=35,M2=105/5=21,M3=105/7=15
3. The inverse are M1-1=2, M2-1=1, M3-1=1,
4. X=(2×35×2+3×21×1+2×15×1) mod 105=23 mod 105
5. X=23
FAQs :
Assignment Number: 3
AIM : Write a program in C++ or java to implement SHA1 algorithm using libraries (API)
THEORY :
The word secure in SHA was decided based on two features. SHAis designed to be computationally in
feasible to:
The input message is "padded" (extended) so that its length (in bits) equals to 448 mod 512.
Padding is always performed, even if the length of the message is already 448 mod 512.
A 64-bit representation of the length of the message is appended to the result of step1. If the
length of the message is greater than 2^64, only the low-order 64 bits will be used.The resulting
message (after padding with bits and with b) has a length that is an exact multiple of 512 bits.
The input message is noe divided into blocks , each of length 512 bits.These blocks become the
input to the message digest processing logic.
A five -word buffer (A, B, C, D,E) is used to compute the message digest. Each of A, B, C, D
is a 32-bit register. These registers are initialized to the following values in hexadecimal, low-order
bytes first):
Step 5.1
Copy the chaining variables A-E into variables a-e. The combination of a-e called abcde will be
considered as a single register for storing the temporarily intermediate as well as the final result.
Step 5.2
Now divide the current 512 bit block into 16 sub block, each consisting of 32 bits.
Step 5.3
SHA has 4 rounds each consisting of 20 iteration . Ecah round takes the current 512 bit block,the
register abcde and a constant k[t] (where t=0 to 79) as three input s.It then update the content of the
register abcde using SHA algorithm steps.We have only four constants defined for K[t],one used in
each round.The value of K[t] are given in following table
Step 5.3
SHA consist of four rounds,each containing 20 iterations.this makes a total 80 iterations.The logical
operation of SHA-1 is shown in following fig.
where
Process p is given as
For the first 16 blocks of W(i.e. t=0 to 15) the contents of the input message sub block M[t]
become the content of W[t].Remaining valued are calculated as
Required Classes
AIM: Configure and demonstrate use of vulnerability assessment tool such as Snort tool for intrusion or SSL
Web security.
OBJECTIVES: Download vulnerability scanning tool. Generate the report for any sample network
ex. SNORT
Theory:
Intrusion Detection System Defined as the tools, methods, and resources to help identify, assess, and
report unauthorized or unapproved network activity.An IDS detects activity in traffic that may or may
not be an intrusion.
IDSes can detect and deal with insider attacks, as well as, external attacks, and are often very useful in
detecting violations of corporate security policy and other internal threats.
Many computer users have encountered tools that monitor dynamic system behaviour in the form of
anti-virus (AV) packages. While AV programs often also monitor system state, they do spend a lot of
their time looking at who is doing what inside a computer – and whether a given program should or
should not have access to particular system resources. The lines become blurred here, as many of the
tools overlap in functionality.
Intrusion prevention systems are a type of HIDS software that protects against buffer overflow attacks
on system memory and can enforce security policy.
Monitoring state
The principle operation of a HIDS depends on the fact that successful intruders (hackers) will generally
leave a trace of their activities. In fact, such intruders often want to own the computer they have
attacked, and will establish their "ownership" by installing software that will grant the intruders future
access to carry out whatever activity (keystroke logging, identity theft, spamming, botnet activity,
spyware-usage etc.) they envisage.In theory, a computer user has the ability to detect any such
modifications, and the HIDS attempts to do just that and reports its findings.
Ideally a HIDS works in conjunction with a NIDS, such that a HIDS finds anything that slips past the
NIDS. Commercially available software solutions often do correlate the findings from NIDS and HIDS
in order to find out about whether a network intruder has been successful or not at the targeted host.
Technique
In general a HIDS uses a database (object-database) of system objects it should monitor – usually (but
not necessarily) file system objects. A HIDS could also check that appropriate regions of memory have
not been modified – for example, the system call table for Linux, and various vtable structures in
Microsoft Windows.
During the communication establishment phase and while transferring the data requested by the client,
the host's server and the client exchanges a passphrase to verify their identity. The server uses the same
passphrase all the time for this purpose. Based upon that an object is created.
For each object in question a HIDS will usually remember its attributes (permissions, size,
modifications dates) and create a checksum of some kind (an MD5, SHA1 hash or similar) for the
contents, if any. This information gets stored in a secure database for later comparison (checksum
database).
An alternate method to HIDS would be to provide NIDS type functionality at the network interface
(NIC) level of an end-point (either server, workstation or other end device). Providing HIDS at the
network layer has the advantage of providing more detailed logging of the source (IP address) of the
attack and attack details, such as packet data, neither of which a dynamic behavioral monitoring
approach could see.
Fig:NIDS
The Data Encryption Standard (DES) is a symmetric-key block cipher published by the National
Institute of Standards and Technology (NIST).
DES is an implementation of a Feistel Cipher. It uses 16 round Feistel structure. The block size is 64-
bit. Though, key length is 64-bit, DES has an effective key length of 56 bits, since 8 of the 64 bits of
the key are not used by the encryption algorithm (function as check bits only). General Structure of
DES is depicted in the following illustration
Before using 3TDES, user first generate and distribute a 3TDES key K, which consists of three
different DES keys K1, K2 and K3. This means that the actual 3TDES key has length 3×56 = 168 bits.
The encryption scheme is illustrated as follows −
Encrypt the plaintext blocks using single DES with key K1.
Now decrypt the output of step 1 using single DES with key K2
Finally, encrypt the output of step 2 using single DES with key K 3.
Decryption of a ciphertext is a reverse process. User first decrypt using K3, then encrypt with
K2, and finally decrypt with K1.
Due to this design of Triple DES as an encrypt–decrypt–encrypt process, it is possible to use a 3TDES
(hardware) implementation for single DES by setting K1, K2, and K3 to be the same value. This
provides backwards compatibility with DES.
Second variant of Triple DES (2TDES) is identical to 3TDES except that K3is replaced by K1. In other
words, user encrypt plaintext blocks with key K1, then decrypt with key K2, and finally encrypt with K1
again. Therefore, 2TDES has a key length of 112 bits.
Triple DES systems are significantly more secure than single DES, but these are clearly a much slower
process than encryption using single DES.
Step 1: Generate Plaintext m, keyA and keyB by clicking on rexpective buttons PART I of the
simulation page.
Step 3: Enter generated keyA from PART I to PART II "Key to be used:" block and click on DES
encrpt button to output ciphertext c1.This is First Encryption.
Step 4: Enter generated ciphertext c1 from PART II "Output:" Block to PART II in "Your text to be
encrypted/decrypted:" block.
Step 5: Enter generated keyB from PART I to PART II in "Key to be used:" block and click on DES
decrypt button to output ciphertect c2.This is Second Encryption.
Step 6: Enter generated ciphertext c2 from PART II "Output:" block to PART II in "Your text to be
encrypted/decrypted:" block.
Step 7: Enter generated keyA from PART I to PART II "Key to be used:" block and click on DES
encrpt button to output ciphertext c3.This is Third Encryption. As Encryption is done thrice.This
Scheme is called triple DES.
Step 7: Enter generated ciphertext c3 from PART II "Output:" Block to PART III "Enter your answer
here:" block inorder to verify your Triple DES.
Conclusion:
Thus we have studied DES algorithm implementation.
FAQs:
1.What is DES?
2.What do you meant by triple DES?
3.Difference between DES and AES?