Re: ImportCspBlob ?
From: Michel Gallant (neutron_at_istar.ca)
Date: 06/17/05
- Next message: William Stacey [MVP]: "Re: ImportCspBlob ?"
- Previous message: Joe Kaplan \(MVP - ADSI\): "Re: Authentication? Forms without Anynymous access"
- In reply to: William Stacey [MVP]: "ImportCspBlob ?"
- Next in thread: William Stacey [MVP]: "Re: ImportCspBlob ?"
- Reply: William Stacey [MVP]: "Re: ImportCspBlob ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Fri, 17 Jun 2005 12:23:10 -0400
Not certain about this, but .NET managed code uses a "publickey" binary blob
(your GetPublicKey() method) that is NOT identical to that used by CryptoAPI.
The .NET blob has an extra 3 hearders (12 bytes) tacked onto the conventional
unmanaged capi publickeyblob, probably used as parameter in ImportCspBlob()
See also:
http://www.jensign.com/JavaScience/dotnet/JKeyNet
- Mitch Gallant
MVP Security
www.jensign.com
"William Stacey [MVP]" <staceywREMOVE@mvps.org> wrote in message news:uGbSmV1cFHA.4040@TK2MSFTNGP14.phx.gbl...
> With a signed assem, how come this does not work? What would?
>
> private void button25_Click(object sender, EventArgs e)
> {
> byte[] pubkey =
> Assembly.GetExecutingAssembly().GetName().GetPublicKey();;
> RSACryptoServiceProvider r = new RSACryptoServiceProvider();
> r.ImportCspBlob(pubkey);
> Console.WriteLine(r.ToXmlString(false));
> }
>
>
> System.Security.Cryptography.CryptographicException was unhandled
> Message="Bad Version of provider.\r\n"
> Source="mscorlib"
> StackTrace:
> at
> System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32
> hr)
>
> at System.Security.Cryptography.Utils._ImportCspBlob(Byte[] keyBlob,
> SafeProvHandle hProv, CspProviderFlags flags, SafeKeyHandle& hKey)
>
> at
> System.Security.Cryptography.Utils.ImportCspBlobHelper(CspAlgorithmType
> keyType, Byte[] keyBlob, Boolean publicOnly, CspParameters parameters,
> Boolean randomKeyContainer, SafeProvHandle& safeProvHandle, SafeKeyHandle&
> safeKeyHandle)
>
> at
> System.Security.Cryptography.RSACryptoServiceProvider.ImportCspBlob(Byte[]
> keyBlob)
>
> at WSESimpleTCPServer.SrvForm.button25_Click(Object sender, EventArgs
> e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio
> 2005\Projects\WSESimpleTCPServer\SrvForm.cs:line 1115
>
> at System.Windows.Forms.Control.OnClick(EventArgs e)
>
> at System.Windows.Forms.Button.OnClick(EventArgs e)
>
> ...
> --
> William Stacey [MVP]
>
>
>
- Next message: William Stacey [MVP]: "Re: ImportCspBlob ?"
- Previous message: Joe Kaplan \(MVP - ADSI\): "Re: Authentication? Forms without Anynymous access"
- In reply to: William Stacey [MVP]: "ImportCspBlob ?"
- Next in thread: William Stacey [MVP]: "Re: ImportCspBlob ?"
- Reply: William Stacey [MVP]: "Re: ImportCspBlob ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]