OpenSSH Signing a File and appending to Signing to File + Verification
Submitted by admin on
Create the signing keys
openssl req -nodes -x509 -sha256 -newkey rsa:4096 -keyout "signing.key" \
-out "signingKey.crt" -days 365 -subj "/C=NL/ST=QC CA/L=Montreal/O=PacificSimplicity \
/OU=Dev/CN=Dev Signing Key"
-out "signingKey.crt" -days 365 -subj "/C=NL/ST=QC CA/L=Montreal/O=PacificSimplicity \
/OU=Dev/CN=Dev Signing Key"
Then sign the file with the following command
openssl dgst -sha256 -sign "signing.key" -out <outputSigned>.sha256 \
<inputFile>; cat <inputFile> <outputSigned>.sha256 > <outputSigned>.appended
<inputFile>; cat <inputFile> <outputSigned>.sha256 > <outputSigned>.appended
To verify the file, execute the following command
openssl dgst -sha256 -verify <(openssl x509 -in "../keys/signingKey.crt" \
-pubkey -noout) -signature <outputSigned>.sha256 <(head -c -512 <outputSigned>.appended)
-pubkey -noout) -signature <outputSigned>.sha256 <(head -c -512 <outputSigned>.appended)
If the contents have not changed, the output will output:
Verified OK
If the validation failed, the file doesn't match the signed value then the file is corrupt or modified/tampered.
Verification Failure
Comments
Hi! I could have sworn I've
Submitted by Aretha (not verified) on
Add new comment