Example usage for java.security.interfaces RSAPrivateCrtKey getCrtCoefficient

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

Introduction

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

Prototype

public BigInteger getCrtCoefficient();

Source Link

Document

Returns the crtCoefficient.

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());
    } else {/* www.  j av  a  2  s  .c  om*/
        RSAPrivateKey k = key;
        return new RSAKeyParameters(true, k.getModulus(), k.getPrivateExponent());
    }
}