I have a public certificate in a PEM (.pem) file


Its total size is 942 characters.

Now I would want to deduce from it the size of private key and asymmetric generation system. Is this possible ?

  • @Polynomial That one seems specific to OpenSSH and this one seems specific to X509 certs, regardless of the title. May 9 '15 at 13:36

The public and private key have the same size (with regards to security, the file size differs of course). It's identical to the size of the modulus when it is regarded as an unsigned integer (and the key size is a full number of bytes, i.e. a multiple of 8 - otherwise it is the location of the highest bit set to one).

You are however showing a full X509 certificate. That certificate contains the public key. You can easily view the public/private key size by typing:

openssl x509 -text -noout -in [yourcert] 

It will contain lines with:

Subject Public Key Info:
    Public Key Algorithm: rsaEncryption
        Public-Key: (2048 bit)

Where [yourcert] is the file containing the certificate and the value 2048 is an example. Note that rsaEncryption may be used to indicate signature generation as well.

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