Tarun Khandelwal wrote:
I have to Implement RSA Decryption. For that i think i will be requiring Private Key.
I am receiving a file which is being created by c code. Where the key is generated using R_ENCODE.c class , function :- R_GeneratePEMKeys.
Than the buffer is being passed to R_EncodePEMBlock.
I am not getting how to get Private Key Object from that file?
In Java, public/private key pairs are generated with the KeyPairGenerator. In your case, since the data has already been encrypted, the pairs have already been generated by the C-program. Technically, you are "regenerating" the private key, but I digress...
Anyway, you just need to create the key object, which is done with one of the java.security.spec.KeySpec -- and following the JavaDoc for that class, I suspect that you need the RSAPrivateKeySpec.
Unfortunately, RSA is not an encryption that I use much (if at all), so I have no idea how to load it from a pem file. But hopefully, I gave you enough to get started (via research).
Henry