jeudi 28 juillet 2016

OpenSSL, How to construct public RSA* from modulus and exp. in c++?

So, Long story short:

I want to construct an RSA* object from a public RSA key in C++ in order to encrypt a small text (a session id) using RSA_public_encrypt. I can easily extract the modulus and exponent from the base64 encoded public key. I tried messing around with RSA_new, d2i_RSAPublicKey, setting e and n manually etc. but nothing worked.

I have found plenty of answers how one would do that in Java but it seems I can't wrap my head around how to do this in C++ and am not very familiar with java, and the documentation is really bad

Java example of what I think should be possible:

PublicKey publicKey = KeyFactory.getInstance("RSA").
    generatePublic(new RSAPublicKeySpec(firstKeyInteger, secondKeyInteger));

PS: Sorry for bad the writing, I haven't been sleeping last night :p

Aucun commentaire:

Enregistrer un commentaire