Re: CryptVerifySignature fail with message NTE_BAD_SIGNATURE



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

.



Relevant Pages

  • Re: CryptVerifySignature fail with message NTE_BAD_SIGNATURE
    ... you must know that digital signature is computed using the private ... key and its verification is done using the public key. ...
    (microsoft.public.platformsdk.security)
  • Re: Soft signatures
    ... now, digital signature, typically just represents that you (in ... For some time there were arguments that if a certificate contained the ... certificate with your public key and the non-repudiation flag in it. ... for a number of different business purposes. ...
    (sci.crypt)
  • Re: Design choice in LTC
    ... The bytes cannot be a valid signature for any public key. ... -- Failure type 1 is obtained when the signature is too small to harbour ...
    (sci.crypt)
  • Re: PGPsigs: the Choice of Con Artists
    ... They can insist whatever they want to insist but if I trust none of them ... You seem to have two problems: one is that you don't like the PGP signature ... signature or break public key encryption. ...
    (comp.os.linux.misc)
  • [PATCH 5/6] MODSIGN: Module signature checker and key manager
    ... given a signature and crypto_hash of the data that was signed. ... new file mode 100644 ... * GNU General Public License for more details. ... * handle a public key element parsed from the keyring blob ...
    (Linux-Kernel)