Re: Enumerating KeyContainers in C#
From: Michel Gallant (neutron_at_NOSPAMistar.ca)
Date: 04/06/04
- Previous message: Alek Davis: "Re: PasswordDeriveBytes - which algorithms are available?"
- In reply to: Shawn Farkas: "RE: Enumerating KeyContainers in C#"
- Next in thread: D. Janknecht: "Re: Enumerating KeyContainers in C#"
- Reply: D. Janknecht: "Re: Enumerating KeyContainers in C#"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 5 Apr 2004 20:55:30 -0400
There is also the more comprehensive .NET utility "KeyPal" with source code here:
http://www.jensign.com/JavaScience/dotnet/keypal
Cheers,
- MIAG
""Shawn Farkas"" <shawnfa@online.microsoft.com> wrote in message
news:6YRwmt2GEHA.616@cpmsftngxa06.phx.gbl...
> Hi Dirk,
>
> Unfortunately there's no way to do that built into the framework. However, you can P/Invoke to
CAPI and accomplish this task. The
> function you're looking for is CryptGetProvParam(), (MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-
> us/security/security/cryptgetprovparam.asp). You'll want to pass in a query parameter of
PP_ENUMCONTAINERS.
> Mich Gallant has written a sample bit of code that does exactly what you're looking for, and
published it on MSDN:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncapi/html/netcryptoapi.asp
>
> Scroll down to the section entitled ".NET and CryptoAPI via P/Invoke: Part 2" for the code that's
relavent to your problem.
>
> -Shawn
> http://blogs.msdn.com/shawnfa
>
> --
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Note: For the benefit of the community-at-large, all responses to this message are best directed
to the newsgroup/thread from which they
> originated.
> --------------------
> >From: "D. Janknecht" <fda@dfsdasd.com>
> >Subject: Enumerating KeyContainers in C#
> >Date: Mon, 5 Apr 2004 17:18:53 +0200
> >Lines: 23
> >X-Priority: 3
> >X-MSMail-Priority: Normal
> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> >Message-ID: <uFi8SFyGEHA.3636@TK2MSFTNGP12.phx.gbl>
> >Newsgroups: microsoft.public.dotnet.security
> >NNTP-Posting-Host: 62.217.38.130
> >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
> >Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.security:5649
> >X-Tomcat-NG: microsoft.public.dotnet.security
> >
> >Hello,
> >
> >i use the following code to access a keycontainer on the local machine:
> >
> >CspParameters parms = new CspParameters(1); // PROV_RSA_FULLparms.Flags =
> >CspProviderFlags.UseMachineKeyStore; // Use Machine store
> >parms.KeyContainerName MyContainerName; // Name of the key-container
> >parms.KeyNumber = 2; // AT_SIGNATURE
> >RSACryptoServiceProvider csp = new RSACryptoServiceProvider(parms);
> >
> >This works fine as long as i pass the value of an existing key container in
> >the "MyContainerName" string . By passing a non-exisiting container name, a
> >new key is generated but no error occurs.
> >So my tought was it to enumerate all key containers and test if the given
> >name exists, but how can i do this?
> >
> >Any ideas?
> >
> >Thanks in advance,
> >
> >Dirk
> >
> >
> >
>
>
- Previous message: Alek Davis: "Re: PasswordDeriveBytes - which algorithms are available?"
- In reply to: Shawn Farkas: "RE: Enumerating KeyContainers in C#"
- Next in thread: D. Janknecht: "Re: Enumerating KeyContainers in C#"
- Reply: D. Janknecht: "Re: Enumerating KeyContainers in C#"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|