Import byte array back into ECPublicKeyParameters ? #412
-
How do i IMPORT a public key (byte array) from a generated ECDH asymmetric keypair into a ECPublicKeyParameters object? I've seen a couple of code samples om stack (rather old ones) and elsewhere and found a way to export to a byte array using aliceKeyPair.Public -> ECPublicKeyParameters and then converting to a byte array using x.Q.GetEncoded, that allow me to send it over a networkstream object to a remote host. Great. But on the receiving side, how do i IMPORT it back from a byte array into a usable ECPublicKeyParameters so i can use it with IBasicAgreement.CalculateAgreement() ? I can't find any documentation on this anywhere, and looking through the source code isn't of much use either for this problem. I don't even know where to continue to look. Thanks in advance for any code/pointers/links to solution that anyone can provide. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Solution was to go through a PemWriter -> PemString, then importing PemString back with ECPublicKeyParameters <- PemReader. |
Beta Was this translation helpful? Give feedback.
-
The problem description is much like what the TLS implementation needs, and as such Org.BouncyCastle.Tls.Crypto.Impl.BC.BcTlsECDH is a good place to begin. |
Beta Was this translation helpful? Give feedback.
Solution was to go through a PemWriter -> PemString, then importing PemString back with ECPublicKeyParameters <- PemReader.