usb: respect automatic PPS feature flag
If the feature flag is set, don't do PPS negotiation. Closes #2219
This commit is contained in:
@@ -36,6 +36,8 @@ abstract class CcidDescription {
|
|||||||
|
|
||||||
// dwFeatures Masks
|
// dwFeatures Masks
|
||||||
private static final int FEATURE_AUTOMATIC_VOLTAGE = 0x00008;
|
private static final int FEATURE_AUTOMATIC_VOLTAGE = 0x00008;
|
||||||
|
private static final int FEATURE_AUTOMATIC_PPS = 0x00080;
|
||||||
|
|
||||||
private static final int FEATURE_EXCHANGE_LEVEL_TPDU = 0x10000;
|
private static final int FEATURE_EXCHANGE_LEVEL_TPDU = 0x10000;
|
||||||
private static final int FEATURE_EXCHAGE_LEVEL_SHORT_APDU = 0x20000;
|
private static final int FEATURE_EXCHAGE_LEVEL_SHORT_APDU = 0x20000;
|
||||||
private static final int FEATURE_EXCHAGE_LEVEL_EXTENDED_APDU = 0x40000;
|
private static final int FEATURE_EXCHAGE_LEVEL_EXTENDED_APDU = 0x40000;
|
||||||
@@ -130,6 +132,10 @@ abstract class CcidDescription {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean hasAutomaticPps() {
|
||||||
|
return hasFeature(FEATURE_AUTOMATIC_PPS);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean hasFeature(int feature) {
|
private boolean hasFeature(int feature) {
|
||||||
return (getFeatures() & feature) != 0;
|
return (getFeatures() & feature) != 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,6 +258,10 @@ public class CcidTransceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasAutomaticPps() {
|
||||||
|
return usbCcidDescription.hasAutomaticPps();
|
||||||
|
}
|
||||||
|
|
||||||
/** Corresponds to 6.2.1 RDR_to_PC_DataBlock. */
|
/** Corresponds to 6.2.1 RDR_to_PC_DataBlock. */
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public abstract static class CcidDataBlock {
|
public abstract static class CcidDataBlock {
|
||||||
|
|||||||
@@ -54,7 +54,10 @@ public class T1TpduProtocol implements CcidTransportProtocol {
|
|||||||
// TODO: set checksum from atr
|
// TODO: set checksum from atr
|
||||||
blockFactory = new T1TpduBlockFactory(BlockChecksumAlgorithm.LRC);
|
blockFactory = new T1TpduBlockFactory(BlockChecksumAlgorithm.LRC);
|
||||||
|
|
||||||
performPpsExchange();
|
boolean skipPpsExchange = ccidTransceiver.hasAutomaticPps();
|
||||||
|
if (!skipPpsExchange) {
|
||||||
|
performPpsExchange();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performPpsExchange() throws UsbTransportException {
|
private void performPpsExchange() throws UsbTransportException {
|
||||||
|
|||||||
@@ -269,6 +269,14 @@ public class CcidTransceiverTest {
|
|||||||
assertArrayEquals(Hex.decode(responseData), ccidDataBlock.getData());
|
assertArrayEquals(Hex.decode(responseData), ccidDataBlock.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReturnsCorrectAutoPpsFlag() throws Exception {
|
||||||
|
CcidDescription description = CcidDescription.fromValues((byte) 0, (byte) 7, 3, 65722);
|
||||||
|
CcidTransceiver ccidTransceiver = new CcidTransceiver(usbConnection, usbBulkIn, usbBulkOut, description);
|
||||||
|
|
||||||
|
assertTrue(ccidTransceiver.hasAutomaticPps());
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyDialog() {
|
private void verifyDialog() {
|
||||||
assertTrue(expectReplies.isEmpty());
|
assertTrue(expectReplies.isEmpty());
|
||||||
assertFalse(expectRepliesVerify.isEmpty());
|
assertFalse(expectRepliesVerify.isEmpty());
|
||||||
|
|||||||
Reference in New Issue
Block a user