what-the-bank/sources/net/sf/scuba/smartcards/ISOFileInfo.java

447 lines
17 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package net.sf.scuba.smartcards;
import java.math.BigInteger;
import o.ghS;
import org.jmrtd.cbeff.ISO781611;
/* loaded from: classes6.dex */
public class ISOFileInfo extends FileInfo {
public static final byte A0 = -96;
public static final byte A1 = -95;
public static final byte A2 = -94;
public static final byte A5 = -91;
public static final byte AB = -85;
public static final byte AC = -84;
public static final byte CHANNEL_SECURITY = -114;
public static final byte DATA_BYTES1 = Byte.MIN_VALUE;
public static final byte DATA_BYTES2 = -127;
public static final byte DF_NAME = -124;
public static final byte ENV_TEMP_EF = -115;
public static final byte FCI_BYTE = 111;
public static final byte FCI_EXT = -121;
public static final byte FCP_BYTE = 98;
public static final byte FILE_DESCRIPTOR = -126;
public static final byte FILE_IDENTIFIER = -125;
public static final byte FMD_BYTE = 100;
public static final byte LCS_BYTE = -118;
public static final byte PROP_INFO = -123;
public static final byte SECURITY_ATTR_COMPACT = -116;
public static final byte SECURITY_ATTR_EXP = -117;
public static final byte SECURITY_ATTR_PROP = -122;
public static final byte SHORT_EF = -120;
byte[] a0;
byte[] a1;
byte[] a2;
byte[] a5;
byte[] ab;
byte[] ac;
byte channelSecurity;
byte dataCodingByte;
byte descriptorByte;
byte[] dfName;
short envTempEF;
short fciExt;
short fid;
int fileLength;
int fileLengthFCI;
byte lcsByte;
byte mainTag;
short maxRecordSize;
short maxRecordsCount;
byte[] propInfo;
byte[] secAttrCompact;
byte[] secAttrExp;
byte[] secAttrProp;
byte shortEF;
/* JADX WARN: Failed to find 'out' block for switch in B:22:0x0079. Please report as an issue. */
/* JADX WARN: Failed to find 'out' block for switch in B:23:0x007c. Please report as an issue. */
/* JADX WARN: Failed to find 'out' block for switch in B:24:0x007f. Please report as an issue. */
public ISOFileInfo(byte[] bArr) throws CardServiceException {
this.mainTag = (byte) -1;
this.fileLength = -1;
this.fileLengthFCI = -1;
this.descriptorByte = (byte) -1;
this.dataCodingByte = (byte) -1;
this.maxRecordSize = (short) -1;
this.maxRecordsCount = (short) -1;
this.fid = (short) -1;
this.dfName = null;
this.propInfo = null;
this.secAttrProp = null;
this.secAttrExp = null;
this.secAttrCompact = null;
this.fciExt = (short) -1;
this.envTempEF = (short) -1;
this.shortEF = (byte) -1;
this.lcsByte = (byte) -1;
this.channelSecurity = (byte) -1;
this.a0 = null;
this.a1 = null;
this.a2 = null;
this.a5 = null;
this.ab = null;
this.ac = null;
if (bArr.length == 0) {
return;
}
byte b = bArr[0];
if (b != 111 && b != 98 && b != 100) {
throw new CardServiceException("Malformed FCI data");
}
this.mainTag = b;
int i = bArr[1];
byte[] bArr2 = new byte[i];
System.arraycopy(bArr, 2, bArr2, 0, i);
int i2 = 0;
while (i2 < i) {
try {
byte b2 = bArr2[i2];
int i3 = i2 + 2;
int i4 = bArr2[i2 + 1];
byte[] bArr3 = new byte[i4];
System.arraycopy(bArr2, i3, bArr3, 0, i4);
int i5 = i3 + i4;
if (b2 == -91) {
byte[] bArr4 = new byte[i4];
this.a5 = bArr4;
System.arraycopy(bArr3, 0, bArr4, 0, i4);
} else if (b2 == -85) {
byte[] bArr5 = new byte[i4];
this.ab = bArr5;
System.arraycopy(bArr3, 0, bArr5, 0, i4);
} else if (b2 != -84) {
switch (b2) {
case Byte.MIN_VALUE:
this.fileLength = new BigInteger(bArr3).abs().intValue();
break;
case -127:
checkLen(i4, 2);
this.fileLengthFCI = new BigInteger(bArr3).intValue();
break;
case -126:
checkLen(i4, 1, 6);
this.descriptorByte = bArr3[0];
if (1 != i4) {
this.dataCodingByte = bArr3[1];
if (2 != i4) {
int i6 = 3;
if (i4 == 3) {
this.maxRecordSize = bArr3[2];
} else {
this.maxRecordSize = new BigInteger(new byte[]{bArr3[2], bArr3[3]}).shortValue();
i6 = 4;
}
if (i6 == i4) {
break;
} else if (i4 == 5) {
this.maxRecordsCount = bArr3[i6];
break;
} else {
this.maxRecordsCount = new BigInteger(new byte[]{bArr3[i6], bArr3[i6 + 1]}).shortValue();
break;
}
} else {
break;
}
} else {
break;
}
case -125:
checkLen(i4, 2);
this.fid = new BigInteger(bArr3).shortValue();
break;
case -124:
checkLen(i4, 0, 16);
byte[] bArr6 = new byte[i4];
this.dfName = bArr6;
System.arraycopy(bArr3, 0, bArr6, 0, i4);
break;
case -123:
byte[] bArr7 = new byte[i4];
this.propInfo = bArr7;
System.arraycopy(bArr3, 0, bArr7, 0, i4);
break;
case -122:
byte[] bArr8 = new byte[i4];
this.secAttrProp = bArr8;
System.arraycopy(bArr3, 0, bArr8, 0, i4);
break;
case -121:
checkLen(i4, 2);
this.fciExt = new BigInteger(bArr3).shortValue();
break;
case -120:
checkLen(i4, 0, 1);
if (i4 != 0) {
this.shortEF = bArr3[0];
break;
} else {
this.shortEF = (byte) 0;
break;
}
default:
switch (b2) {
case -118:
checkLen(i4, 1);
this.lcsByte = bArr3[0];
break;
case -117:
byte[] bArr9 = new byte[i4];
this.secAttrExp = bArr9;
System.arraycopy(bArr3, 0, bArr9, 0, i4);
break;
case -116:
byte[] bArr10 = new byte[i4];
this.secAttrCompact = bArr10;
System.arraycopy(bArr3, 0, bArr10, 0, i4);
break;
case -115:
checkLen(i4, 2);
this.envTempEF = new BigInteger(bArr3).shortValue();
break;
case -114:
checkLen(i4, 1);
this.channelSecurity = bArr3[0];
break;
default:
switch (b2) {
case -96:
byte[] bArr11 = new byte[i4];
this.a0 = bArr11;
System.arraycopy(bArr3, 0, bArr11, 0, i4);
break;
case ISO781611.BIOMETRIC_HEADER_TEMPLATE_BASE_TAG /* -95 */:
byte[] bArr12 = new byte[i4];
this.a1 = bArr12;
System.arraycopy(bArr3, 0, bArr12, 0, i4);
break;
case -94:
byte[] bArr13 = new byte[i4];
this.a2 = bArr13;
System.arraycopy(bArr3, 0, bArr13, 0, i4);
break;
default:
throw new CardServiceException("Malformed FCI: unrecognized tag.");
}
}
}
} else {
byte[] bArr14 = new byte[i4];
this.ac = bArr14;
System.arraycopy(bArr3, 0, bArr14, 0, i4);
}
i2 = i5;
} catch (ArrayIndexOutOfBoundsException unused) {
throw new CardServiceException("Malformed FCI.");
}
}
}
private static void checkLen(int i, int i2) throws CardServiceException {
if (i != i2) {
throw new CardServiceException("Malformed FCI.");
}
}
private static void checkLen(int i, int i2, int i3) throws CardServiceException {
if (i < i2 || i > i3) {
throw new CardServiceException("Malformed FCI.");
}
}
public byte[] getFormatted() {
String e;
String e2;
byte[] bArr = new byte[0];
if (this.mainTag == -1) {
return bArr;
}
int i = this.fileLength;
if (i != -1) {
bArr = catArray(bArr, getArray(Byte.MIN_VALUE, ghS.c(ghS.e((short) i))));
}
int i2 = this.fileLengthFCI;
if (i2 != -1) {
bArr = catArray(bArr, getArray(DATA_BYTES2, ghS.c(ghS.e((short) i2))));
}
byte b = this.descriptorByte;
if (b != -1) {
byte[] bArr2 = {b};
byte[] bArr3 = new byte[0];
byte b2 = this.dataCodingByte;
if (b2 != -1) {
bArr3 = new byte[]{b2};
}
byte[] bArr4 = new byte[0];
short s = this.maxRecordSize;
if (s != -1) {
if (s > 256) {
e2 = ghS.e(s);
} else if (this.maxRecordsCount == -1) {
e2 = ghS.e((byte) s);
} else {
e2 = ghS.e(s);
}
bArr4 = ghS.c(e2);
}
byte[] bArr5 = new byte[0];
short s2 = this.maxRecordsCount;
if (s2 != -1) {
if (s2 <= 256) {
e = ghS.e((byte) s2);
} else {
e = ghS.e(s2);
}
bArr5 = ghS.c(e);
}
bArr = catArray(bArr, getArray((byte) -126, catArray(catArray(catArray(bArr2, bArr3), bArr4), bArr5)));
}
short s3 = this.fid;
if (s3 != -1) {
bArr = catArray(bArr, getArray(FILE_IDENTIFIER, ghS.c(ghS.e(s3))));
}
byte[] bArr6 = this.dfName;
if (bArr6 != null) {
bArr = catArray(bArr, getArray((byte) -124, bArr6));
}
byte[] bArr7 = this.propInfo;
if (bArr7 != null) {
bArr = catArray(bArr, getArray(PROP_INFO, bArr7));
}
byte[] bArr8 = this.secAttrProp;
if (bArr8 != null) {
bArr = catArray(bArr, getArray((byte) -122, bArr8));
}
short s4 = this.fciExt;
if (s4 != -1) {
bArr = catArray(bArr, getArray(FCI_EXT, ghS.c(ghS.e(s4))));
}
byte b3 = this.shortEF;
if (b3 != -1) {
bArr = catArray(bArr, getArray((byte) -120, b3 == 0 ? new byte[0] : new byte[]{b3}));
}
byte b4 = this.lcsByte;
if (b4 != -1) {
bArr = catArray(bArr, getArray(LCS_BYTE, new byte[]{b4}));
}
byte[] bArr9 = this.secAttrExp;
if (bArr9 != null) {
bArr = catArray(bArr, getArray(SECURITY_ATTR_EXP, bArr9));
}
byte[] bArr10 = this.secAttrCompact;
if (bArr10 != null) {
bArr = catArray(bArr, getArray(SECURITY_ATTR_COMPACT, bArr10));
}
short s5 = this.envTempEF;
if (s5 != -1) {
bArr = catArray(bArr, getArray(ENV_TEMP_EF, ghS.c(ghS.e(s5))));
}
byte b5 = this.channelSecurity;
if (b5 != -1) {
bArr = catArray(bArr, getArray(CHANNEL_SECURITY, new byte[]{b5}));
}
byte[] bArr11 = this.a0;
if (bArr11 != null) {
bArr = catArray(bArr, getArray(A0, bArr11));
}
byte[] bArr12 = this.a1;
if (bArr12 != null) {
bArr = catArray(bArr, getArray(A1, bArr12));
}
byte[] bArr13 = this.a2;
if (bArr13 != null) {
bArr = catArray(bArr, getArray((byte) -94, bArr13));
}
byte[] bArr14 = this.a5;
if (bArr14 != null) {
bArr = catArray(bArr, getArray(A5, bArr14));
}
byte[] bArr15 = this.ab;
if (bArr15 != null) {
bArr = catArray(bArr, getArray(AB, bArr15));
}
byte[] bArr16 = this.ac;
if (bArr16 != null) {
bArr = catArray(bArr, getArray((byte) -84, bArr16));
}
return getArray(this.mainTag, bArr);
}
private static byte[] getArray(byte b, byte[] bArr) {
byte[] bArr2 = new byte[bArr.length + 2];
bArr2[0] = b;
bArr2[1] = (byte) bArr.length;
System.arraycopy(bArr, 0, bArr2, 2, bArr.length);
return bArr2;
}
private static byte[] catArray(byte[] bArr, byte[] bArr2) {
byte[] bArr3 = new byte[bArr.length + bArr2.length];
System.arraycopy(bArr, 0, bArr3, 0, bArr.length);
System.arraycopy(bArr2, 0, bArr3, bArr.length, bArr2.length);
return bArr3;
}
public String toString() {
StringBuilder sb = new StringBuilder("Length: ");
sb.append(this.fileLength);
sb.append("\nLength FCI: ");
sb.append(this.fileLengthFCI);
sb.append("\nDesc byte: ");
sb.append((int) this.descriptorByte);
sb.append("\nData byte: ");
sb.append((int) this.dataCodingByte);
sb.append("\nRecord size: ");
sb.append((int) this.maxRecordSize);
sb.append("\nRecord count: ");
sb.append((int) this.maxRecordsCount);
sb.append("\nFID: ");
sb.append(ghS.e(this.fid));
sb.append("\nDF name: ");
sb.append(ghS.c(this.dfName));
sb.append("\npropInfo: ");
sb.append(ghS.c(this.propInfo));
sb.append("\nsecAttrProp: ");
sb.append(ghS.c(this.secAttrProp));
sb.append("\nsecAttrExp: ");
sb.append(ghS.c(this.secAttrExp));
sb.append("\nsecAttrComp: ");
sb.append(ghS.c(this.secAttrCompact));
sb.append("\nFCI ext: ");
sb.append(ghS.e(this.fciExt));
sb.append("\nEF env temp: ");
sb.append(ghS.e(this.envTempEF));
sb.append("\nShort EF: ");
sb.append(ghS.e(this.shortEF));
sb.append("\nLCS byte: ");
sb.append(ghS.e(this.lcsByte));
sb.append("\nChannel sec: ");
sb.append(ghS.e(this.channelSecurity));
sb.append("\na0: ");
sb.append(ghS.c(this.a0));
sb.append("\na1: ");
sb.append(ghS.c(this.a1));
sb.append("\na2: ");
sb.append(ghS.c(this.a2));
sb.append("\na5: ");
sb.append(ghS.c(this.a5));
sb.append("\nab: ");
sb.append(ghS.c(this.ab));
sb.append("\nac: ");
sb.append(ghS.c(this.ac));
sb.append("\n");
return sb.toString();
}
@Override // net.sf.scuba.smartcards.FileInfo
public int getFileLength() {
return this.fileLength;
}
@Override // net.sf.scuba.smartcards.FileInfo
public short getFID() {
return this.fid;
}
}