openssl genpkey -algorithm RSA -out private_key.pem
.....+..+++++++++++++++++++++++++++++++++++++++*..+++++++++++++++++++++++++++++++++++++++*...............+......+.+.....+......+...+.......+...+...............+..+...................+...+..+.+..................+......+...+.....+...+.............+..+...++++++
.+...+..+++++++++++++++++++++++++++++++++++++++*...........+....+...........+.+.....+...+............+...+......+.+..+.+......+........+...+...+++++++++++++++++++++++++++++++++++++++*........+..+.......+..+....+.....+....+...........+.+.....+.+...+......+...........+.........................+.....+.......+...+.....+....+.....+...+......+....+......+.....+.........++++++
openssl rsa -pubout -in private_key.pem -out public_key.pem
writing RSA key
openssl dgst -sha256 -binary -out hash.bin server/main_feed.txt
openssl pkeyutl -sign -inkey private_key.pem -keyform PEM -in hash.bin -out server/main_feed.sig256
openssl dgst -sha256 -verify public_key.pem -signature server/main_feed.sig256 hash.bin
Verification failure
8066D85CC37F0000:error:02000068:rsa routines:ossl_rsa_verify:bad signature:../crypto/rsa/rsa_sign.c:426:
8066D85CC37F0000:error:1C880004:Provider routines:rsa_verify:RSA lib:../providers/implementations/signature/rsa_sig.c:785:
I’m honestly not even sure why this happens. I did all the commands one after the other trying to generate a key pair and sign a file.
But the verification fails instantly for some reason.
I tried testing this same process with a simpler file generated by echo "This is a test." > test.txt
. It still failed.
I was expecting the verification to succeed. But it does not.
ReDJstone is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.