0

because of the faster decryption i am changing my Code from RSA to ElGamal.

So i am using BouncyCastle for the first time now, but i can not figure out hot to convert my keys

ElGamalPublicKeyParameters pub_key;
ElGamalPrivateKeyParameters priv_key;

each to a byte[] (String would also work)

I found a solution for the class both are inheriting "AsymmetricKeyParameter":

    PrivateKeyInfo k = PrivateKeyInfoFactory.CreatePrivateKeyInfo(private_key);
    byte[] serializedKey = k.ToAsn1Object().GetDerEncoded();

but this works only for the PrivateKey. I could not find a similar was to do it with the public_key

I need a String or byte[] to be able to compress, encrypt, save and send the keys.

-

Thank you for your help in advance.

Alex R.
  • 1
  • 1
  • 4

1 Answers1

0
byte[] serializedKey2 = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(public_keyS).ToAsn1Object().GetDerEncoded();

may work, did not test it yet

Alex R.
  • 1
  • 1
  • 4