Lab 3: Cryptography

shoulderslyricalΤεχνίτη Νοημοσύνη και Ρομποτική

21 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

88 εμφανίσεις

shoulderslyrical_221c8d18
-
4c7c
-
4c89
-
9e9b
-
95cbb3cff55b.doc







1
/
5



Student Name:

__________
________________________
Computer #

____


Activity

1
:
Comparing MD5 message
-
digest hashes on a Windows


MD5

(
Message
-
Digest algorithm 5
)

is a widely used
cryptographic hash funct
ion

that generates a 128
-
bit

hash value. It has been used in a wide variety of security applications. One of its common
usages

is
checking the integrity of downloaded software to make sure they are legitimate. However, it has been
shown that MD5 is not
col
lision resistant
.
A

hash function is
collision resistant

if it is
impossible or
nearly
impossible

to find two inputs that hash to the same output. While it was not a clearly fatal
weakness, some researchers are recommending the use of other algorithms, suc
h as
SHA
-
1

or SHA
-
2.
Md5deep is a version of MD5 that can be used
to
hash various types of inputs.
One of t
he

latest stable
version
s

of md5deep (
that includes other hash functions
) is version 3.6 released on March 23 2010.


Md5deep can be downloaded from
h
ttp://md5deep.sourceforge.net
.


1)

Use your Windows 2003 server computer to create a folder called
md5deep

under the C: drive.

2)

Download the md5deep
-
3.6.zip from the mainserver computer to your computer and save it in
the md5deep folder.

3)

Navigate to the md5dee
p folder
on your computer
to locate and unzip
(right
-
click/Extract All)
the
md5deep
-
3.6.zip file

to the
C:
\
md5deep

folder.

4)

Navigate to the C:
\
md5deep folder to see the unzipped files that are in a subfolder called
md5deep
-
3.6
. You will notice that there is

a file called MD5DEEP.TXT that explains what is in the
program and how it works. Based on the content of the md5deep
-
3.6 subfolder and
the
explanation in the MD5DEEP.TXT file, name the hash functions
(or programs)
included in
MD5deep.

____________________
___________________________________________________________

5)

Now, open a C
ommand
P
rompt and use the
cd

command to change to the md5deep
-
3.6
subfolder
.

6)

Hashes can be generate
d

from

a

text
string
that you enter at the keyboard as well as from an
existing file
.

7)

Do the following to create
the
hash for

the
abcd

strin
g

a.

Make sure that you have changed to the md5deep
-
3.6
directory

that contains the
md5deep.exe file.

b.

Type
md5deep

and press ENTER

c.

Type
abcd

and simultaneously
press
Ctrl and D. Then, press ENTER

d.

Simulta
neously press Crtl and C to see the hash of
abcd
.

8)

Md5deep hashes are displayed in hexadecimal.
H
exadecimal numbers are written using sets of
two characters (like 6a, 35, 1f, etc).
Count the number of
hexadecimal
characters in the hash. How
long is the has
h of
abcd
?

Answer:

____________ hexadecimal characters.

Convert the length in bits by multiplying your answer by 8:

________ bits

MIS 4850

Systems Security



Lab
3



Cryptography

shoulderslyrical_221c8d18
-
4c7c
-
4c89
-
9e9b
-
95cbb3cff55b.doc







2
/
5

9)

Now, open
Wordpad

(Start/All Programs/Accessories/Wordpad), and create a file that contains
the following sentence:
This is m
y first input file for md5deep.

10)

Save the file
in the md5deep
-
3.6

subfolder under the name md5input1.
rtf

11)

From the command prompt, determine the hash for the file you
just
created by entering
md5deep md5input1.rtf

12)

What is the length of the hash for the md5in
put1.rtf file?
Answer: _____ hexadecimal characters

13)

How does the hash of
abcd

compare

to the hash
of
the md5input1.rtf file in terms of their
length
? Explain

why
.

________________________________________________________________________________
_____________
___________________________________________________________________
________________________________________________________________________________


14)

How does the hash of
abcd

compare

to the hash
of
the md5input1.rtf file in terms of their
content
? Explain

why
.

________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________


15)

Instead o
f displaying them, hashes can be saved in files. From the
C
ommand
P
rompt, type the
following command to save the hash of md5input1.rtf

to

the
hashes.txt file:

md5deep md5input1.rtf > hashes.txt

16)

Now, to compare the hash of md5input1.rtf with hashes of othe
r files in the md5deep
-
3.6
subfolder, type the following command

md5deep

M hashes.txt *.*

17)

Based on the result, what input files have a hash that is exactly the same as the hash saved in
hashes.txt? Answer: _________________________________________________
_______

18)

Star
t

Wordpad

again (if necessary). Edit the md5input1.rtf file and replace the period (.) at the
end of the sentence with an exclamation mark. Then save the file as md5input
2.rtf

in the same
subfolder (md5deep
-
3.6).

19)

Complete

the appropriate steps
to generate the hash for the md5input
2.rtf

file.

20)

Use the following command to compare the hash saved in the hashes.txt file with the hash of any
files in the md5deep
-
3.6 subfolder:

md5deep

M hashes.txt *.*

21)

Based on the result, what input files have a hash

that is exactly the same as the hash saved in
hashes.txt? Answer: ________________________________________________________

22)

Why the md5input
1
.rtf

file is not listed among the files with a hash that is identical to the hash
saved in hashes.txt?

___________
_____________________________________________________________________
________________________________________________________________________________

23)

Leave the C
ommand
P
rompt open for the next activity



Activity 2:
Comparing MD5 and SHA message
-
digest has
hes


Secure Hash Algorythm (SHA) is seen by many cryptographers as more secure that MD5.
It

