P
P
Pegas123452020-01-28 11:32:18
OpenSSL
Pegas12345, 2020-01-28 11:32:18

Openssl and Base64 what's wrong?

Hello. Help with a question.

You need to hash and sign the string.
Here is an example that works fine:

echo "TesTIK" | openssl dgst -sha256 -sign openssl/private.key > sign.sig
openssl dgst -verify openssl/public.key -sha256 -signature sign.sig -binary <<< "TesTIK"


result: Verified OK

But the task is this, you need this file first in base64, and then from base64 back and check the signature. I do it like this:

echo "TesTIK" | openssl dgst -sha256 -sign openssl/private.key > sign.sig
base64 sign.sig > base64.txt
base64 -d base64.txt > decoded.sig
openssl dgst -verify openssl/public.key -sha256 -signature sign.sig -binary decoded.sig


But there is already an error: Verification Failure

Where and what is wrong?

Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HPFV, 2020-03-30
@HPFV

Maybe it's too late (I'm looking for answers on this topic myself now), but the thing is that in the first case you correctly check the signature through the source with the public key ("Testik" string), and in the second you try to check the signature through the signature, but you need to the same check through the source (the same string "Testik").

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question