Developing Basic Cryptography Lab Modules With Open SSL
Developing Basic Cryptography Lab Modules With Open SSL
OPEN SSL
Page 12.490.1
While there has been a recent proliferation of quality cryptography texts, there remains a
shortage of quality applied laboratory exercises and related support materials. In part, this
is due to the cost and availability of commercial cryptographic software. In part, this is
due to the time and resource commitment required to develop laboratory modules.
Utilization of free open source software can help offset related monetary costs. While
there are many open source cryptographic tools, not all tools are appropriate for “hands-
on” learning activities. For example, our lab modules are designed to make cryptographic
processes visible to students; while, tools like PGP and GPG are designed to make
cryptographic processes transparent to users.
This paper presents the author’s experiences developing and utilizing applied
cryptographic lab modules. The primary cryptographic software utilized, in these
modules, is OpenSSL. This is an Open Source tool kit available for both Linux and
Windows. In addition to OpenSSL, the modules utilize a variety of other open source
tools including Ethereal (WireShark), net cat, Firefox, and Apache.
Because the objectives are curriculum dependent, it would be helpful to review the
curriculum within which our cryptography course evolved.
The scope of the applied cryptography class includes cryptographic services required to
securely store and transmit confidential information. It also includes related
cryptographic services such as those that provide integrity, authentication, and
nonrepudiation. Specific topic areas include: symmetric and asymmetric cryptography,
digital fingerprints, message authentication codes, digital signatures, certificates, public
key infrastructure, and virtual private networks (VPNs). Laboratory activities that enable
students to apply related cryptographic principles augment conventional class activities.
When presented to the students, these module goals are accompanied by an overview.
Let’s look at the overview.
Cryptography Overview
As cryptography evolved, it’s definition also evolved. Originally, cryptography’s
definition was derived from its literal meaning, that is, from the original Greek, as “secret
writing”.
Over time, as cryptography continued to evolve, the definition broadened. For example, ,
the National Institute for Standard and Technology (NIST) now defines cryptography as
“… a branch of mathematics that is based on the transformation of data and can be used
to provide several security services: confidentiality, data integrity, authentication,
Page 12.490.3
For example, in a hybrid system symmetric cryptography is used for bulk encryption
while asymmetric cryptography is used for key exchange and temporary session key
encryption. Understanding both asymmetric and symmetric technologies as well as how
they combine into a hybrid system can provide a foundation for a variety of security
technologies and protocols including Secure Session Layer (SSL), Public Key
Infrastructure (PKI), and Virtual Private Networks (VPNs). As Figure 1-1 shows,
symmetric, asymmetric, and one way functions provide a foundation from which learning
modules that include Basic Protocol Building Blocks, Applied Protocols, and Secure
Protocol Applications can evolve [1].
Page 12.490.4
Figure 1-1 Crypto Basics
Our lab modules provide students with “Hands-on” experience with cryptographic
services. In these modules, students apply symmetric, asymmetric, and hybrid
technologies as well as one way functions. Lab activities focus on four cryptographic
security services and their related mechanisms. Table 1-1 shows these services and
mechanism.
Specific security services are obtained through the application of specific cryptographic
mechanisms. These mechanisms may employ symmetric or asymmetric technologies.
Page 12.490.5
They may also combine into a hybrid system. As the modules progress, students gain
experience with specific security services and mechanisms. Students employ these
technologies and mechanisms to provide confidentiality, integrity, authenticity, and non-
repudiation security services.
Lab Modules
Related laboratory activities were developed in modules. Each module has its own
objectives and procedures. Figure 1-1 presents a context of how additional modules, after
Crypto Basics, might evolve.
The next section presents several modules that we have developed and successfully
utilized.
Module Examples
Part Zero – Introduction
Objectives
At the end of this module, you will be able to:
• Access and use OpenSSL from the command line.
• Access OpenSSL help (man) pages from the command line.
• Locate and access online sources of OpenSSL documentation.
• Download related cryptographic standards from the National Institute for Standards
and Technology (NIST).
Procedure
This module introduces you to the OpenSSL Cryptographic Toolkit. Here, you will
access relevant help (man) pages and learn to work with OpenSSL from the command
line. You will also learn to identify relevant Internet based information sources. At the
end of the lab, you will download, and read, the “Security Requirements for
Cryptographic Modules” standard from the National Institute for Standards and
Technology (NIST) [2].
After you have read the general man pages exit from them. You may exit from the Man
Page 12.490.6
Pages by either pressing the q key or pressing both the ctrl and the z keys.
In later activities, you will be using the enc command. Now, is a good time to become
familiar with this command. To learn more about the encrypt command type:
man enc
Now, lets look a little closer at OpenSSL. While you have the manual pages showing in
one console window, open another console window. At the prompt in the new console
window, type the following commands: (Note: be sure to press return at the end of each
command.)
openssl version
openssl list-standard-commands
openssl list-message-digest-commands
openssl list-cipher-commands
Open a navigator window and browse to the OpenSSL web site. In the browser’s URL
text box, type:
www.OpenSSL.org
Check the available documentation. Also check for other sources of OpenSSL
information such as forums and mailing lists.
http://csrc.nist.gov/publications/fips/
Download and save FIPS 140-2, the “Requirements for Cryptographic Modules”. If you
don’t have permanent storage available at your workstation, use a web based service to
email the pdf file to yourself.
Before proceeding to Part One, you should check the end of lab questions to make sure
that you can answer them. You will also want to save relevant screen shots for your
online lab narrative.
Objectives
At the end of this module, you will be able to:
Page 12.490.7
During this step, you will generate a 56 bit DES key. Then, you will use that DES key to
encrypt and decrypt an ASCII text file. After that, you will employ an MD5 hash to
demonstrate that the unencrypted file is identical to the original text file.
For this lab module, we will use the IETF’s RFC3766 as our text file. To obtain the file,
launch your browser and go to the rfc editor site at the below listed URL. Once you are at
the web site, locate rfc3766.
ftp://ftp.rfc-editor.org/in-notes/
Note One
Accept the default download directory. This will be your home directory. Since you are
user Knoppix, your home directory is also named “Knoppix”.
Note Two
Be sure to change the download file name to rfc3766XX where XX are your initials.
Note Three
Accept the default file type (rfc3766XX.txt). Note that while Linux does not require file
types, we will use them here to distinguish among several versions of this file.
Now, open a console window. Automatically, you will be placed in your default home
directory. Since, by default, you are user Knoppix, this will be the Knoppix directory.
When you list the files in your home directory, you should see the RFC that you
Page 12.490.8
previously downloaded.
ls -al
While you are in your home directory, create a file containing a pseudo random number
56 bits long. Later, you will use that number as your DES key. In an open console
window, enter:
To make sure that the encryption operation worked, list the encrypted file.
cat rfc3766XX.enc
Now to provide assurance that the process works both ways, you should decrypt the .enc
file that you just created. After you decript the file, go ahead and list it on your console.
You would expect the file rfc3766XX.dec to be identical to the file that you downloaded
rfc3766XX.txt. Since identical files will have identical message digests, you can prove
that the files are identical by creating and comparing each file’s message digest. Enter the
following command lines. Then, compare the generated digests (hashes).
Part One A-- Symmetric Key and File Exchange, Symmetric Decryption
Objectives
At the end of this module, you will be able to:
• Use Apache to distribute an encrypted document.
• Use the Net Cat Utility to distribute your DES Key.
• Use the Ethereal (WireShark) Packet Analyzer to capture packets.
• Demonstrate file integrity through the creation of file hashes.
Page 12.490.9
For this lab module, you will exchange encrypted files and DES keys with your lab
partner. Your encrypted file will be distributed through port 80 on the web. Your DES
key will be distributed through Net Cat using whatever port your select.
After the exchange, you will have two different encrypted files, yours and your partners.
You will also have two different DES keys, yours and your partners. Consequently, you
will need to be very careful to keep the names of the files and keys organized. In order to
succeed in this module, you will also need to have good communications with your lab
partner.
To ascertain the security of each communications channel, you will employ the Ethereal
(WireShark) packet analyzer. With this tool, you will capture each TCP stream. After you
have captured the appropriate packets, you will emulate an intruder and attempt to
reassemble the original files from the captured packets.
Prior to beginning the lab, you must exchange IP addresses with your lab partner. You
can determine your IP address by opening a console window and typing:
ifconfig
Since you will be using your web server to exchange the encrypted file with your lab
partner, you now need to move your encrypted file from your home directory to your web
server’s root directory.
To do this first, from the KDE menu, select KNOPPIX, from there, select root shell. This
will open a shell with root privileges. Once that shell is open, copy the encrypted file
from your home directory to your web server’s default directory.
cp rfc3766XX.enc /var/www/rfc3766XX.enc
su
apache start
To make sure that your web server is running, start Netscape Navigator. Place 127.0.0.1
in the browser’s address box and press the Return Key. At this point, you should see the
default Apache homepage in your Navigator Window.
You will now need to edit the web server’s default home page. For this operation, use the
Kwrite editor. You will need superuser privileges to edit the default home page. Open a
console window, type:
su
kwrite
Page 12.490.10
… use the File Open Menu selection to open the “index.html” file. You will find this file
in the /var/www directory.
Now, in the open kwrite session, edit the index.html. First, delete everything in the file
after the first <body> tag and prior to the list of links (<ul> tag> at the page bottom.
Then, edit the first link in the list to point to the encrypted file.
<A HREF="rfc3766XX.enc">
>RFC3766</A>
</A>
After you have deleted the unneeded portions of the original “index.html” file and added
the link to your encrypted file, save the index file. Use the default file name. Use the
default directory. (Note, if you are using super user privileges and still have problems
saving the index.html file simply save the file under a different name
You should further customize the default home page. At a minimum, you should add
your name in a level 1 header at the top of the page. This will provide you lab partner
with assurance when they go to your page to download your encrypted file. You should
also add other relevant information.
<h1>Uno Kitty</h1>
Now, have your partner navigate to your web server with their browser. They can do that
by entering your IP address in the address box of their web browser. Once there, they
should download the rfc that you encrypted to their machine.
Now, you will use NetCat to create a connection between your and your lab partner’s
computers. This connection will facilitate your key exchange.
During this exchange, the partner that is furnishing the key will be the server. The partner
that is receiving the key will be the client. Prior to starting this step, begin capturing
packets with Ethereal. You will find it useful to employ a display or a capture filter that
limits the display or capture to your partner’s IP address. You will also find it useful to
have Ethereal update the list of packets in real time.
After the Ethereal Interface opens, first choose “Captures” pull down menu. Then, choose
the Options choice. Select the appropriate check box to select the “Display packets in real
time” option. On a busy network, you may also want to set the display filter to only
display packets from your lab partner.
Now, each lab partner needs to set up their NetCat Server. Part of the set up is the
selection of an upper level port with which to open communications. You will need to
Page 12.490.11
select a unique port and to communicate that port number with your lab partner. It is
important to communicate the appropriate port number to your lab partner. Before
proceeding, please coordinate with your lab partner and fill out the following table.
XXXX is the number of the port that you will be opening for your server. Be sure to
choose a higher level (over 1024) port. And be sure to let your lab partner know which
port you have chosen.
Where aaa.bbb.ccc.ddd is the ip address of your partner’s server and YYYY are the upper
level ports that your lab partner has opened on their NetCat server.
You should now exchange keys with your partner. That is, your partner should send their
key to you and you should send your key to your partner. If you have chosen Ethereal’s
“View packets in real time” option, you should see the TCP connection in Ethereal’s
capture packet window. After the key exchange is complete, press Ctrl-C to break the net
cat connection.
At this point, you should stop your packet capture and save the file as part 1A. This
packet capture will contain the passwords. At the end of the lab, you should see if you
can recover the key from the packets. Hint, you may have to choose binary file type to
save the key. What does this experience tell you about the security of conventional
network connections?
Now, make sure that you have captured your partner’s key. Note, if you see a file with
the appropriate name but a file size of zero, then your key exchange failed and you need
to repeat the process.
ls -al
Now, that you have evidence that the file transfer was successful, use your lab partner’s
key to decrypt the encrypted rfc that you downloaded from your lab partner’s web site.
Conclusion
To understand cryptographic basics, a student needs to have a first hand knowledge of
basic cryptographic activities and services. These activities include generating random
numbers as well as generating and applying symmetric keys and asymmetric key pairs.
Basic services include confidentiality and integrity. Services covered by other modules
include authentication and nonrepudiation.
Antidotal student response to the lab modules has been enthusiastic. The fact that the
labs are open source and LiveCD based means that the students can repeat and verify
their lab work at their home or at their work. It also means that the students can freely
distribute the software utilized within the modules. An unintended side effect is that other
professors have adopted existing lab modules into other classes.
There is however much further work to be done. One task would be to create a custom
LiveCd that would contain lab modules and associated class materials. Another task
would be to create more modules that would extend the lab’s scope. At present, we have
lab modules for all of the Basic Topics in Figure 1-1. We also have modules that contain
a subset of the Protocol Building Blocks.
In our class, the students also create their own projects. Several students have extended
the class activities to demonstrate other software such as TrueCrypt. As the class evolves,
our anticipation is that it the utilization of Open Source Software will contribute to the
class becoming more project orientated.
Bibliographic Information
1. Dark, M, Morales, L, Justice, C, A Methodology for Developing and Disseminating Curriculum
Resource material in Information Security, CISSE 2005.
2. FIPS PUB 140-2: Security Requirements for Cryptographic Modules, National Institute of Standards
and Technology, May 25 2001
7. Tjaden, B, Fundamentals of Secure Computer Systems, Franklin, Beedle & Associates, Inc., 2004.
8. Viega,J,Messier,M, Chandra, P,Network Security with OpenSSL Cryptography for Secure
Communications, O'Reilly, 2002.
Page 12.490.14