Search in sources :

Example 46 with ProviderException

use of java.security.ProviderException in project android_frameworks_base by AOSPA.

the class AndroidKeyStoreKeyPairGeneratorSpi method generateKeystoreKeyPair.

private void generateKeystoreKeyPair(final String privateKeyAlias, KeymasterArguments args, byte[] additionalEntropy, final int flags) throws ProviderException {
    KeyCharacteristics resultingKeyCharacteristics = new KeyCharacteristics();
    int errorCode = mKeyStore.generateKey(privateKeyAlias, args, additionalEntropy, mEntryUid, flags, resultingKeyCharacteristics);
    if (errorCode != KeyStore.NO_ERROR) {
        throw new ProviderException("Failed to generate key pair", KeyStore.getKeyStoreException(errorCode));
    }
}
Also used : ProviderException(java.security.ProviderException) KeyCharacteristics(android.security.keymaster.KeyCharacteristics)

Example 47 with ProviderException

use of java.security.ProviderException in project robovm by robovm.

the class ProviderExceptionTest method testProviderException09.

/**
     * Test for <code>ProviderException(String, Throwable)</code> constructor
     * Assertion: constructs ProviderException when <code>cause</code> is not
     * null <code>msg</code> is not null
     */
public void testProviderException09() {
    ProviderException tE;
    for (int i = 0; i < msgs.length; i++) {
        tE = new ProviderException(msgs[i], tCause);
        String getM = tE.getMessage();
        String toS = tCause.toString();
        if (msgs[i].length() > 0) {
            assertTrue("getMessage() must contain ".concat(msgs[i]), getM.indexOf(msgs[i]) != -1);
            if (!getM.equals(msgs[i])) {
                assertTrue("getMessage() should contain ".concat(toS), getM.indexOf(toS) != -1);
            }
        }
        assertNotNull("getCause() must not return null", tE.getCause());
        assertEquals("getCause() must return ".concat(tCause.toString()), tE.getCause(), tCause);
    }
}
Also used : ProviderException(java.security.ProviderException)

Example 48 with ProviderException

use of java.security.ProviderException in project robovm by robovm.

the class ProviderExceptionTest method testProviderException04.

/**
     * Test for <code>ProviderException(Throwable)</code> constructor
     * Assertion: constructs ProviderException when <code>cause</code> is null
     */
public void testProviderException04() {
    Throwable cause = null;
    ProviderException tE = new ProviderException(cause);
    assertNull("getMessage() must return null.", tE.getMessage());
    assertNull("getCause() must return null", tE.getCause());
}
Also used : ProviderException(java.security.ProviderException)

Example 49 with ProviderException

use of java.security.ProviderException in project jdk8u_jdk by JetBrains.

the class RSAPublicKey method getPublicExponent.

/**
     * Returns the public exponent.
     */
public BigInteger getPublicExponent() {
    if (exponent == null) {
        try {
            publicKeyBlob = getPublicKeyBlob(handles.hCryptKey);
            exponent = new BigInteger(1, getExponent(publicKeyBlob));
        } catch (KeyException e) {
            throw new ProviderException(e);
        }
    }
    return exponent;
}
Also used : ProviderException(java.security.ProviderException) BigInteger(java.math.BigInteger) KeyException(java.security.KeyException)

Example 50 with ProviderException

use of java.security.ProviderException in project jdk8u_jdk by JetBrains.

the class RSAPublicKey method getModulus.

/**
     * Returns the modulus.
     */
public BigInteger getModulus() {
    if (modulus == null) {
        try {
            publicKeyBlob = getPublicKeyBlob(handles.hCryptKey);
            modulus = new BigInteger(1, getModulus(publicKeyBlob));
        } catch (KeyException e) {
            throw new ProviderException(e);
        }
    }
    return modulus;
}
Also used : ProviderException(java.security.ProviderException) BigInteger(java.math.BigInteger) KeyException(java.security.KeyException)

Aggregations

ProviderException (java.security.ProviderException)128 KeymasterArguments (android.security.keymaster.KeymasterArguments)30 InvalidKeyException (java.security.InvalidKeyException)26 OperationResult (android.security.keymaster.OperationResult)25 KeyStoreException (android.security.KeyStoreException)20 KeyCharacteristics (android.security.keymaster.KeyCharacteristics)20 DERBitString (com.android.org.bouncycastle.asn1.DERBitString)15 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)15 BigInteger (java.math.BigInteger)13 IOException (java.io.IOException)12 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)12 ASN1Integer (com.android.org.bouncycastle.asn1.ASN1Integer)10 DERInteger (com.android.org.bouncycastle.asn1.DERInteger)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 RSAKeyGenParameterSpec (java.security.spec.RSAKeyGenParameterSpec)10 GeneralSecurityException (java.security.GeneralSecurityException)6 KeyStoreException (java.security.KeyStoreException)6 NoSuchProviderException (java.security.NoSuchProviderException)6 KeymasterCertificateChain (android.security.keymaster.KeymasterCertificateChain)5 KeyProtection (android.security.keystore.KeyProtection)5