1 package org.bouncycastle.crypto;
3 import java.security.SecureRandom;
6 * The base class for symmetric, or secret, cipher key generators.
8 public class CipherKeyGenerator
10 protected SecureRandom random;
11 protected int strength;
14 * initialise the key generator.
16 * @param param the parameters to be used for key generation
19 KeyGenerationParameters param)
21 this.random = param.getRandom();
22 this.strength = (param.getStrength() + 7) / 8;
26 * generate a secret key.
28 * @return a byte array containing the key value.
30 public byte[] generateKey()
32 byte[] key = new byte[strength];
34 random.nextBytes(key);