0

I am trying to create an RSA key using openssl on Linux and then converting it to PuTTY format so that I can use it from my Windows PC as well.

openssl genpkey -algorithm RSA-PSS -out myKey.pem -outform PEM -pkeyopt rsa_keygen_bits:2048

Key is generated. I cat it, looks ok.

Now convert it to PuTTY format:

puttygen myKey.pem -o myKey.ppk -O private

I get following error:

puttygen: error loading 'myKey.pem': unrecognised key type

I tried to check the key using the following command:

openssl rsa -in myKey.pem -text

I get following error:

140527068488128:error:0607907F:digital envelope routines:EVP_PKEY_get0_RSA:expecting an rsa key:../crypto/evp/p_lib.c:464:

Any idea what's going on?

0

You're using the wrong algorithm: RSA-PSS instead of RSA.

This command would generate the intended key:

openssl genpkey -algorithm RSA -out myKey.pem -outform PEM -pkeyopt rsa_keygen_bits:2048

Note that the only change is replacing RSA-PSS with RSA.


For a given private key, you can retrieve informations about it, including the algorithm used, like this:

openssl asn1parse -in myKey.pem

the wrong algorithm (for SSH usage) would have a line similar to this among others:

    9:d=2  hl=2 l=   9 prim: OBJECT            :rsassaPss

while the RSA algorithm will have something similar to this among others:

    9:d=2  hl=2 l=   9 prim: OBJECT            :rsaEncryption
  • I didn't understand why is RSA-PSS wrong? It is supported and mentioned in the man page of genpkey, which states ... "Valid built-in algorithm names for private key generation are RSA, RSA-PSS, EC, X25519, X448, ED25519 and ED448" – xkcd Jun 13 at 16:12
  • you generate an RSA-PSS key then complain it doesn't decode as RSA with the last command. SSH (not openssl) doesn't support RSA-PSS. If you want to use SSH, you have a limited subset of valid key algorithms. RSA-PSS is not part of them, RSA is. Others are possible. ED25519 would be valid for openssh, I don't know for putty. – A.B Jun 13 at 16:22
  • Thanks for your kind reply. Maybe I should change the question title ... why the RSA-PSS keys cannot be used as normal RSA keys are used with SSH? AFAIK the RSA-PSS is just recommended PKCS#1 standard way to use RSA. en.wikipedia.org/wiki/Probabilistic_signature_scheme – xkcd Jun 14 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.