Search in sources :

Example 1 with KeyGenerationParameters

use of org.bouncycastle.crypto.KeyGenerationParameters in project robovm by robovm.

the class BaseKeyGenerator method engineInit.

protected void engineInit(int keySize, SecureRandom random) {
    try {
        if (random == null) {
            random = new SecureRandom();
        }
        engine.init(new KeyGenerationParameters(random, keySize));
        uninitialised = false;
    } catch (IllegalArgumentException e) {
        throw new InvalidParameterException(e.getMessage());
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) SecureRandom(java.security.SecureRandom) KeyGenerationParameters(org.bouncycastle.crypto.KeyGenerationParameters)

Example 2 with KeyGenerationParameters

use of org.bouncycastle.crypto.KeyGenerationParameters in project robovm by robovm.

the class BaseKeyGenerator method engineInit.

protected void engineInit(SecureRandom random) {
    if (random != null) {
        engine.init(new KeyGenerationParameters(random, defaultKeySize));
        uninitialised = false;
    }
}
Also used : KeyGenerationParameters(org.bouncycastle.crypto.KeyGenerationParameters)

Example 3 with KeyGenerationParameters

use of org.bouncycastle.crypto.KeyGenerationParameters in project robovm by robovm.

the class BaseKeyGenerator method engineGenerateKey.

protected SecretKey engineGenerateKey() {
    if (uninitialised) {
        engine.init(new KeyGenerationParameters(new SecureRandom(), defaultKeySize));
        uninitialised = false;
    }
    return new SecretKeySpec(engine.generateKey(), algName);
}
Also used : SecretKeySpec(javax.crypto.spec.SecretKeySpec) SecureRandom(java.security.SecureRandom) KeyGenerationParameters(org.bouncycastle.crypto.KeyGenerationParameters)

Example 4 with KeyGenerationParameters

use of org.bouncycastle.crypto.KeyGenerationParameters in project XobotOS by xamarin.

the class JCEKeyGenerator method engineGenerateKey.

protected SecretKey engineGenerateKey() {
    if (uninitialised) {
        engine.init(new KeyGenerationParameters(new SecureRandom(), defaultKeySize));
        uninitialised = false;
    }
    return new SecretKeySpec(engine.generateKey(), algName);
}
Also used : SecretKeySpec(javax.crypto.spec.SecretKeySpec) SecureRandom(java.security.SecureRandom) KeyGenerationParameters(org.bouncycastle.crypto.KeyGenerationParameters)

Example 5 with KeyGenerationParameters

use of org.bouncycastle.crypto.KeyGenerationParameters in project XobotOS by xamarin.

the class JCEKeyGenerator method engineInit.

protected void engineInit(int keySize, SecureRandom random) {
    try {
        // BEGIN android-added
        if (random == null) {
            random = new SecureRandom();
        }
        // END android-added
        engine.init(new KeyGenerationParameters(random, keySize));
        uninitialised = false;
    } catch (IllegalArgumentException e) {
        throw new InvalidParameterException(e.getMessage());
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) SecureRandom(java.security.SecureRandom) KeyGenerationParameters(org.bouncycastle.crypto.KeyGenerationParameters)

Aggregations

KeyGenerationParameters (org.bouncycastle.crypto.KeyGenerationParameters)7 SecureRandom (java.security.SecureRandom)5 InvalidParameterException (java.security.InvalidParameterException)2 SecretKeySpec (javax.crypto.spec.SecretKeySpec)2 DESKeyGenerator (org.bouncycastle.crypto.generators.DESKeyGenerator)1