Proj X11: Using RSA with OpenSSL (20 pts)

What You Need for This Project

Purpose

To practice using RSA to encrypt and decrypt data. This is an important skill for security professionals.

Edward Snowden, the NSA whistleblower, wanted to use RSA encryption to send confidential data to Glen Greenwald, but Greenwald couldn't set it up.

1. Generate a Key Pair

On Kali, in a Terminal, execute these commands:
openssl genrsa -out private_key.pem 2048
openssl rsa -in private_key.pem -out public_key.pem -outform PEM -pubout
ls -l
You see two PEM files, one containing a public key, and one containing a private key, as shown below.

Both of those files are plaintext. To see that, execute these commands:

cat private_key.pem 
cat public_key.pem

Encrypting a Message

Execute these commands to create a file containing your name and encrypt it:
echo "Message from YORNAME" > encrypt.txt
cat encrypt.txt 
openssl rsautl -encrypt -inkey public_key.pem -pubin -in encrypt.txt -out encrypt.dat 
ls -l
file encrypt.dat
An "encrypt.dat" file is created. It's much longer than the plaintext message, and it's a binary file, as shown below.

Decrypting a Message

Execute these commands to decrypt the message and print it out:
openssl rsautl -decrypt -inkey private_key.pem -in encrypt.dat -out new_encrypt.txt 
cat new_encrypt.txt
The message appears, containing your name, as shown below.

Saving a Screen Image

Make sure you can see your name in the decrypted message, as shown above.

Save a full-desktop image. On a Mac, press Shift+Commmand+3. On a PC, press Shift+PrntScrn and paste into Paint.

YOU MUST SUBMIT A FULL-SCREEN IMAGE FOR FULL CREDIT!

Save the image with the filename "YOUR NAME Proj 11x", replacing "YOUR NAME" with your real name.

Turning in your Project

Email the image to to cnit.141@gmail.com with the subject line: Proj 11x from YOUR NAME

X11.2: Challenge: Decrypt This Message (10 pts.)

Here's my private key:
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAsuAyrN//ECDOG1lu+3G3QcAE3tWrquNtpiyg5PYxZB6h56Un
UfkQ+2IlMXpJWk01CUVOyccEO3JSEYa/f3YrZHAEv3suIrNvfOlKQAGAgRfUAuTA
fnKUJuHy95MDX2SGz3IVKxHmY2hME4vWTC5rZHJEyZ7Q2cbySg97Ae3PsSfYKHop
kJ5ylRr5tdjvQ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SgN57KznteUzMwKwVid
HYhEnO4CZyNWey8Bc7lV0UZky9oZLHWCuMj8u8jdXG+efKMoH2nnFc3lt5TrmbTR
QMMstroKwMaDzIZct/m/8wfhZBnDYJT8ZAGOqRRpS9oZ0r9Pa1UTPdSdxVSDyKD/
6Wa7YOkCgYEAuoRrl2HIWHnmY1URF7RPx84qTKMk82IzKW6ApLCtjqQZLJuVe1Hr
ELcC4ecZu2FGpA4puK0evJ+6GCn5Q2Pem+jodpc865GxjNDLHLgSWghg9cs5OH9d
MkRzmDVBpCUGsESgDkif9AQt9IgeBDcoxoqQtlehifgt2hq9huyndJo=
-----END RSA PRIVATE KEY-----
Download this file and decrypt it.

Enter the plaintext into the form below to record your score in Canvas.

Name or Email:
Plaintext:

Sources

Using OpenSSL to encrypt messages and files on Linux
Thanks to @oADAMo for motivating me to write this project.
Posted 1-24-19 by Sam Bowne