Hi,

I enjoy using Bouncy Castle in my projects.

Right now I try to get a working key exchange between .Net and BC for
elliptic curves, meaning that I generate a keypair with either of them and
then use them for the other.

This is working for private keys via (VB.Net):
   Dim netPrivateKey As Byte() =
ECDiffieHellmanCng.Key.Export(CngKeyBlobFormat.Pkcs8PrivateBlob)

   Dim bcPrivateKeyInfo As PrivateKeyInfo =
PrivateKeyInfoFactory.CreatePrivateKeyInfo(bcKeyPair.Private)
   Dim bcPrivateKey As Byte() = bcPrivateKeyInfo.GetDerEncoded

and load them with "CngKey.Import(bcPrivateKey,
CngKeyBlobFormat.Pkcs8PrivateBlob)" and
"PrivateKeyFactory.CreateKey(netPrivateKey)" respectively.


For public keys I haven't found a working solution for cross-use.
   "PublicKeyFactory" won't take a net public key and "CngKey.Import" won't
accept a BC one.
Export for those is
    "ECDiffieHellmanCng.PublicKey.ToByteArray" and
"SubjectPublicKeyInfo.GerDerEncoded".


Is there any other way to export or import those public keys for
cross-use,  that I haven't found yet?

-- 
Best regards,
Karsten Wendt

Reply via email to