Click here to Skip to main content
15,888,325 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi their ,

I have generated private and public key in java. whereas public key size is 1kb and private key size is 2kb. i googled lot but unable to understand the core.

help me out.


Thanks in advance:)
Posted
Comments
Sergey Alexandrovich Kryukov 4-Jul-11 20:21pm    
There is no issue here. What did you expect? Why did you expect equal-size keys, can you explain that?
--SA

1 solution

Besides the cryptographic information about your actual key, the key files always contain some metadata, as to when the key was generated, whether it is packed, if so what kind of packing (base64 etc) was used to pack the key etc.
Try to open your key in a notepad to see if you can get any human-readable info.
Often you can read something like:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,7BC....

JHQ8U0pDbeFM9h2jZSmiugxdqOa2q/MiX43Xa4Es6nKmzu9oI/ZfpIdAHi8qwtsD
mZ5bQRIXD9AXeIRy+0tG2ibUaphQEsvI995PWUsh8N9dVumsqykmMXSwND7tkbHB
iO/VVSAAD9bV3dbl5nbMwMnPG+YC3S90GAK4ZRIqrHRQ94fd/ZAvP8kV9ilwCmX6
swFlNBLGuKFllJ9qkyr+OOQqulrAyZAB2UThGCJJetELFtV4mLmIaHdgDIcUqpJp==
-----END RSA PRIVATE KEY-----


The two lines just after the beginning of RSA private key are metadata, that can vary in size.
If the key is in a binary format, you can usually get the meta information using some key management tool.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 4-Jul-11 20:21pm    
Nice explanation, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900