0% found this document useful (0 votes)
68 views5 pages

NIS 17 Cryptolab

This document provides instructions for encrypting and decrypting data using OpenSSL. It describes using OpenSSL to encrypt a sample text file containing a letter and then decrypting the encrypted file. Specifically, it details how to: 1. Encrypt the sample text file into an encrypted file called "grandma.enc" using AES-256 encryption with a password. 2. Display the encrypted contents, which appears scrambled, and then re-encode the encrypted data into a file called "grandma1.enc" using Base64 encoding. 3. Decrypt both encrypted files back into readable text files using OpenSSL and the original password.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views5 pages

NIS 17 Cryptolab

This document provides instructions for encrypting and decrypting data using OpenSSL. It describes using OpenSSL to encrypt a sample text file containing a letter and then decrypting the encrypted file. Specifically, it details how to: 1. Encrypt the sample text file into an encrypted file called "grandma.enc" using AES-256 encryption with a password. 2. Display the encrypted contents, which appears scrambled, and then re-encode the encrypted data into a file called "grandma1.enc" using Base64 encoding. 3. Decrypt both encrypted files back into readable text files using OpenSSL and the original password.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

NIS 17, AITI-KACE

JUNE, 2023
Lab – Encrypting and Decrypting Data Using OpenSSL
Objectives
 Part 1: Encrypting Messages with OpenSSL
 Part 2: Decrypting Messages with OpenSSL
Background / Scenario
OpenSSL is an open-source project that provides a robust, commercial-grade, and full-
featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL)
protocols. It is also a general-purpose cryptography library. In this lab, you will use OpenSSL
to encrypt and decrypt text messages.
Note: While OpenSSL is the de facto cryptography library today, the use presented in this lab
is NOT recommended for robust protection. Below are two security problems with this lab:
1. The method described in this lab uses a weak key derivation function. The ONLY
security is introduced by a very strong password.
2. The method described in this lab does not guarantee the integrity of the text file.
This lab should be used for instructional purposes only. The methods presented here should
NOT be used to secure truly sensitive data.
Required Resources
 Kali Linux virtual machine
Instructions
Part 1: Encrypting Messages with OpenSSL
OpenSSL can be used as a standalone tool for encryption. While many encryption algorithms
can be used, this lab focuses on AES. To use AES to encrypt a text file directly from the
command line using OpenSSL, follow the steps below:
Step 1: Encrypting a Text File
a. Log into your kali Linux VM.
b. Open a terminal window.
c. Make a directory in Desktop/projects and put the text file to be encrypted in that
directory create a file called letter_to_grandma.txt and copy the following text into it:
Hi Grandma,
I am writing this letter to thank you for the chocolate chip cookies you sent me. I got them
this morning and I have already eaten half of the box! They are absolutely delicious!
I wish you all the best. Love,
Your cookie-eater grandchild.
Screenshot:

d. Display the contents of letter_to_grandma.txt text file on the screen:


Screenshot:
e. From the same terminal window, issue the appropriate command to encrypt the text file
with a key-length of 2048. The command will use AES-256 to encrypt the text file and save
the encrypted version as grandma.enc. OpenSSL will ask for a password and for password
confirmation. Provide the password as requested and be sure to remember the password.
Screenshot:

f. When the process is finished, use the appropriate command again to display the contents
of the grandma.enc file.
Screenshot:

Did the contents of the grandma.enc file display correctly? What does it look like? Explain.
Ans: From the above diagram, the message didn’t display because it has been encrypted
with a key or password. The message will be displayed when the right key or password has
been give out to the receiver.
g. To make the file readable, run the OpenSSL command again, but this time add the -
a option before the -in but change the -out file name to grandma1.enc. The -a option tells
OpenSSL to encode the encrypted message using a different encoding method of Base64
before storing the results in a file.
Note: Base64 is a group of similar binary-to-text encoding schemes used to represent binary
data in an ASCII string format.
Screenshot:
h. Once again, use the appropriate command to display the contents of the, now re-
generated, grandma.enc file:
Note: The contents of grandma.enc and grandma1.enc will vary.
Screenshot:

Part 2: Decrypting Messages with OpenSSL


With a similar OpenSSL command, it is possible to decrypt grandma.enc without the -a
option and grandma1.enc but use -a in addition to the -d option.
Screenshot:

b. OpenSSL will ask for the password used to encrypt the file. Enter the same password
again.
Screenshot:
c. When OpenSSL finishes decrypting the grandma.enc and grandma1.enc file, it saves the
decrypted message in a text file. Use the cat display the contents:
Screenshot:

You might also like