what-the-bank/sources/org/bouncycastle/crypto/generators/DESKeyGenerator.java

29 lines
1009 B
Java

package org.bouncycastle.crypto.generators;
import org.bouncycastle.crypto.CipherKeyGenerator;
import org.bouncycastle.crypto.KeyGenerationParameters;
import org.bouncycastle.crypto.params.DESParameters;
/* loaded from: classes6.dex */
public class DESKeyGenerator extends CipherKeyGenerator {
@Override // org.bouncycastle.crypto.CipherKeyGenerator
public void init(KeyGenerationParameters keyGenerationParameters) {
super.init(keyGenerationParameters);
if (this.strength == 0 || this.strength == 7) {
this.strength = 8;
} else if (this.strength != 8) {
throw new IllegalArgumentException("DES key must be 64 bits long.");
}
}
@Override // org.bouncycastle.crypto.CipherKeyGenerator
public byte[] generateKey() {
byte[] bArr = new byte[8];
do {
this.random.nextBytes(bArr);
DESParameters.setOddParity(bArr);
} while (DESParameters.isWeakKey(bArr, 0));
return bArr;
}
}