Skip to content

Commit

Permalink
Regression with BC 1.78
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpaljak committed Jul 29, 2024
1 parent 5df517f commit 335643b
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions library/src/main/java/pro/javacard/gp/GPData.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
public final class GPData {
private static final Logger logger = LoggerFactory.getLogger(GPData.class);

private GPData() {}
private GPData() {
}

// SD states
public static final byte readyStatus = 0x1;
public static final byte initializedStatus = 0x7;
Expand Down Expand Up @@ -382,19 +384,16 @@ public static String sw2str(int sw) {
}

public static String oid2string(byte[] oid) {
try {
// Prepend 0x06 tag, if not present
// XXX: if ber-tlv allows to fetch constructed data, this is not needed
if (oid[0] != 0x06) {
oid = GPUtils.concatenate(new byte[]{0x06, (byte) oid.length}, oid);
}
ASN1ObjectIdentifier realoid = (ASN1ObjectIdentifier) ASN1ObjectIdentifier.fromByteArray(oid);
if (realoid == null)
throw new IllegalArgumentException("Could not parse OID from " + HexUtils.bin2hex(oid));
return realoid.toString();
} catch (IOException e) {
throw new IllegalArgumentException("Could not handle " + HexUtils.bin2hex(oid));
logger.trace("Parsing {} as OID", HexUtils.bin2hex(oid));
// XXX: Hardcoded to avoid issue in bc-java 1.78+
// See https://github.com/bcgit/bc-java/issues/1758
if (Arrays.equals(HexUtils.hex2bin("2A864886FC6B048000"), oid)) {
return "1.2.840.114283.4.0";
}
ASN1ObjectIdentifier realoid = ASN1ObjectIdentifier.fromContents(oid);
if (realoid == null)
throw new IllegalArgumentException("Could not parse OID from " + HexUtils.bin2hex(oid));
return realoid.toString();
}

private static String logAndGetOidFromByteArray(byte[] tag, byte[] tlv) {
Expand Down

0 comments on commit 335643b

Please sign in to comment.