Commit a0635f69 authored by Josh Ji's avatar Josh Ji

add vendor function (GET_COUNT 0x45)

return number of credentials
parent 7c2ff15c
newJavaCardApplet
\ No newline at end of file
......@@ -4,6 +4,8 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="delegatedBuild" value="false" />
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -35,6 +35,7 @@ import javacardx.apdu.ExtendedLength;
public class CTAP2 extends Applet implements ExtendedLength {
private static final byte FIDO2_VENDOR_GET_COUNT = (byte)0x45;
private CBORDecoder cborDecoder;
private CBOREncoder cborEncoder;
......@@ -190,22 +191,25 @@ public class CTAP2 extends Applet implements ExtendedLength {
case FIDO2_AUTHENTICATOR_GET_NEXT_ASSERTION:
authGetNextAssertion(apdu, buffer);
break;
case FIDO2_VENDOR_ATTEST_SIGN:
case FIDO2_VENDOR_ATTEST_SIGN: //0x41
attestSignRaw(apdu, vars[3]);
break;
case FIDO2_VENDOR_ATTEST_LOADCERT:
case FIDO2_VENDOR_ATTEST_LOADCERT: //0x42
attestSetCert(apdu, vars[3]);
break;
case FIDO2_VENDOR_PERSO_COMPLETE:
case FIDO2_VENDOR_PERSO_COMPLETE: //0x43
persoComplete(apdu);
break;
case FIDO2_VENDOR_ATTEST_GETPUB:
case FIDO2_VENDOR_ATTEST_GETPUB: //0x44
getAttestPublic(apdu);
break;
case FIDO2_VENDOR_ATTEST_GETCERT:
case FIDO2_VENDOR_ATTEST_GETCERT: //0x4a
getCert(apdu);
break;
case FIDO2_AUTHENTICATOR_RESET:
case FIDO2_VENDOR_GET_COUNT: //0x45
getCount(apdu);
break;
case FIDO2_AUTHENTICATOR_RESET: //0x07
// Need to finish doing this, we can, i mean, but I don't like it
doReset(apdu);
break;
......@@ -244,6 +248,15 @@ public class CTAP2 extends Applet implements ExtendedLength {
apdu.sendBytesLong(inBuf, (short) 0, vars[0]);
}
/** get counter's value */
public void getCount(APDU apdu){
short count = discoverableCreds.getCount();
apdu.setOutgoing();
apdu.setOutgoingLength((short)2);
Util.setShort(inBuf,(short)0, count);
apdu.sendBytesLong(inBuf,(short)0,(short)2);
}
/**
* Performs raw signatures, may only occur when personalisation is not complete.
*
......@@ -1024,7 +1037,7 @@ public class CTAP2 extends Applet implements ExtendedLength {
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
}
break;
case FIDO2_INS_NFCCTAP_MSG:
case FIDO2_INS_NFCCTAP_MSG: // 0x10
handle(apdu);
break;
case FIDO2_DESELECT:
......
......@@ -27,6 +27,7 @@ public class CredentialArray {
private boolean[] slotStatus;
private short size;
private short counter;
private short count = 0;//the number of creds in the array
/**
* Constructor for a CredentialArray.
......@@ -46,6 +47,7 @@ public class CredentialArray {
short slot = alreadyExists(in);
creds[slot] = in;
slotStatus[slot] = true;
count = (short)(slot + 1);
} catch (Exception e) {
UserException.throwIt(CTAP2.CTAP2_ERR_KEY_STORE_FULL);
}
......@@ -117,6 +119,10 @@ public class CredentialArray {
public short getLength() {
return size;
}
public short getCount(){
return count;
}
/**
* Returns the credential at position, or null if none.
* @param position the position to get.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment