Java 8 RSAPrivateCrtKey - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 RSAPrivateCrtKey class.

This code example shows how to use the following methods: getModulus, getCrtCoefficient, getPrimeExponentP, getPrimeExponentQ, getPrimeP
		} else if (format != null && format.equalsIgnoreCase("PKCS#1")
				&& key instanceof RSAPrivateCrtKey) {
			// this condition will rarely be true 
			RSAPrivateCrtKey pKey = (RSAPrivateCrtKey) key;
			RSAPrivateKeyStructure st = new RSAPrivateKeyStructure(pKey
					.getModulus(), pKey.getPublicExponent(), pKey
					.getPrivateExponent(), pKey.getPrimeP(), pKey.getPrimeQ(),
					pKey.getPrimeExponentP(), pKey.getPrimeExponentQ(), pKey
							.getCrtCoefficient());
			ASN1Primitive ob = st.toASN1Primitive();
 
			try { 
				return BouncyCastleUtil.toByteArray(ob);
			} catch (IOException e) {
				// that should never happen 
				return new byte[0]; 
			} 
		} else { 
			return new byte[0]; 
		} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getPrimeP, getPrimeQ, getPrivateExponent
 
        if (privateKey instanceof  RSAPrivateCrtKey)
        { 
            RSAPrivateCrtKey rsK = (RSAPrivateCrtKey)privateKey;
 
            privateKeyDataPacket = new RSASecretBCPGKey(rsK.getPrivateExponent(), rsK.getPrimeP(), rsK.getPrimeQ());
        } 
        else if (privateKey instanceof DSAPrivateKey)
        { 
            DSAPrivateKey dsK = (DSAPrivateKey)privateKey;
 
            privateKeyDataPacket = new DSASecretBCPGKey(dsK.getX());
        } 
        else if (privateKey instanceof  ElGamalPrivateKey)
        { 
            ElGamalPrivateKey esK = (ElGamalPrivateKey)privateKey;
 
            privateKeyDataPacket = new ElGamalSecretBCPGKey(esK.getX());
        } 
        else 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getModulus, getCrtCoefficient, getPrimeExponentP, getPrimeExponentQ, getPrimeP
            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. 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getModulus, getCrtCoefficient, getPrimeExponentP, getPrimeExponentQ, getPrimeP
    { 
        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 
        { 
            RSAPrivateKey k = key;
 
            return new RSAKeyParameters(true, k.getModulus(), k.getPrivateExponent());
        } 
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getCrtCoefficient, getPrimeExponentP, getPrimeExponentQ, getPrimeP, getPrimeQ
 
        rsaKeyPair = new RSAKeyPair();
 
        rsaKeyPair.setModulus(crtPubKey.getModulus().toByteArray());
   
        rsaKeyPair.setExponent(crtPriKey.getPublicExponent().toByteArray());
        rsaKeyPair.setP(crtPriKey.getPrimeP().toByteArray());
        rsaKeyPair.setQ(crtPriKey.getPrimeQ().toByteArray());
        rsaKeyPair.setDP(crtPriKey.getPrimeExponentP().toByteArray());
        rsaKeyPair.setDQ(crtPriKey.getPrimeExponentQ().toByteArray());
        rsaKeyPair.setInverseQ(crtPriKey.getCrtCoefficient().toByteArray());
        rsaKeyPair.setD(crtPriKey.getPrivateExponent().toByteArray());
    } 
 
    public KeyPair getRSAKeyPair() {
        if (rsaKeyPair == null) {
            if (encryptedData != null && key != null) {
                try { 
                    decryptData(key, encryptedData.getOwnerDocument());
                } catch (XKMSException e) {
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 RSAPrivateCrtKey Methods: