How to determine the RSA Private key size from the Public.key file? Question: How to determine the RSA Private key size from the Public.key file? Just roughly, how big it could be? 

$ ls -la Public.key 
    -rw-r--r--. 1 user user 498 Sep  4 15:31 Public.key
    $ 


The Public.key was generated using the Java API (which defaults to the X509 SubjectPublicKeyInfo structure with embedded PKCS#1 public key in a BIT STRING).
Assumption: you've saved the RSA public key using the default encoding in Java (for the SUNRSA provider), as in:



KeyPairGenerator kgen = KeyPairGenerator.getInstance("RSA");
kgen.initialize(1024);
KeyPair kp = kgen.generateKeyPair();
Files.write(new File("Public.key").toPath(), kp.getPublic().getEncoded());


This generates an X.509 ASN.1 SubjectPublicKeyInfo structure encoded using DER.

In that case you can retrieve the information from the public key using the following OpenSSL command:

openssl rsa -pubin -inform DER -in Public.key -text -noout


This will show the following output:

Public-Key: (1024 bit)
Modulus:
    00:c3:7e:ea:ba:9d:55:81:ec:80:8b:68:fb:7b:80:
    14:d4:66:45:0e:ba:6e:45:98:23:dc:24:26:a4:30:
    0e:20:48:12:23:b3:8b:5e:ed:c2:a5:cf:5e:32:43:
    00:9b:61:6e:e7:a6:f4:01:55:e9:cc:a8:c7:29:24:
    fd:29:7b:a1:b9:4b:1c:4c:de:cc:f6:d0:7e:75:a6:
    5f:28:09:65:67:76:1c:e8:f5:ae:85:ad:4a:dc:48:
    ca:82:46:25:e1:17:f8:3b:0c:53:30:c4:bb:08:5a:
    75:43:8a:d3:26:97:35:a7:2f:61:c6:68:06:24:b3:
    c8:42:e1:53:40:39:95:46:c9
Exponent: 65537 (0x10001)


As you can see, the key size is in the first line of the output.