Sorry for my english and honestly I have a very little understanding on this so please bear with me.
I am developing a java application that sends a signed request to a Server.
To do so, I have to generate a PKCS#1 RSA key pair in PEM
format for signing and verification. I've tried using OpenSSL v.1.0.1. but the public key generated is a X.509 PEM
.
Here's the openssl command I used to generate the keys:
Private Key:
openssl genrsa -out name_of_private_key.pem 1024
Public Key
openssl rsa -in name_of_private_key.pem -pub out > name_of_public_key.pem
I've gone through this thread also and I found an open source JAVA library BouncyCastle: Generating RSA keys in PKCS#1 format in Java
But it says that BouncyCastle is only for PKCS#1 padding not encoding.
Preferably, I'm looking for ways to generate it using JAVA or any third parties if no other option is available.
Although the OpenSSL library supports PKCS#1 encoding, the command line version of OpenSSL will only output RSA Public keys in x.509 format. Unfortunately it seems you are left with no option than to write some code that uses the OpenSSL library to output keys in PKCS#1 format.
For reference, a PKCS#1 key uses these headers/footers:
Whereas a x.509 key uses these headers/footers: