Example usage for java.security.interfaces RSAPrivateCrtKey getPrivateExponent

List of usage examples for java.security.interfaces RSAPrivateCrtKey getPrivateExponent

Introduction

In this page you can find the example usage for java.security.interfaces RSAPrivateCrtKey getPrivateExponent.

Prototype

public BigInteger getPrivateExponent();

Source Link

Document

Returns the private exponent.

Usage

From source file:com.thoughtworks.go.security.X509CertificateGeneratorTest.java

@Test
public void shouldGeneratePrivateKeyWithCRTFactorsForCompatibilityWithOtherPlatform() throws Exception {
    X509CertificateGenerator generator = new X509CertificateGenerator();
    Registration registration = generator.createAgentCertificate(keystore, "agentHostName");
    assertThat(registration.getPrivateKey(), instanceOf(RSAPrivateCrtKey.class));
    RSAPrivateCrtKey key = (RSAPrivateCrtKey) registration.getPrivateKey();
    assertThat(key.getModulus().signum(), is(1));
    assertThat(key.getPrivateExponent().signum(), is(1));
    assertThat(key.getPrimeP().signum(), is(1));
    assertThat(key.getPrimeExponentQ().signum(), is(1));
    assertThat(key.getCrtCoefficient().signum(), is(1));
}

From source file:org.ebayopensource.fido.uaf.crypto.KeyCodec.java

static public RSAKeyParameters generatePrivateKeyParameter(RSAPrivateKey key) {
    if (key instanceof RSAPrivateCrtKey) {
        RSAPrivateCrtKey k = (RSAPrivateCrtKey) key;
        return new RSAPrivateCrtKeyParameters(k.getModulus(), k.getPublicExponent(), k.getPrivateExponent(),
                k.getPrimeP(), k.getPrimeQ(), k.getPrimeExponentP(), k.getPrimeExponentQ(),
                k.getCrtCoefficient());//  w w w  .j ava2s . c o  m
    } else {
        RSAPrivateKey k = key;
        return new RSAKeyParameters(true, k.getModulus(), k.getPrivateExponent());
    }
}