CPSignHash error 80090008

From: iandoll (iandoll_at_yahoo.com)
Date: 12/20/04


Date: 20 Dec 2004 05:10:26 -0800

Hello all,

I have certificate and I have set him my CSP ( by setting
CERT_KEY_PROV_INFO),
so my CSP is called when I am using that certificate in IE (2SSL
communication).
In CSP I have implemented all functions to be wrappers to default CSP.
When I access web server using my certificate, next functions are
called
in this order :

1. CPAcquireContext
2. CPCreateHash
3. CPSetHashParam
4. CPSignHash
5. CPDestroyHash
6. CPReleaseContext

Everything is fine till CPSignHash is called by browser.
Function CPSignHash return error code 80090008 (Invalid algorithm
specified)
During the debug I have seen that CPCreateHash is called with
CALG_SSL3_SHAMD5
(0x00008008) as algorithm, I have forwarded all parameters to default
CSP.
Do I need to set any additional parameter in any of this functions to
make it
work correctly.

Code snippet is below the message.

Thanks in advance,
Ian

BOOL WINAPI
CPAcquireContext(
OUT HCRYPTPROV *phProv,
IN LPCSTR szContainer,
IN DWORD dwFlags,
IN PVTableProvStruc pVTable)
{
MessageBox(NULL, "CPAcquireContext", "DEBUG", MB_OK);

BOOL retVal = CryptAcquireContext(phProv, NULL, NULL, PROV_RSA_FULL,
dwFlags);
if (!retVal) { ERROR_MSGBOX("CPAcquireContext-ERROR");}
return retVal;
}

BOOL WINAPI
CPCreateHash(
IN HCRYPTPROV hProv,
IN ALG_ID Algid,
IN HCRYPTKEY hKey,
IN DWORD dwFlags,
OUT HCRYPTHASH *phHash)
{
MessageBox(NULL, "CPCreateHash", "DEBUG", MB_OK);

BOOL retVal = CryptCreateHash(hProv, Algid, hKey, NULL, phHash);
if (!retVal) { ERROR_MSGBOX( "CPCreateHash-ERROR");}
return retVal;
}

BOOL WINAPI
CPSetHashParam(
IN HCRYPTPROV hProv,
IN HCRYPTHASH hHash,
IN DWORD dwParam,
IN CONST BYTE *pbData,
IN DWORD dwFlags)
{
MessageBox(NULL, "CPSetHashParam", "DEBUG", MB_OK);

BOOL retVal = CryptSetHashParam(hHash, dwParam, pbData, NULL);
if (!retVal) {MessageBox(NULL, "CPSetHashParam-ERROR", "DEBUG",
MB_OK);}
return retVal;
}

BOOL WINAPI
CPSignHash(
IN HCRYPTPROV hProv,
IN HCRYPTHASH hHash,
IN DWORD dwKeySpec,
IN LPCWSTR szDescription,
IN DWORD dwFlags,
OUT LPBYTE pbSignature,
IN OUT LPDWORD pcbSigLen)
{
MessageBox(NULL, "CPSignHash", "DEBUG", MB_OK);

BOOL retVal = CryptSignHash(hHash, dwKeySpec, NULL, dwFlags,
pbSignature, pcbSigLen);
if (!retVal) { ERROR_MSGBOX("CPSignHash-ERROR");}
 return retVal;
}



Relevant Pages

  • RE: CPSignHash error 80090008
    ... > so my CSP is called when I am using that certificate in IE (2SSL ... > BOOL WINAPI ... > OUT HCRYPTPROV *phProv, ... > IN DWORD dwFlags, ...
    (microsoft.public.platformsdk.security)
  • cpEncrypt
    ... i want to write my own CSP. ... IN HCRYPTPROV hProv, ... CpEncrypt function using CryptEncryption which is in the wincrypt.h. ... understanding whether CpEncrypt function encrypt or do not encrypt. ...
    (microsoft.public.platformsdk.security)
  • help needed with CryptEncrypt
    ... I used CertCreateCertificateContext to read the certificate buffer. ... HCRYPTPROV hCryptProv = NULL; ... DWORD cbContent = 0; ... DWORD dwBufferLen = cbContent; ...
    (microsoft.public.platformsdk.security)
  • Re: windows programming cryptography(problem in implementing a Sma
    ... Normally your smart card should have on-board key pair generation, ... First,I should include it’s header file in CSP code as below: ... HCRYPTPROV and remember that it refers to your CSP and to the ...
    (microsoft.public.platformsdk.security)
  • Re: windows programming cryptography(problem in implementing a Sma
    ... First,I should include it’s header file in CSP code as below: ... I don't know how to implemet CPAcquirecontext function in CSP in order ... memory to HCRYPTPROV, ... HCRYPTPROV and remember that it refers to your CSP and to the ...
    (microsoft.public.platformsdk.security)