Signing and Verifying
“https://pagefault.blog/2019/04/22/how-to-sign-and-verify-using-openssl/”
Steps to Create a Signature
-
Generate a Private Key:
Bash
# Generate 4096-bit RSA private key and extract public key openssl genrsa -out key.pem 4096This creates a 2048-bit RSA private key and stores it in the file
private.key. -
Generate a Public Key:
Bash
openssl rsa -in key.pem -pubout > key.pubThis extracts the corresponding public key from your private key and stores it in
public.key. -
Create signature:
Bash
openssl dgst -sign key.pem -keyform PEM -sha256 -out data.zip.sign -binary data.zipThis generates a hash and then signs it using the private key
-
verify signature:
Bash
openssl dgst -verify key.pub -keyform PEM -sha256 -signature data.zip.sign -binary data.zip Verified OK