Example usage for java.security.spec RSAPrivateCrtKeySpec getPrimeExponentP

List of usage examples for java.security.spec RSAPrivateCrtKeySpec getPrimeExponentP

Introduction

In this page you can find the example usage for java.security.spec RSAPrivateCrtKeySpec getPrimeExponentP.

Prototype

public BigInteger getPrimeExponentP() 

Source Link

Document

Returns the primeExponentP.

Usage

From source file:org.casbah.provider.PKCS1EncodedKeySpecTest.java

@Test
public void testToRsaKeySpec() throws IOException, CAProviderException {

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    IOUtils.copy(this.getClass().getResourceAsStream("/caplaintext.key"), baos);
    byte[] encodedKey = baos.toByteArray();
    PKCS1EncodedKeySpec encodedKeySpec = new PKCS1EncodedKeySpec(encodedKey);
    RSAPrivateCrtKeySpec privateKeySpec = encodedKeySpec.toRsaKeySpec();
    assertNotNull(privateKeySpec);//w  ww  .j a v a  2s.  c o m

    assertEquals(TestKeyValues.MODULUS, privateKeySpec.getModulus());
    assertEquals(TestKeyValues.PUBLIC_EXPONENT, privateKeySpec.getPublicExponent());
    assertEquals(TestKeyValues.PRIVATE_EXPONENT, privateKeySpec.getPrivateExponent());
    assertEquals(TestKeyValues.PRIME1, privateKeySpec.getPrimeP());
    assertEquals(TestKeyValues.PRIME2, privateKeySpec.getPrimeQ());
    assertEquals(TestKeyValues.EXPONENT1, privateKeySpec.getPrimeExponentP());
    assertEquals(TestKeyValues.EXPONENT2, privateKeySpec.getPrimeExponentQ());
    assertEquals(TestKeyValues.COEFFICIENT, privateKeySpec.getCrtCoefficient());

}