what-the-bank/sources/org/bouncycastle/jcajce/provider/symmetric/Shacal2.java

138 lines
5.8 KiB
Java

package org.bouncycastle.jcajce.provider.symmetric;
import java.security.AlgorithmParameters;
import java.security.InvalidAlgorithmParameterException;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.spec.IvParameterSpec;
import org.bouncycastle.crypto.BlockCipher;
import org.bouncycastle.crypto.CipherKeyGenerator;
import org.bouncycastle.crypto.engines.Shacal2Engine;
import org.bouncycastle.crypto.macs.CMac;
import org.bouncycastle.crypto.modes.CBCBlockCipher;
import org.bouncycastle.jcajce.provider.config.ConfigurableProvider;
import org.bouncycastle.jcajce.provider.symmetric.util.BaseAlgorithmParameterGenerator;
import org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher;
import org.bouncycastle.jcajce.provider.symmetric.util.BaseKeyGenerator;
import org.bouncycastle.jcajce.provider.symmetric.util.BaseMac;
import org.bouncycastle.jcajce.provider.symmetric.util.BlockCipherProvider;
import org.bouncycastle.jcajce.provider.symmetric.util.IvAlgorithmParameters;
/* loaded from: classes6.dex */
public final class Shacal2 {
/* loaded from: classes6.dex */
public static class AlgParamGen extends BaseAlgorithmParameterGenerator {
@Override // java.security.AlgorithmParameterGeneratorSpi
protected void engineInit(AlgorithmParameterSpec algorithmParameterSpec, SecureRandom secureRandom) throws InvalidAlgorithmParameterException {
throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for Shacal2 parameter generation.");
}
@Override // java.security.AlgorithmParameterGeneratorSpi
protected AlgorithmParameters engineGenerateParameters() {
byte[] bArr = new byte[32];
if (this.random == null) {
this.random = new SecureRandom();
}
this.random.nextBytes(bArr);
try {
AlgorithmParameters createParametersInstance = createParametersInstance("Shacal2");
createParametersInstance.init(new IvParameterSpec(bArr));
return createParametersInstance;
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
}
/* loaded from: classes6.dex */
public static class Mappings extends SymmetricAlgorithmProvider {
private static final String PREFIX = Shacal2.class.getName();
@Override // org.bouncycastle.jcajce.provider.util.AlgorithmProvider
public void configure(ConfigurableProvider configurableProvider) {
StringBuilder sb = new StringBuilder();
String str = PREFIX;
sb.append(str);
sb.append("$CMAC");
configurableProvider.addAlgorithm("Mac.Shacal-2CMAC", sb.toString());
StringBuilder sb2 = new StringBuilder();
sb2.append(str);
sb2.append("$ECB");
configurableProvider.addAlgorithm("Cipher.Shacal2", sb2.toString());
StringBuilder sb3 = new StringBuilder();
sb3.append(str);
sb3.append("$ECB");
configurableProvider.addAlgorithm("Cipher.SHACAL-2", sb3.toString());
StringBuilder sb4 = new StringBuilder();
sb4.append(str);
sb4.append("$KeyGen");
configurableProvider.addAlgorithm("KeyGenerator.Shacal2", sb4.toString());
StringBuilder sb5 = new StringBuilder();
sb5.append(str);
sb5.append("$AlgParamGen");
configurableProvider.addAlgorithm("AlgorithmParameterGenerator.Shacal2", sb5.toString());
StringBuilder sb6 = new StringBuilder();
sb6.append(str);
sb6.append("$AlgParams");
configurableProvider.addAlgorithm("AlgorithmParameters.Shacal2", sb6.toString());
StringBuilder sb7 = new StringBuilder();
sb7.append(str);
sb7.append("$KeyGen");
configurableProvider.addAlgorithm("KeyGenerator.SHACAL-2", sb7.toString());
StringBuilder sb8 = new StringBuilder();
sb8.append(str);
sb8.append("$AlgParamGen");
configurableProvider.addAlgorithm("AlgorithmParameterGenerator.SHACAL-2", sb8.toString());
StringBuilder sb9 = new StringBuilder();
sb9.append(str);
sb9.append("$AlgParams");
configurableProvider.addAlgorithm("AlgorithmParameters.SHACAL-2", sb9.toString());
}
}
/* loaded from: classes6.dex */
public static class AlgParams extends IvAlgorithmParameters {
@Override // org.bouncycastle.jcajce.provider.symmetric.util.IvAlgorithmParameters, java.security.AlgorithmParametersSpi
public String engineToString() {
return "Shacal2 IV";
}
}
/* loaded from: classes6.dex */
public static class CBC extends BaseBlockCipher {
public CBC() {
super(new CBCBlockCipher(new Shacal2Engine()), 256);
}
}
/* loaded from: classes6.dex */
public static class CMAC extends BaseMac {
public CMAC() {
super(new CMac(new Shacal2Engine()));
}
}
/* loaded from: classes6.dex */
public static class ECB extends BaseBlockCipher {
public ECB() {
super(new BlockCipherProvider() { // from class: org.bouncycastle.jcajce.provider.symmetric.Shacal2.ECB.1
@Override // org.bouncycastle.jcajce.provider.symmetric.util.BlockCipherProvider
public BlockCipher get() {
return new Shacal2Engine();
}
});
}
}
/* loaded from: classes6.dex */
public static class KeyGen extends BaseKeyGenerator {
public KeyGen() {
super("SHACAL-2", 128, new CipherKeyGenerator());
}
}
private Shacal2() {
}
}