- public static byte[] doChalResp(IsoDep isoTag, int slot,
- byte[] challenge) throws CRException {
- try {
- isoTag.connect();
- byte[] resp = isoTag.transceive(selectApdu);
- int length = resp.length;
- if (resp[length - 2] != (byte)0x90 ||
- resp[length - 1] != 0x00) {
+ public static ArrayList<String> doChalResp(IsoDep isoTag, int slot,
+ ArrayList<String> cset)
+ throws IOException, CRException {
+ if (slot != 1 && slot != 2) {
+ throw new CRException(String.format(
+ "NFC Yubikey slot is %d, can be 1 or 2",
+ slot));
+ }
+ byte[] resp = isoTag.transceive(selectApdu);
+ int length = resp.length;
+ if (resp[length - 2] != (byte)0x90 ||
+ resp[length - 1] != 0x00) {
+ throw new CRException(String.format(
+ "NFC select error code: %02x:%02x",
+ resp[length - 2], resp[length - 1]));
+ }
+ ArrayList<String> rset = new ArrayList<String>();
+
+ Iterator itr = cset.iterator();
+ while (itr.hasNext()) {
+ byte[] challenge = unhex((String)itr.next());
+ if (challenge.length > 127) {