Re: CryptVerifySignature fail with message NTE_BAD_SIGNATURE
- From: Mounir IDRASSI <moonidra@xxxxxxxxxxxxxxxxx>
- Date: Sat, 7 Jun 2008 03:44:01 -0700
Hi Vishal,
First, you must know that digital signature is computed using the private
key and its verification is done using the public key. So, I think you are
mixing things here.
Second, when you call CryptSignHash with AT_KEYEXCHANGE on the hash, the CSP
will use the private key to compute the signature of the hash after adding
some padding. Then, in order to verify this signature, you only need to have
the public key which have been exported previously. Once this public key is
imported, its handle is used in CryptVerifySignature to check the validity of
the digital signature. This is done by performing an RSA public
exponentiation on the digital signature, then it will check the padding
correctness of the result and remove it subsequently and at last it will
compare the unpadded result with the given hash. If they are the same, then
the signature is valid, otherwise it's not.
At this point, all the operation you have to perform can be completely done
with an AT_SIGNATURE key as well. The difference between AT_SIGNATURE and
AT_KEYEXCHANGE is that the latest can perform RSA encrypting while the first
can not.
Cheer,
--
Mounir IDRASSI
IDRIX
http://www.idrix.fr
to reach : mounir_idrix_fr (replace the underscores with the at and dot
characters respectively)
"visalavats@xxxxxxxxxxxxx" wrote:
Thanks for the info Mounir,.
I am working on Windows mobile.
I want to create a digital signature for a file from one end(A) and
send the file and signature to the other end(Windows mobile).
The signature should be created using public key
( I am using function CryptGenKey(hProv, AT_KEYEXCHANGE,
0,&hPublicKey);
CryptExportKey(hPublicKey,0,/
*PRIVATEKEYBLOB*/ PUBLICKEYBLOB,0,
baKeyBlob.GetData(),&dwKeyBlobLen) ;
and for signing I am using "CryptSignHash( hHash, AT_KEYEXCHANGE,
NULL, 0, pbSignature, &dwSigLen) ;"
and verifying signing i am using " CryptVerifySignature( hHash,
bSignature, dwSigLen, hPubKey, NULL, 0)"
and functions succeeds.
My question here is: how the private keys used here to verify
signature? because we used hpublic key which is a public key.
Please share your idea i am bit confused how the AT_KEYEXCHANGE
works.
Thanks
Vishal
- Follow-Ups:
- Re: CryptVerifySignature fail with message NTE_BAD_SIGNATURE
- From: visalavats
- Re: CryptVerifySignature fail with message NTE_BAD_SIGNATURE
- From: visalavats
- Re: CryptVerifySignature fail with message NTE_BAD_SIGNATURE
- References:
- CryptVerifySignature fail with message NTE_BAD_SIGNATURE
- From: visalavats
- Re: CryptVerifySignature fail with message NTE_BAD_SIGNATURE
- From: visalavats
- Re: CryptVerifySignature fail with message NTE_BAD_SIGNATURE
- From: visalavats
- CryptVerifySignature fail with message NTE_BAD_SIGNATURE
- Prev by Date: RE: CardRSADecrypt succeeds but CryptDecrypt fails with NTE_BAD_DA
- Next by Date: RE: CardRSADecrypt succeeds but CryptDecrypt fails with NTE_BAD_DA
- Previous by thread: Re: CryptVerifySignature fail with message NTE_BAD_SIGNATURE
- Next by thread: Re: CryptVerifySignature fail with message NTE_BAD_SIGNATURE
- Index(es):
Relevant Pages
|