CryptAcquireContext and GINA

From: Sergio G. (sgmartin_at_digi-sign-p.com)
Date: 09/30/05


Date: Fri, 30 Sep 2005 12:29:58 +0200

Hi all,

I'm writting a custom GINA wich allows a user to unlock his computer
verifying the PIN of a SmartCard.

For getting this to work I call CryptAcquireContext passing the CSP name and
type, with no container name and with CRYPT_SILENT flags.

CryptAcquireContext(
 &hCryptProv,
 NULL,
 CSPname,
 CSP_TYPE,
 CRYPT_SILENT )

I use CRYPT_SILENT because I do not want the CSP to show its custom dialog
to ask for the pin.

Then I call CryptSetProvParam passing the user PIN to check it, and
CryptReleaseContext to finish.

CryptSetProvParam(
 hCryptProv,
 PP_SIGNATURE_PIN,
 userPIN,
 0)

This code works ok when ran outside the GINA, but fails when ran on it,
getting NTE_BAD_KEYSET error in CryptAcquireContext. I guess this is a
container access problem so I have added CRYPT_VERIFYCONTEXT flag to the
call to CryptAcquireContext, but the error remains the same.

Any ideas of what might be happening?
Also, does any know a better way to check the PIN of a smart card?

Thanks in advance,
Sergio.



Relevant Pages

  • Re: P7M with Crypto Api
    ... You should take a look in MSDN at the CAPI functions CryptMsgXXX (e.g. ... display your own dialog asking for the PIN and submit it ... files using only Crypto Api (I used CryptAcquireContext once and then ... So i think that with Crypto Api it is possible to "store" ...
    (microsoft.public.platformsdk.security)
  • Smart Card PIN verification
    ... I was wordering if there is any way to check the PIN of a Smart Card ... different from calling SetProvParam after CryptAcquireContext. ...
    (microsoft.public.platformsdk.security)