CryptographicException from System.Security.Cryptography.Protected

  • Thread starter Thread starter ondrej421
  • Start date Start date
O

ondrej421

Hi there,

On some computers running Windows XP, the ProtectData() method sometimes
throws the following CryptographicException:

Type: System.Security.Cryptography.CryptographicException
Message: The system cannot find the file specified.

Source: System.Security
Stack Trace:
at System.Security.Cryptography.ProtectedData.Protect(Byte[] userData,
Byte[] optionalEntropy, DataProtectionScope scope)
...

This is how the method is being called:
byte[] encrypted = ProtectedData.Protect(plain, null,
DataProtectionScope.CurrentUser);

I can't find an answer to why this would be happening. Can anyone think of a
possible reason?

Thank you!
 
ondrej421 said:
On some computers running Windows XP, the ProtectData() method sometimes
throws the following CryptographicException:

Type: System.Security.Cryptography.CryptographicException
Message: The system cannot find the file specified.

Source: System.Security
Stack Trace:
at System.Security.Cryptography.ProtectedData.Protect(Byte[] userData,
Byte[] optionalEntropy, DataProtectionScope scope)
...

This is how the method is being called:
byte[] encrypted = ProtectedData.Protect(plain, null,
DataProtectionScope.CurrentUser);

I can't find an answer to why this would be happening. Can anyone think of a
possible reason?

Thank you!

..Protect() is a thin wrapper around the native CryptProtectData() function,
so it's safe to say this has nothing to do with the .NET framework itself.
CryptProtectData() doesn't document a special failure mode.

Assuming the "file not found" is genuine (and not a bogus error value
produced as a result of a bug) try installing Filemon
(http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx) to see if
there are any obvious API calls failing when you use ProtectedData().
 
Back
Top