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

137 lines
5.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
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.asn1.cryptopro.CryptoProObjectIdentifiers;
import org.bouncycastle.crypto.BufferedBlockCipher;
import org.bouncycastle.crypto.CipherKeyGenerator;
import org.bouncycastle.crypto.engines.GOST28147Engine;
import org.bouncycastle.crypto.macs.GOST28147Mac;
import org.bouncycastle.crypto.modes.CBCBlockCipher;
import org.bouncycastle.crypto.modes.GCFBBlockCipher;
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.IvAlgorithmParameters;
import org.bouncycastle.jcajce.provider.util.AlgorithmProvider;
/* loaded from: classes6.dex */
public final class GOST28147 {
/* 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 GOST28147 parameter generation.");
}
@Override // java.security.AlgorithmParameterGeneratorSpi
protected AlgorithmParameters engineGenerateParameters() {
byte[] bArr = new byte[16];
if (this.random == null) {
this.random = new SecureRandom();
}
this.random.nextBytes(bArr);
try {
AlgorithmParameters createParametersInstance = createParametersInstance("GOST28147");
createParametersInstance.init(new IvParameterSpec(bArr));
return createParametersInstance;
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
}
/* loaded from: classes6.dex */
public static class Mappings extends AlgorithmProvider {
private static final String PREFIX = GOST28147.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("$ECB");
configurableProvider.addAlgorithm("Cipher.GOST28147", sb.toString());
configurableProvider.addAlgorithm("Alg.Alias.Cipher.GOST", "GOST28147");
configurableProvider.addAlgorithm("Alg.Alias.Cipher.GOST-28147", "GOST28147");
StringBuilder sb2 = new StringBuilder("Cipher.");
sb2.append(CryptoProObjectIdentifiers.gostR28147_gcfb);
String obj = sb2.toString();
StringBuilder sb3 = new StringBuilder();
sb3.append(str);
sb3.append("$GCFB");
configurableProvider.addAlgorithm(obj, sb3.toString());
StringBuilder sb4 = new StringBuilder();
sb4.append(str);
sb4.append("$KeyGen");
configurableProvider.addAlgorithm("KeyGenerator.GOST28147", sb4.toString());
configurableProvider.addAlgorithm("Alg.Alias.KeyGenerator.GOST", "GOST28147");
configurableProvider.addAlgorithm("Alg.Alias.KeyGenerator.GOST-28147", "GOST28147");
StringBuilder sb5 = new StringBuilder("Alg.Alias.KeyGenerator.");
sb5.append(CryptoProObjectIdentifiers.gostR28147_gcfb);
configurableProvider.addAlgorithm(sb5.toString(), "GOST28147");
StringBuilder sb6 = new StringBuilder();
sb6.append(str);
sb6.append("$Mac");
configurableProvider.addAlgorithm("Mac.GOST28147MAC", sb6.toString());
configurableProvider.addAlgorithm("Alg.Alias.Mac.GOST28147", "GOST28147MAC");
}
}
/* 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 "GOST IV";
}
}
/* loaded from: classes6.dex */
public static class KeyGen extends BaseKeyGenerator {
public KeyGen(int i) {
super("GOST28147", i, new CipherKeyGenerator());
}
public KeyGen() {
this(256);
}
}
/* loaded from: classes6.dex */
public static class CBC extends BaseBlockCipher {
public CBC() {
super(new CBCBlockCipher(new GOST28147Engine()), 64);
}
}
/* loaded from: classes6.dex */
public static class ECB extends BaseBlockCipher {
public ECB() {
super(new GOST28147Engine());
}
}
/* loaded from: classes6.dex */
public static class GCFB extends BaseBlockCipher {
public GCFB() {
super(new BufferedBlockCipher(new GCFBBlockCipher(new GOST28147Engine())), 64);
}
}
/* loaded from: classes6.dex */
public static class Mac extends BaseMac {
public Mac() {
super(new GOST28147Mac());
}
}
private GOST28147() {
}
}