Dan Griffin's Blog

Comments on security, PKI, smart cards, cryptography, and entrepreneurship.

I’ve recently been provisioning a new dev machine.  While searching for the download point for the CNG (Crypto API: Next Generation) SDK, I stumbled upon some new CNG-related sample code offered by Microsoft separately from the SDK.  The new sample can be downloaded here - http://www.microsoft.com/downloads/details.aspx?familyid=34C59FA0-E265-4E44-9A3B-9370EECDC5A9&displaylang=en.  Here’s what I found:

1.       By default, the sample CAB wants to install itself to the user profile.  While that’s nice from a UAC point of view, I figured I’d rather stick that code in place I’m more likely to be able to find it later.  So I installed it under c:\Program Files\Microsoft CNG Development Kit\DemoCode.
2.       Open the CNGLibrary.sln file and Build.
3.       In Solution Explorer in Visual Studio 2005, right-click on CNGTestApp and select Set as StartUp Project
4.       Press F5 to start debugging

I was surprised to discover that the sample includes a managed (C#) WinForm!  The form consists  of four primary controls:  an Input edit box, a Hash Type multi-select, an Output edit box, and a Generate Hash button.  The overall purpose of the sample is apparently to demonstrate the use of PInvoke to exercise the CNG hashing routines from managed code. 


Cool – but then again, the .NET Framework already supports all of the SHA-2 algorithms natively, so exposing a more complex CNG scenario via PInvoke would have been preferable.  Like how about ECDH (Elliptic Curve Diffie-Hellman) key agreement?  Anyway – there it is.

Permalink |

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment