what-the-bank/sources/org/jmrtd/cert/CVCertificateBuilder.java

123 lines
5.7 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.jmrtd.cert;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
import java.security.SignatureException;
import java.util.Date;
import o.C15290gme;
import o.C15294gmi;
import o.InterfaceC15241glC;
import o.InterfaceC15243glE;
import o.glH;
import o.glK;
import o.glL;
import o.glQ;
import o.glS;
import o.glW;
import org.ejbca.cvc.AccessRightEnum;
import org.ejbca.cvc.AuthorizationRoleEnum;
import org.ejbca.cvc.CVCertificate;
import org.ejbca.cvc.exception.ConstructionException;
import org.jmrtd.cert.CVCAuthorizationTemplate;
/* loaded from: classes6.dex */
public class CVCertificateBuilder {
public static CardVerifiableCertificate createCertificate(PublicKey publicKey, PrivateKey privateKey, String str, CVCPrincipal cVCPrincipal, CVCPrincipal cVCPrincipal2, CVCAuthorizationTemplate cVCAuthorizationTemplate, Date date, Date date2, String str2) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException, SignatureException, ConstructionException {
glL gll = new glL(cVCPrincipal.getCountry().toAlpha2Code(), cVCPrincipal.getMnemonic(), cVCPrincipal.getSeqNumber());
glW glw = new glW(cVCPrincipal2.getCountry().toAlpha2Code(), cVCPrincipal2.getMnemonic(), cVCPrincipal2.getSeqNumber());
AuthorizationRoleEnum role = getRole(cVCAuthorizationTemplate.getRole());
CVCertificate cVCertificate = new CVCertificate(new glQ(gll, C15290gme.e(publicKey, str, role), glw, (InterfaceC15243glE) role, (InterfaceC15241glC) getAccessRight(cVCAuthorizationTemplate.getAccessRight()), date, date2));
Signature signature = Signature.getInstance(glH.e(str), str2);
signature.initSign(privateKey);
signature.update(cVCertificate.f());
cVCertificate.c(new glK(glS.SIGNATURE, C15294gmi.c(str, signature.sign())));
return new CardVerifiableCertificate(cVCertificate);
}
private static AuthorizationRoleEnum getRole(CVCAuthorizationTemplate.Role role) {
int i = AnonymousClass1.$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role[role.ordinal()];
if (i == 1) {
return AuthorizationRoleEnum.CVCA;
}
if (i == 2) {
return AuthorizationRoleEnum.DV_D;
}
if (i == 3) {
return AuthorizationRoleEnum.DV_F;
}
if (i == 4) {
return AuthorizationRoleEnum.IS;
}
throw new NumberFormatException("Cannot decode role ".concat(String.valueOf(role)));
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: org.jmrtd.cert.CVCertificateBuilder$1, reason: invalid class name */
/* loaded from: classes6.dex */
public static /* synthetic */ class AnonymousClass1 {
static final int[] $SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission;
static final int[] $SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role;
static {
int[] iArr = new int[CVCAuthorizationTemplate.Permission.values().length];
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission = iArr;
try {
iArr[CVCAuthorizationTemplate.Permission.READ_ACCESS_NONE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission[CVCAuthorizationTemplate.Permission.READ_ACCESS_DG3.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission[CVCAuthorizationTemplate.Permission.READ_ACCESS_DG4.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission[CVCAuthorizationTemplate.Permission.READ_ACCESS_DG3_AND_DG4.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
int[] iArr2 = new int[CVCAuthorizationTemplate.Role.values().length];
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role = iArr2;
try {
iArr2[CVCAuthorizationTemplate.Role.CVCA.ordinal()] = 1;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role[CVCAuthorizationTemplate.Role.DV_D.ordinal()] = 2;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role[CVCAuthorizationTemplate.Role.DV_F.ordinal()] = 3;
} catch (NoSuchFieldError unused7) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role[CVCAuthorizationTemplate.Role.IS.ordinal()] = 4;
} catch (NoSuchFieldError unused8) {
}
}
}
private static AccessRightEnum getAccessRight(CVCAuthorizationTemplate.Permission permission) {
int i = AnonymousClass1.$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission[permission.ordinal()];
if (i == 1) {
return AccessRightEnum.READ_ACCESS_NONE;
}
if (i == 2) {
return AccessRightEnum.READ_ACCESS_DG3;
}
if (i == 3) {
return AccessRightEnum.READ_ACCESS_DG4;
}
if (i == 4) {
return AccessRightEnum.READ_ACCESS_DG3_AND_DG4;
}
throw new NumberFormatException("Cannot decode access right ".concat(String.valueOf(permission)));
}
}