Thursday, February 24, 2011 12:02 AM
I have a small sample program which fails on my computer with a Cryptographic exception, but on a coworker's computer it will succeed (no exception). Any ideas?
The exception I get:
Unhandled Exception: System.Security.Cryptography.CryptographicException: The requested operation is not supported.
at System.Security.Cryptography.NCryptNative.ImportKey(SafeNCryptProviderHandle provider, Byte keyBlob, String format)
at System.Security.Cryptography.CngKey.Import(Byte keyBlob, CngKeyBlobFormat format, CngProvider provider)
at System.Security.Cryptography.CngKey.Import(Byte keyBlob, CngKeyBlobFormat format)
Thursday, February 24, 2011 12:18 AMModerator
CngKey (and all of the Cryptography Next Generation classes) are only supported on Vista SP1 and later. If you're running XP, for example, you'll receive this exception.
For details, see the documentation, under Platforms: "Windows 7, Windows Vista SP1 or later, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported)"
Reed Copsey, Jr. - http://reedcopsey.com
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
Thursday, February 24, 2011 6:52 AMModerator
Thursday, February 24, 2011 2:22 PMI am running Vista SP2 (32-bit). The documentation suggests that a PlatformNotSupportedException would be thrown if that was my problem.
Monday, February 28, 2011 3:18 AMModerator
It is supported on Vista SP1 and later, so Vista SP2 should work, you can submit this issue to Microsoft Connect feedback portal http://connect.microsoft.com, Microsoft engineers will evaluate them seriously, thanks. If this issue is urgent, please contact support at http://support.microsoft.com.
Eric Yang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, February 28, 2011 2:56 PM
I entered a "feedback item" on the Microsoft Connect website. https://connect.microsoft.com/VisualStudio/feedback/details/648322/cngkey-import-throws-cryptographicexception-on-vista-sp2
Side note: neither Chrome nor Firefox seems to render that webpage correctly, word-wraps are not occurring, so I can only view it (correctly) with IE.
I will probably try to contact support as well.
Friday, March 04, 2011 4:26 PM
The Windows SDK Escalation Engineer on my support case found that the issue is that the native function being called by the CngKey.Import method does not support the ECC private blob type in Windows Vista or Windows Server 2008 (but it does work in Windows Server 2008 R2).
Here's the relevant documentation http://msdn.microsoft.com/en-us/library/aa376276(VS.85).aspx
- BCRYPT_ECCPRIVATE_BLOBWindows Server 2008 and Windows Vista: This value is not available.
So that is very disappointing, when you read everywhere else that the CNG library functions are supported in Vista SP1 or later, but then you try it out and nearly every blob type is not supported in Vista.
- Marked As Answer by Ansssss Friday, March 04, 2011 4:34 PM