architecture/docs/workshop/5-snake-oil-crypto/hands-on-support/UsingRSA
Jean-Louis Huynen 94109782df
add: [workshop] more content for SOC
2019-12-06 10:53:00 +01:00
..
README.md add: [workshop] more content for SOC 2019-12-06 10:53:00 +01:00
message.bin add: [workshop] more content for SOC 2019-12-06 10:53:00 +01:00
private.pem add: [workshop] more content for SOC 2019-12-06 10:53:00 +01:00
public.pem add: [workshop] more content for SOC 2019-12-06 10:53:00 +01:00

README.md

Instructions

This directory contains a sample public key public.pem, the corresponding private key private.pem, and a message that has been encrypted with the private key message.bin.

You should be able to decrypt the message using the command-line openssl utility like this:

$openssl rsautl -inkey private.pem -decrypt < message.bin

If you want to see the details of the keys' contents, try:

$openssl rsa -in public.pem -pubin -text -noout
$openssl rsa -in private.pem -text -noout

Note that the output from OpenSSL will be in hexadecimal!

The most fundamental difference between the public and private keys is that the public key includes the modulus n ("modulus"), while the private key also includes the two primes p ("prime1") and q ("prime2") such that p×q = n.

You can generate a new private key using:

$openssl genrsa -aes128 4096 > my key.pem

Then you can create the corresponding public key using:

$openssl rsa -in key.pem -out key-public.pem -pubout -outform PEM 

And finally encrypt a message with this new key using:

$openssl rsautl -encrypt -inkey key-public.pem -pubin -in mymessage.txt -out mymessage.txt.asc