Code example for RSAPrivateCrtKey

Methods: getCrtCoefficient, getModulus, getPrimeExponentP, getPrimeExponentQ, getPrimeP, getPrimeQ, getPrivateExponent, getPublicExponent

0
            throw new InvalidKeySpecException(e);
        } 
    } 
 
    static OpenSSLKey getInstance(RSAPrivateCrtKey rsaPrivateKey) throws InvalidKeyException {
        BigInteger modulus = rsaPrivateKey.getModulus();
        BigInteger privateExponent = rsaPrivateKey.getPrivateExponent();
 
        if (modulus == null) {
            throw new InvalidKeyException("modulus == null");
        } else if (privateExponent == null) {
            throw new InvalidKeyException("privateExponent == null");
        } 
 
        try { 
            /* 
             * OpenSSL uses the public modulus to do RSA blinding. If 
             * the public modulus is not available, the call to 
             * EVP_PKEY_new_RSA will turn off blinding for this key 
             * instance. 
             */ 
            final BigInteger publicExponent = rsaPrivateKey.getPublicExponent();
            final BigInteger primeP = rsaPrivateKey.getPrimeP();
            final BigInteger primeQ = rsaPrivateKey.getPrimeQ();
            final BigInteger primeExponentP = rsaPrivateKey.getPrimeExponentP();
            final BigInteger primeExponentQ = rsaPrivateKey.getPrimeExponentQ();
            final BigInteger crtCoefficient = rsaPrivateKey.getCrtCoefficient();
 
            return new OpenSSLKey(NativeCrypto.EVP_PKEY_new_RSA( 
                    modulus.toByteArray(),
                    publicExponent == null ? null : publicExponent.toByteArray(),
                    privateExponent.toByteArray(),