The signature different in C# and C++ CRYPTOAPI

N

no game

I have a problem with signature using RSACryptoServiceProvider


I use

signature=privKey.SignData(byteData, new MD5CryptoServiceProvide),

and get a byte array of signature.

The other party use CryptoAPI C++ function:
//create the hash object
CryptCreateHash(
Provider,
CALG_MD5,
0,
0,
&Hash)

//add the data to be signed to the hash
CryptHashData(
Hash,
(LPBYTE)(LPCTSTR)byData,
sSignatureData.GetLength(),
0)

//sign the hash data
//two steps, first step is to get the length
//so we know how big to allocate the output buffer
CryptSignHash(
Hash,
dwKeySpec,
NULL,
0,
NULL,
&dwSignLength
)
CryptSignHash(
Hash,
dwKeySpec,
NULL,
0,
(LPBYTE)(LPCTSTR)sSignature,
&dwSignLength
)


Now they got a signature is different from what I got, and we are using
the same pair of public and private certificate and .pfx file, is there
other people have the same problem? Is there any solution to this
problem?

Thanks
 
N

no game

I got answer for myself.

The signature result is the same, except C# and C++ give result in
reverse order.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top