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

108 lines
3.2 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.jcajce.provider.symmetric.util;
import javax.crypto.interfaces.PBEKey;
import javax.crypto.spec.PBEKeySpec;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.PBEParametersGenerator;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.params.ParametersWithIV;
/* loaded from: classes6.dex */
public class BCPBEKey implements PBEKey {
String algorithm;
int digest;
int ivSize;
int keySize;
ASN1ObjectIdentifier oid;
CipherParameters param;
PBEKeySpec pbeKeySpec;
boolean tryWrong = false;
int type;
/* JADX INFO: Access modifiers changed from: package-private */
public boolean shouldTryWrongPKCS12() {
return this.tryWrong;
}
public void setTryWrongPKCS12Zero(boolean z) {
this.tryWrong = z;
}
/* JADX INFO: Access modifiers changed from: package-private */
public int getType() {
return this.type;
}
@Override // javax.crypto.interfaces.PBEKey
public byte[] getSalt() {
return this.pbeKeySpec.getSalt();
}
@Override // javax.crypto.interfaces.PBEKey
public char[] getPassword() {
return this.pbeKeySpec.getPassword();
}
public CipherParameters getParam() {
return this.param;
}
public ASN1ObjectIdentifier getOID() {
return this.oid;
}
/* JADX INFO: Access modifiers changed from: package-private */
public int getKeySize() {
return this.keySize;
}
public int getIvSize() {
return this.ivSize;
}
@Override // javax.crypto.interfaces.PBEKey
public int getIterationCount() {
return this.pbeKeySpec.getIterationCount();
}
@Override // java.security.Key
public String getFormat() {
return "RAW";
}
@Override // java.security.Key
public byte[] getEncoded() {
CipherParameters cipherParameters = this.param;
if (cipherParameters == null) {
int i = this.type;
return i == 2 ? PBEParametersGenerator.PKCS12PasswordToBytes(this.pbeKeySpec.getPassword()) : i == 5 ? PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(this.pbeKeySpec.getPassword()) : PBEParametersGenerator.PKCS5PasswordToBytes(this.pbeKeySpec.getPassword());
}
if (cipherParameters instanceof ParametersWithIV) {
cipherParameters = ((ParametersWithIV) cipherParameters).getParameters();
}
return ((KeyParameter) cipherParameters).getKey();
}
/* JADX INFO: Access modifiers changed from: package-private */
public int getDigest() {
return this.digest;
}
@Override // java.security.Key
public String getAlgorithm() {
return this.algorithm;
}
public BCPBEKey(String str, ASN1ObjectIdentifier aSN1ObjectIdentifier, int i, int i2, int i3, int i4, PBEKeySpec pBEKeySpec, CipherParameters cipherParameters) {
this.algorithm = str;
this.oid = aSN1ObjectIdentifier;
this.type = i;
this.digest = i2;
this.keySize = i3;
this.ivSize = i4;
this.pbeKeySpec = pBEKeySpec;
this.param = cipherParameters;
}
}