01: package org.bouncycastle.crypto.generators;
02:
03: import org.bouncycastle.crypto.CipherKeyGenerator;
04: import org.bouncycastle.crypto.params.DESParameters;
05:
06: public class DESKeyGenerator extends CipherKeyGenerator {
07: public byte[] generateKey() {
08: byte[] newKey = new byte[DESParameters.DES_KEY_LENGTH];
09:
10: do {
11: random.nextBytes(newKey);
12:
13: DESParameters.setOddParity(newKey);
14: } while (DESParameters.isWeakKey(newKey, 0));
15:
16: return newKey;
17: }
18: }
|