Java 8 RSAKey - 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 RSAKey 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]; 
		} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
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());
        } 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getModulus, getPublicExponent
This code example shows how to use the following methods:getModulus, getCrtCoefficient, getPrimeExponentP, getPrimeExponentQ, getPrimeP
        else if (spec.isAssignableFrom(RSAPrivateCrtKeySpec.class) && key instanceof RSAPrivateCrtKey)
        { 
            RSAPrivateCrtKey k = (RSAPrivateCrtKey)key;
 
            return new RSAPrivateCrtKeySpec(
                k.getModulus(), k.getPublicExponent(),
                k.getPrivateExponent(),
                k.getPrimeP(), k.getPrimeQ(),
                k.getPrimeExponentP(), k.getPrimeExponentQ(),
                k.getCrtCoefficient());
        } 
 
        return super.engineGetKeySpec(key, spec);
    } 
 
    protected Key engineTranslateKey(
        Key key)
        throws InvalidKeyException 
    { 
        if (key instanceof RSAPublicKey)
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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. 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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());
        } 
    } 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getModulus, getCrtCoefficient, getPrimeExponentP, getPrimeExponentQ, getPrimeP
            fail("public key 2 exponent mismatch"); 
        } 
 
        RSAPrivateCrtKey priv = (RSAPrivateCrtKey)readObject(rsaPriv);
 
        if (!mod.equals(priv.getModulus()))
        { 
            fail("private key modulus mismatch"); 
        } 
        if (!privExp.equals(priv.getPrivateExponent()))
        { 
            fail("private key exponent mismatch"); 
        } 
        if (!p.equals(priv.getPrimeP()))
        { 
            fail("private key p mismatch"); 
        } 
        if (!q.equals(priv.getPrimeQ()))
        { 
            fail("private key q mismatch"); 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getModulus, getCrtCoefficient, getPrimeExponentP, getPrimeExponentQ, getPrimeP
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());
        } 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 RSAKey Methods: