X-Git-Url: http://www.average.org/gitweb/?p=YkNeoCR.git;a=blobdiff_plain;f=src%2Forg%2Faverage%2Fnfcauthcr%2FNFCAuthCRCheck.java;h=ea37128d65ed936f8dda42c0079809ed7318392f;hp=dc59b69e4391ebec2552a9a96915579b3150617f;hb=bdfe828f712fa2a187a424923c6594f12e965a5d;hpb=d68162938933f84fdde11f7a4ae5b919ccc469a1 diff --git a/src/org/average/nfcauthcr/NFCAuthCRCheck.java b/src/org/average/nfcauthcr/NFCAuthCRCheck.java index dc59b69..ea37128 100644 --- a/src/org/average/nfcauthcr/NFCAuthCRCheck.java +++ b/src/org/average/nfcauthcr/NFCAuthCRCheck.java @@ -1,7 +1,5 @@ package org.average.nfcauthcr; -import java.io.IOException; - import android.app.Activity; import android.app.AlertDialog; import android.app.PendingIntent; @@ -21,10 +19,6 @@ public class NFCAuthCRCheck extends Activity { private final String TAG = getClass().getName(); - private static final byte[] selectCommand = - {0x00, (byte) 0xA4, 0x04, 0x00, 0x07, (byte) 0xA0, - 0x00, 0x00, 0x05, 0x27, 0x20, 0x01, 0x00}; - private AlertDialog swipeDialog; private PendingIntent tagIntent; @@ -67,7 +61,8 @@ public class NFCAuthCRCheck extends Activity { Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); if (tag == null) return; IsoDep isoTag = IsoDep.get(tag); - byte[] response = doChallengeYubiKey(isoTag, slot, challenge); + byte[] response = NFCAuthCRYubiNeo.doChallengeYubiKey( + isoTag, slot, challenge); if (response != null) { Intent data = getIntent(); data.putExtra("response", response); @@ -124,29 +119,4 @@ public class NFCAuthCRCheck extends Activity { adapter.disableForegroundDispatch(this); } } - - private byte[] doChallengeYubiKey(IsoDep isoTag, int slot, - byte[] challenge) { - try { - isoTag.connect(); - byte[] resp = isoTag.transceive(selectCommand); - int length = resp.length; - if (resp[length - 2] == (byte)0x90 && - resp[length - 1] == 0x00) { - return challenge; - } else { - Toast.makeText(this, R.string.tag_error, - Toast.LENGTH_LONG).show(); - } - } catch (TagLostException e) { - Toast.makeText(this, - R.string.tag_lost, Toast.LENGTH_LONG).show(); - } catch (IOException e) { - Toast.makeText(this, - getText(R.string.tag_error) + - e.getMessage(), - Toast.LENGTH_LONG).show(); - } - return null; - } }