what-the-bank/sources/o/XFe.java

59 lines
2.9 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import android.security.keystore.KeyGenParameterSpec;
import com.google.android.gms.stats.CodePackage;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.ProviderException;
import java.util.Arrays;
import javax.crypto.KeyGenerator;
@Deprecated
/* loaded from: classes.dex */
public final class XFe {
static {
new KeyGenParameterSpec.Builder("_androidx_security_master_key_", 3).setBlockModes(CodePackage.GCM).setEncryptionPaddings("NoPadding").setKeySize(256).build();
}
public static String AO_(KeyGenParameterSpec keyGenParameterSpec) throws GeneralSecurityException, IOException {
if (keyGenParameterSpec.getKeySize() != 256) {
StringBuilder sb = new StringBuilder("invalid key size, want 256 bits got ");
sb.append(keyGenParameterSpec.getKeySize());
sb.append(" bits");
throw new IllegalArgumentException(sb.toString());
}
if (!Arrays.equals(keyGenParameterSpec.getBlockModes(), new String[]{CodePackage.GCM})) {
StringBuilder sb2 = new StringBuilder("invalid block mode, want GCM got ");
sb2.append(Arrays.toString(keyGenParameterSpec.getBlockModes()));
throw new IllegalArgumentException(sb2.toString());
}
if (keyGenParameterSpec.getPurposes() != 3) {
StringBuilder sb3 = new StringBuilder("invalid purposes mode, want PURPOSE_ENCRYPT | PURPOSE_DECRYPT got ");
sb3.append(keyGenParameterSpec.getPurposes());
throw new IllegalArgumentException(sb3.toString());
}
if (!Arrays.equals(keyGenParameterSpec.getEncryptionPaddings(), new String[]{"NoPadding"})) {
StringBuilder sb4 = new StringBuilder("invalid padding mode, want NoPadding got ");
sb4.append(Arrays.toString(keyGenParameterSpec.getEncryptionPaddings()));
throw new IllegalArgumentException(sb4.toString());
}
if (!keyGenParameterSpec.isUserAuthenticationRequired() || keyGenParameterSpec.getUserAuthenticationValidityDurationSeconds() > 0) {
String keystoreAlias = keyGenParameterSpec.getKeystoreAlias();
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(null);
if (!keyStore.containsAlias(keystoreAlias)) {
try {
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES", "AndroidKeyStore");
keyGenerator.init(keyGenParameterSpec);
keyGenerator.generateKey();
} catch (ProviderException e) {
throw new GeneralSecurityException(e.getMessage(), e);
}
}
return keyGenParameterSpec.getKeystoreAlias();
}
throw new IllegalArgumentException("per-operation authentication is not supported (UserAuthenticationValidityDurationSeconds must be >0)");
}
}