typically
creates hashes that are 160 bits long instead of
128
bits
for
MD5.


1)

From the C
ommand
P
rompt, take the necessary steps to create
the
hash for
xyz

using md5
deep
(if needed, see step 7 in Activity 1 above for guidance)

shoulderslyrical_221c8d18
-
4c7c
-
4c89
-
9e9b
-
95cbb3cff55b.doc







3
/
5

2)

Do the following to create
the
hash for
xyz

using SHA1deep
:

a.

Make sure that you have changed to the md5deep
-
3.6
directory

that contains the
sha1deep.exe file.

b.

Type
sha1deep

and press ENTER

c.

Type
x
yz

and simultaneously

press

Ctrl and D. Then, press ENTER

d.

Simultaneously press Crtl and C to see the
SHA
hash of
xyz

3)

What is the length of the SHA hash generated?
Answer:

_____ hexadecimal characters
.
Convert
the length in bits by multiplying your answer b
y 8:

________ bits

4)

Compare the hashes for
xyz

generated using MD5 and SHA1. Explain the differences.

________________________________________________________________________________
___________________________________________________________________________
_____
________________________________________________________________________________


Activity 3:
Using HashCalc for hashing


The HashCalc program used in this activity is a free program available at
http:/
/www.slavasoft.com/hashcalc
. You will
use
a copy of the program
available

on the mainserver
computer


1)

Use your Windows 2003 server computer to create a folder called
hashcalc

under the C: drive.

2)

Download the hashcalc.zip from the mainserver computer to yo
ur computer and save it in the
hashcalc folder.

3)

Navigate to the hashcalc folder
on your computer
to locate and unzip (right
-
click/Extract All) the
hashcalc.zip file to the
C:
\
hashcalc

folder.

4)

Navigate to the C:
\
hashcalc folder to locate and run (double
-
cli
ck) the setup.exe program

5)

Follow the instructions to install the program with the default options.

6)

Launch the HashCalc program (Start/All Programs/
HashCalc/HashCalc) to get to the main
interface. It should look like this:























shoulderslyrical_221c8d18
-
4c7c
-
4c89
-
9e9b
-
95cbb3cff55b.doc







4
/
5


7)

Hashcalc is

an easy to use program. Use it to determine the MD5 and the SHA1 hashes of the
abcd

string. Write down the hashes:

MD5 hash: ________________________________________________

SHA1 hash: ________________________________________________

8)

HMAC

(Hash
-
based Mess
age Authentication Code) is used to authenticate messages
by
generating a
M
essage
A
uthentication
C
ode

(MAC)
for the messages. It requires using a
cryptographic hash function

and a
secret
key
. As with any MAC,
HMAC

may be used to
simultaneously verify both
the
data
integrity

and the
authenticity

of a
message
. The cryptographic
strength of the HMAC depends upon the
cryptographic strength

of the underlying hash function,
the size of its hash output


i.e
length




in bits and on the size and quality of the cry
ptographic
key.

9)

Imagine that you received the
md5input1.rtf

file
created in Activity 1 from a friend. The
friend secretly sends you the key for authenticating the received file.
Assume that the key is
student
. T
ake the necessary steps to generate the MD5 m
essage authentication code for the file.
Write down the MAC:

____________________________________________________________
____________




You will be given an
assignment,

in which you will be using the tools you have used in this
assignment
in order
to
auth
enticate software
that
you
will download from the I
nternet.


shoulderslyrical_221c8d18
-
4c7c
-
4c89
-
9e9b
-
95cbb3cff55b.doc







5
/
5

Lab 3
Questions


Student Name:
_______________
_____________________________


Q.1.

You want to verify the authenticity of a software program that is available on the developer’s
web site. Which o
f the following steps should you take? Indicate your answers by placing a checkmark
next to the statements that reflect your answers.



Use a good encryption algorithm like DES and a strong key to generate the ciphertext


Use a good encryption algorithm l
ike Triple
-
DES and a strong key to generate the ciphertext


Use a hash function like MD5 to generate a hash of the downloaded program’s file


Use a hash function like SHA1 to generate a hash of the downloaded program’s file


䍯mp慲攠aU攠捩cU敲瑥x琠gen敲
ated using DES with the hash found on the developer’s website


Compare the program’s MD5 hash sum from the developer’s website with the hash you
g敮敲慴敤⁵獩eg⁡⁍M5⁨慳U⁦畮捴楯n


Compare the program’s SHA1 hash sum from the developer’s website with th
攠Ua獨⁹su
g敮敲慴敤⁵獩eg⁡⁓ 䄱AUa獨⁦sn捴楯n


Q.2
.

You want to use SHA1 to generate a hash for a Microsoft Word file.
Which of the following
you will
need? (Choose all that apply)

a)

The MD5 hash function

b)

a key

c)

The SHA hash function

d)

The Word file


e)

All of
the above


Q.
3
.

Imagine that a 512
-
byte text file is used as input with the MD5 hash function. Which of the
following could be the size of the checksum?

a)

512 bits

b)

256 bytes

c)

128 bits

d)

None of the above


Q.4
.

Imagine that a 512
-
byte text file is used as input
with the SHA1 hash function. Which of the
following could be the size of the checksum?

a)

512 bits

b)

256 bytes

c)

128 bits

d)

None of the above


Q.
5
.

You can generate an MD5 hash using a character string as the input.


T

F


Q.
6
.

You cannot generate a SHA1 hash using
a character string as the input.


T

F


Q.
7
.

You cannot generate a SHA1 hash using a .rtf file as the input.



T

F


Q.
8
.

You cannot generate a SHA1 hash using an executable file as the input.


T

F