CryptAcquireContext on PocketPC 2002 Emulator

C

colin.mackay

I'm having a problem with CryptAcquireContext in a .NET Compact
Framework application running on the Pocket PC Emulator 2002. On a
Pocket PC 2003 Second Edition (a real device) it seems to work fine.

The line of code I'm having a problem with is:

WinApi.CryptAcquireContext(ref hProv, null,
"Microsoft Enhanced Cryptographic Provider v1.0",
1, // PROV_RSA_FULL
0xf0000000); // CRYPT_VERIFYCONTEXT

WinApi is a class that contains the definition of all the PInvoked
methods.
[DllImport("coredll.dll")]
public static extern bool CryptAcquireContext(
ref IntPtr phProv, string pszContainer, string pszProvider,
uint dwProvType, uint dwFlags);

The problem is that on my machine, running the code produces an error
0x80000005

When I tried the code on a collegues machine, her Pocket PC 2002
Emulator produced a differernt error message. She got 0x80090019 on the
same function call. I don't understand why there is a difference - both
should be set up identically, but I guess there is something different.

Finally, we tried to deploy it to a real Pocket PC device (PPC 2003
Second Edition) and it worked fine.

I need the code to work on PPC 2002 onwards. Does anyone have any idea
why I am seeing different results? Or have any idea of how to fix this?
 
C

colin.mackay

I didn't find any documentation to support the following statement,
hence this disclaimer, but it would appear that PocketPC 2002 does not
support the Enhanced Cryptographic Provider. I changed the above line
to:

WinApi.CryptAcquireContext(ref hProv, null,
"Microsoft Base Cryptographic Provider v1.0",
1, // PROV_RSA_FULL
0xf0000000); // CRYPT_VERIFYCONTEXT

And everything worked.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top