diff --git a/Lab 2 - Certificates/README.md b/Lab 2 - Certificates/README.md index 0da053d..a2713a8 100644 --- a/Lab 2 - Certificates/README.md +++ b/Lab 2 - Certificates/README.md @@ -299,3 +299,27 @@ Check the output: ```sh openssl x509 -in intermediate.cer -noout -text ``` + +# Signing Data +Create a file with secret content: +```sh +cd /root +vi secret.txt +``` + +## Create Signature +```sh +# Create and encrypt hash of file +openssl dgst -sha256 -sign /root/ca/private/ca.key.pem -out /tmp/hash.sha256 secret.txt +# Convert hash file to base64 +openssl base64 -in /tmp/hash.sha256 -out secret.sig +``` + +## Verify Signature +Under normal circumstances: +```sh +# Re-create hash file from base64 +openssl base64 -d -in secret.sig -out /tmp/hash.sha256 +# Check integrity of `secret.txt` +openssl dgst -sha256 -verify /root/ca/ca.key.pem.pub -signature /tmp/hash.sha256 secret.txt +```