Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do we extract Modulus, Exponent, P, Q, etc from Private/Public Key?

801532Oct 4 2010 — edited Dec 15 2010
Hi Friends..

I want to know, is there a way to extract Modulus and Exponent from Public Key and extract contents from Private Key in (CRT) Chinese Remainder Theorem?..
Actually, we can do this when we "print out" the Public Key and Private Key, as follows :
               //Get Public Key of KeyPair just generated
		PublicKey pubKey = pair.getPublic();
		//Get Public Key of KeyPair just generated
		PrivateKey privKey = pair.getPrivate();
		
		System.out.println("Public Key  = " + pubKey);
		System.out.println("Private Key  = " + privKey);
it will print, the contents as follows :
Public Key = Sun RSA public key, 512 bits
  modulus: 7245167342676344317906934030302544552432079991256588369257926164425751465534242483204954676132059996724165172896153776444688381927937426790249978563155939
  public exponent: 65537

Private Key = Sun RSA private CRT key, 512 bits
  modulus:          7245167342676344317906934030302544552432079991256588369257926164425751465534242483204954676132059996724165172896153776444688381927937426790249978563155939
  public exponent:  65537
  private exponent: 3008860942149046543181302523807076233021711721959054666006881249022318348985166301650552976025343498696303558233103587251105410954636737443508599789159969
  prime p:          86259910146814054946856998005948469934550403083182889279708979133443598784657
  prime q:          83992289469640018365413156013863220983167781117440735610803682622464920568627
  prime exponent p: 3140457231949865497401480037874682229333617067556866713785886204928459140641
  prime exponent q: 25929352893018552139540091436478335702449769558692966764999620165978153912209
  crt coefficient:  6802026673753271661464817453104766146685769044163286901158466553717481388215
But, this way is not what i want.. :(

Please help me regarding this.

Thanks.

Leonardo Carreira
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 12 2011
Added on Oct 4 2010
7 comments
7,686 views