package org.bouncycastle.jcajce.provider.symmetric; import java.io.IOException; import java.security.spec.AlgorithmParameterSpec; import java.security.spec.InvalidParameterSpecException; import javax.crypto.spec.PBEParameterSpec; import org.bouncycastle.asn1.ASN1Encoding; import org.bouncycastle.asn1.ASN1Primitive; import org.bouncycastle.asn1.pkcs.PKCS12PBEParams; import org.bouncycastle.jcajce.provider.config.ConfigurableProvider; import org.bouncycastle.jcajce.provider.symmetric.util.BaseAlgorithmParameters; import org.bouncycastle.jcajce.provider.util.AlgorithmProvider; /* loaded from: classes6.dex */ public class PBEPKCS12 { /* loaded from: classes6.dex */ public static class AlgParams extends BaseAlgorithmParameters { PKCS12PBEParams params; @Override // org.bouncycastle.jcajce.provider.symmetric.util.BaseAlgorithmParameters public AlgorithmParameterSpec localEngineGetParameterSpec(Class cls) throws InvalidParameterSpecException { if (cls == PBEParameterSpec.class) { return new PBEParameterSpec(this.params.getIV(), this.params.getIterations().intValue()); } throw new InvalidParameterSpecException("unknown parameter spec passed to PKCS12 PBE parameters object."); } @Override // java.security.AlgorithmParametersSpi protected String engineToString() { return "PKCS12 PBE Parameters"; } @Override // java.security.AlgorithmParametersSpi protected void engineInit(byte[] bArr, String str) throws IOException { if (!isASN1FormatString(str)) { throw new IOException("Unknown parameters format in PKCS12 PBE parameters object"); } engineInit(bArr); } @Override // java.security.AlgorithmParametersSpi protected void engineInit(byte[] bArr) throws IOException { this.params = PKCS12PBEParams.getInstance(ASN1Primitive.fromByteArray(bArr)); } @Override // java.security.AlgorithmParametersSpi protected void engineInit(AlgorithmParameterSpec algorithmParameterSpec) throws InvalidParameterSpecException { if (!(algorithmParameterSpec instanceof PBEParameterSpec)) { throw new InvalidParameterSpecException("PBEParameterSpec required to initialise a PKCS12 PBE parameters algorithm parameters object"); } PBEParameterSpec pBEParameterSpec = (PBEParameterSpec) algorithmParameterSpec; this.params = new PKCS12PBEParams(pBEParameterSpec.getSalt(), pBEParameterSpec.getIterationCount()); } @Override // java.security.AlgorithmParametersSpi protected byte[] engineGetEncoded(String str) { if (isASN1FormatString(str)) { return engineGetEncoded(); } return null; } @Override // java.security.AlgorithmParametersSpi protected byte[] engineGetEncoded() { try { return this.params.getEncoded(ASN1Encoding.DER); } catch (IOException e) { StringBuilder sb = new StringBuilder("Oooops! "); sb.append(e.toString()); throw new RuntimeException(sb.toString()); } } } /* loaded from: classes6.dex */ public static class Mappings extends AlgorithmProvider { private static final String PREFIX = PBEPKCS12.class.getName(); @Override // org.bouncycastle.jcajce.provider.util.AlgorithmProvider public void configure(ConfigurableProvider configurableProvider) { StringBuilder sb = new StringBuilder(); sb.append(PREFIX); sb.append("$AlgParams"); configurableProvider.addAlgorithm("AlgorithmParameters.PKCS12PBE", sb.toString()); } } private PBEPKCS12() { } }