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 ?

Maarten Bodewes
  • 4,562
  • 15
  • 29
nlassaux
  • 123
  • 1
  • 5

1 Answers1

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.

DaSh
  • 103
  • 4
Maarten Bodewes
  • 4,562
  • 15
  • 29