2

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

-----BEGIN CERTIFICATE-----
MIICsjCCAZqgAwIBAgIJAMA1YIQ2JLXDMA0GCSqGSIb3DQEBBQUAMBExDzANBgNV
             ...
29V/R9RZOoSBHDzGPL84wm4qojMuwQ==
-----END CERTIFICATE-----

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. – Maarten Bodewes May 9 '15 at 13:36
3

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.