Lab 3: Asymmetric Encryption (RSA)

← Back to Week 6

Mission Objectives

Objective 1

Generate Alice's RSA key pair (2048-bit)

In Alice's terminal: openssl genrsa -out alice_private.pem 2048
Objective 2

Extract Alice's public key from her private key

In Alice's terminal: openssl rsa -in alice_private.pem -pubout -out alice_public.pem
Objective 3

Bob creates a message and encrypts it with Alice's public key

In Bob's terminal:
echo "Secret message from Bob" > bob_message.txt
openssl rsautl -encrypt -inkey alice_public.pem -pubin -in bob_message.txt -out encrypted_to_alice.bin
Objective 4

Alice decrypts Bob's message with her private key

In Alice's terminal: openssl rsautl -decrypt -inkey alice_private.pem -in encrypted_to_alice.bin -out decrypted_from_bob.txt
Objective 5

Generate Bob's RSA key pair

In Bob's terminal: openssl genrsa -out bob_private.pem 2048
Objective 6

Extract Bob's public key and Alice encrypts a reply

Bob: openssl rsa -in bob_private.pem -pubout -out bob_public.pem
Alice: echo "Reply from Alice" > alice_reply.txt
Alice: openssl rsautl -encrypt -inkey bob_public.pem -pubin -in alice_reply.txt -out encrypted_to_bob.bin
Objective 7

Bob decrypts Alice's reply with his private key

In Bob's terminal: openssl rsautl -decrypt -inkey bob_private.pem -in encrypted_to_bob.bin -out decrypted_from_alice.txt
Objective 8

Try decrypting with the wrong key to see failure

Try to decrypt Bob's message to Alice using Bob's private key (wrong key!):
openssl rsautl -decrypt -inkey bob_private.pem -in encrypted_to_alice.bin -out wrong.txt
alice@secure-comm:~
Alice's Workstation - Asymmetric Encryption Lab
Generate your RSA key pair to receive encrypted messages from Bob
alice@secure-comm:~$
bob@secure-comm:~
Bob's Workstation - Asymmetric Encryption Lab
Once Alice has her public key, you can encrypt messages to her!
bob@secure-comm:~$

LAB COMPLETE!

You've mastered asymmetric encryption with RSA

+25 XP