I use KeyPairGenerator class to generate private and public key for RSA algorithm. Next step is to create DigitalSignature for some files. I’m going to use Signature class with public key generated in first step. It is working ok, but I have a problem with getting p and q parameter. How can I get them? I need them to be shown, the same as modulus. When I use .toString() method on private or public key, I can see all these values? Is there any other posibility to get p, q, modulus without parsing this string?
One more thing. Is there any posibility to get only generated key without all this values which are in toString() method?
Thanks a lot!
You have to cast the result of
KeyPair.getPublic()andKeyPair.getPrivate()toRSAPublicKeyandRSAPrivateKey.EDIT:
You can cast
KeyPair.getPrivate()toRSAPrivateCrtKeyto extract P and Q.