Search in sources :

Example 6 with KeyGenerationParameters

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

the class CipherProvider method generateKey.

private byte[] generateKey() {
    SecureRandom random = new SecureRandom();
    random.setSeed(UUID.randomUUID().toString().getBytes());
    KeyGenerationParameters generationParameters = new KeyGenerationParameters(random, DESParameters.DES_KEY_LENGTH * 8);
    DESKeyGenerator generator = new DESKeyGenerator();
    generator.init(generationParameters);
    return Hex.encode(generator.generateKey());
}
Also used : DESKeyGenerator(org.bouncycastle.crypto.generators.DESKeyGenerator) SecureRandom(java.security.SecureRandom) KeyGenerationParameters(org.bouncycastle.crypto.KeyGenerationParameters)

Example 7 with KeyGenerationParameters

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

the class JCEKeyGenerator 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)

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