Another GUID Question - Code Project code

  • Thread starter Thread starter Glyn Meek
  • Start date Start date
G

Glyn Meek

We are using the Code Project routines for generating GUIDs on the Pocket
PC.

http://www.codeproject.com/netcf/PPCGuidGen.asp

In an earlier posting, I mentioned that we occasionally get an error message

"Failed to acquire cryptography handle."

....and it turns out that this is generated out of the 'CodeProject' NewGuid
routine, by a piece of code that reads...

If Not WinApi.CryptAcquireContext(hCryptProv, Nothing, Nothing, _
WinApi.PROV_RSA_FULL, WinApi.CRYPT_VERIFYCONTEXT) Then
Throw New SystemException( "Failed to acquire cryptography handle.")
End If

Can anyone tell me under what circumstances the CryptAcquireContext routine
would fail and generate this error? I have received one response that
mentions that the DeKlarit GUID code had a similar error, with a 'fix'
mentioned, but the code is significantly different enough that it doesn't
apply to the 'CodeProject' stuff. Does anyone know if there is a later
version of the CodeProject code that has fixed this, or if any GUID code is
better than any other?

thanks

Glyn Meek
 
It can occur if your device doesn't have high encryption built in. Take a
look at the updated GuidEx code in the OpenNETCF vault
(http://vault.netcf.tv/VaultService/VaultWeb/login.aspx User: guest,
Password: guest) as this actually has three possible branches:-
On CE.NET 4.2 and higher it uses the native CoCreateGuid API method
On prior devices with crypto support it uses the crypto APIs
(OpenNETCF.Security.Cryptography)
On remaining devices it uses basic Windows CE random number generation.

Peter
 
Chris...this is one of our customers, as we can't reproduce it on any other
equipment, and I have no idea what equipment he's running on. This is the
first I have ever heard of a 'high-encryption pack'.

How does one know if it's installed?

and where does one get a hold of it?

Glyn
 
I just spoke with our customer who has this issue, and he has a brand new
Dell Axim with Pocket OS 2003, so this shouldn't be a problem. He actually
tried the download anyhow, but it made no difference...any other
suggestions?

Glyn Meek
 
Would you recommend replacing the CodeProject code with the OpenNetCF code,
Peter?

Glyn
 
It's an option. The OpenNETCF code has some failsafes that the CodeProject
stuff apparently doesn't. Basically it tries several mechanisms, each less
desirable that the previous, to try to generate your GUID, at last resorting
to a random number generator. The idea is that you should always get a
result, not an exception. Obviously it means that how the result is
attained may change depending on the device.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate
 
Back
Top