Congrats! You verified that these are the actual lab instructions.
In this part of the lab, you're going to use a CLI tool called openssl
. You used ssh-keygen
and other utilities to create key pairs before, but those are formatted just for SSH. We need openssl for other formats. There are better tools out there, but this one is already installed.
You'll start by replicating what I just did: sending password protected files. First, you'll need a partner. Find someone from across the room.
[from-name]_to_[to-name].txt
with your name first and the name of the recipient second. Alice would write her message to Bob in alice_to_bob.txt
.$ openssl aes-256-cbc -e -in alice_to_bob.txt -out alice_to_bob.enc.txt
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
$ openssl aes-256-cbc -d -in alice_to_bob.enc.txt -out alice_to_bob.dec.txt
The hardest part was getting the password to the other person, right? Symmetric encryption is perfect when you can keep the password or keyfile all to yourself, but not when you're trying to communicate with someone. So try that again but using a public/private keypair this time.
You'll use openssl to generate keys. Do NOT use the public/private keys you've already created for SSH. You'll create new temporary keys just for the purpose of this exercise, then you'll delete them. Add your name to the file so we know who it belongs to.
$ openssl genpkey -algorithm RSA -out name_private.pem -pkeyopt rsa_keygen_bits:2048
.........................................+++
...............................+++
$ openssl rsa -pubout -in name_private.pem -out name_public.pem
writing RSA key
-----BEGIN PUBLIC KEY-----
-----BEGIN PRIVATE KEY-----
Go find your partner's public key on Slack and download it. You'll use it to encrypt your message. In this command, Alice is using Bob's public key to encrypt her message:
$ openssl rsautl -encrypt -inkey bob_public.pem -pubin -in alice_to_bob.txt -out alice_to_bob.asym_enc.txt
Send the encrypted file over Slack for your partner to decrypt. Here, Bob is using his private key to decrypt Alice's message and store the result in a file:
$ openssl rsautl -decrypt -inkey bob_private.pem -in alice_to_bob.asym_enc.txt -out alice_to_bob.asym_dec.txt
Crypto has come a long way in the last few years, it's not just for developers. Many apps come with end-to-end encryption out of the box like Signal for secure text messaging. You can also use a key server like Keybase to store your keys, publicly verify them, and allow all sorts of encrypted communications. The HackBlossom cybersecurity guide has a whole list of other tools and practices you can look into.
Organizations like the Electronic Frontier Foundation have put together a ton of guides to help keep you secure. They also have a deep dive on how public key encryption works to help you understand this lab better.