Re: CryptoAPI



That 596 byte is a MS PRIVATEKEYBLOB unencrypted blob.
..NET api does not support importing these blob types.
You will need to use PInvoke from .NET 1.1 / 2 to import that
RSA keypair. Some samples showing how to set up capi fn prototypes and structs are here:
http://www.jensign.com/JavaScience/cryptoutils

Also, you can manually import that unencrypted PRIVATEKEYBLOB (if in a file)
using the .NET tool sn.exe .. e.g.
sn -i yourprivatekey.snk MyContainer
but this only works if the privatekeyblob specifies the key as AT_SIGNATURE.

- Mitch Gallant
MVP Security

<zabutimaxim@xxxxxxxxx> wrote in message
news:1139754639.488025.256920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello everyone,

I need to convert some code that works with CryptoAPI using
advapi32.dll to C#.NET and to use
System.Security.Cryptography. The question is what is the analog for
CryptImportKey API? In the old code they giving to this CryptImportKey
a private key which is byte array 596 bytes length.

Thanks,
Maxim



.