Skip to content

Latest commit

 

History

History
99 lines (62 loc) · 1.67 KB

File metadata and controls

99 lines (62 loc) · 1.67 KB

TLS Certificates 101 Workshop

Part 3: Key Usage


Encrypt and Decrypt a Message


Create a message

$ echo "Hello World" > message.txt

Symetric Encryption & Decryption / ist das wirklioch symmetrisch?

Encrypt the message using the Private Key

$ openssl pkeyutl -encrypt -inkey private.pem -in message.txt -out message.sym-enc

Decrypt the message using the Private Key

$ openssl pkeyutl -decrypt -inkey private.pem -in message.sym-enc

Asymetric Encryption & Decryption

Encrypt the message using the Public Key.

$ openssl pkeyutl -encrypt -inkey public.pem -pubin -in message.txt -out message.asym-enc

Decrypt the message using the Private Key

$ openssl pkeyutl -decrypt -inkey private.pem -in message.asym-enc

Sign and Verify a Message


Signing

Sign the message using the Private Key.

$ openssl dgst -sha256 -sign private.pem -out message.sig message.txt

Verification

Verify the message signature using the Public Key.

$ openssl dgst -verify public.pem -signature message.sig message.txt
Verified OK

Tamper with the message

Modify the message.

$ echo "!" >> message.txt

Detect Tampering

Verify the message again using the Public Key.

$ openssl dgst -verify public.pem -signature message.sig message.txt
Verification Failure

Finished!

This was the third part of the workshop.

You should now have learned how to use cryptographic keys for encryption, decryption, signing, and verification.

To continue with the workshop, please proceed to the next part: Certificates