CryptAcquireContext() fails for Eracom HSM
- From: "Ivan A. Vasilyev" <violator@xxxxxxxxxxxx>
- Date: Wed, 13 Dec 2006 21:28:05 +0600
Hi all
I'm trying to "play" with HSM mentioned, but can't even acquire context.
..NET 1.1 is used with P/Invoke.
The code is:
....
uint provFlags = CRYPT_VERIFYCONTEXT;
if (!CryptAcquireContext(ref pProvider, null, ERACOM_PROVIDER_NAME,
PROV_RSA_FULL, provFlags)) {
ShowWin32Error(Marshal.GetLastWin32Error(), true);
return;
}
....
private static void ShowWin32Error(int errorcode, bool startNewLine) {
Win32Exception myEx = new Win32Exception(errorcode);
if (startNewLine) {
Console.WriteLine();
}
Console.WriteLine("Error code:\t 0x{0:X}", myEx.ErrorCode);
Console.WriteLine("Error message:\t " + myEx.Message);
}
Strange, but this code fails with error 0x80004005 ('Unspecified error' in
WinError.h). Though ShowWin32Error() function shows other error message...
Any ideas?
TIA
.
- Prev by Date: Re: Difference between CryptEncryptMessage EncryptMessage(Negotiate)
- Next by Date: How can a program talk to Windows Security Center?
- Previous by thread: S/MIME with CAPI
- Next by thread: How can a program talk to Windows Security Center?
- Index(es):