Hi!
I'm new to crypto++ and crypto stuff in general.. I have an RSA public key
and a signature (in hex) generated in crypto++. I need to verify the
signature using openssl dgst which fails at the moment. In the following
example, crypto_hello_sig.bin is the signature, in binary format of "hello,
world!". Using openssl rsautl I get the following output:
D:\OpenSSL\bin>openssl rsautl -in c:\crypto_hello_sig.bin -verify -inkey
c:\cryp
to_pub.pem -pubin -asn1parse
Loading 'screen' into random state - done
0:d=0 hl=2 l= 33 cons: SEQUENCE
2:d=1 hl=2 l= 9 cons: SEQUENCE
4:d=2 hl=2 l= 5 prim: OBJECT :sha1
11:d=2 hl=2 l= 0 prim: NULL
13:d=1 hl=2 l= 20 prim: OCTET STRING
0000 - e9 1b a0 97 2b 90 55 18-7f a2 ef a8 b5 c1 56 f4
...+.U.......V.
0010 - 87 a8 29 3a ..):
In signatures created by openssl dgst, the OCTET STRING is the hashed value,
i.e., the last two lines should read:
0000 - d2 16 16 92 d6 ca a7 63-96 0c 13 11 cc c7 eb 43
......c.......C
0010 - 48 30 1e fe
H0..
The following is the crypto++ code that creates the signature:
void CRSACipher::sign(const string &message, string &signature) throw
(EncryptionError)
{
try
{
StringSource privString(m_strPrivateKey, true, new
HexDecoder);
RSASSA_PKCS1v15_SHA_Signer signer(privString);
AutoSeededRandomPool rng;
//RandomPool rng;
signature = "";
StringSource (message,
true,
new SignerFilter(rng, signer, new
HexEncoder(new StringSink(signature))));
}
catch (CryptoPP::Exception &excp)
{
throw EncryptionError(excp.what());
}
}
My questions are:
a. Is the signature code correct?
b. Are the last two lines in the asn1 dump simply the hashed value of the
signed text?
c. Does anyone have any suggestions regarding how to proceed?
thanks very much for your help,
Eleanor