src/com/makina/security/OpenFIPS201/OpenFIPS201.java
private void processPIV_VERIFY(APDU apdu) {

        final byte CONST_P1_AUTH 	= (byte)0x00;
        final byte CONST_P1_RESET 	= (byte)0xFF;
        final byte CONST_P2 		= (byte)0xFF;
        final byte CONST_LC			= (byte)0x08;

        byte[] buffer = apdu.getBuffer();
        short length = (short)(buffer[ISO7816.OFFSET_LC] & 0xFF);

        /*
         * PRE-CONDITIONS
         */

        // PRE-CONDITION 1 - The P1 value must be equal to the constant CONST_P1_AUTH or CONST_P1_RESET
        // PRE-CONDITION 2 - If the P1 value is set to CONST_P1_RESET, the data field must be absent
        // NOTE: This is handled by the cases below

        // PRE-CONDITION 3 - If the P1 value is set to CONST_P1_AUTH and the data field is present, the
        //					 length must be equal to CONST_LC
        // NOTE: This is handled inside the PIVProvider

        /*
         * EXECUTION STEPS
         */

        // STEP 1 - Call the appropriate PIV 'Verify' command

        // CASE 1 - If P1='00', and Lc and the command data field are absent, the command can be
        // 			used to retrieve the number of further retries allowed ('63 CX'), or to check whether
        // 			verification is not needed ('90 00').
        if (buffer[ISO7816.OFFSET_P1] == CONST_P1_AUTH && length == ZERO_SHORT) {
            // Retrieve the authentication status using the key reference supplied in P2
            piv.verifyGetStatus(buffer[ISO7816.OFFSET_P2]);
            return;
        };

        // CASE 2 - If P1='FF', and Lc and the command data field are absent, the command shall reset
        // 			the security status of the key reference in P2.
        if (buffer[ISO7816.OFFSET_P1] == CONST_P1_RESET && length == ZERO_SHORT) {
            // Reset the authentication status using the key reference supplied in P2
            piv.verifyResetStatus(buffer[ISO7816.OFFSET_P2]);
            return;
        };

        // CASE 3 - If P1='00', and Lc and the command data field are present, then the authentication data
        //			in the command data field shall be compared against the reference data associated with
        //			the key reference [...]
        if (buffer[ISO7816.OFFSET_P1] == CONST_P1_AUTH && length != ZERO_SHORT) {
            // Verify using the key reference supplied in P2
            piv.verify(buffer[ISO7816.OFFSET_P2], buffer, ISO7816.OFFSET_CDATA, length);
            return;
        };

        // If we reached here, then none of the cases applied
        ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2);
    }
/**
     * Process the PIV 'VERIFY' command
     *
     * @param apdu The incoming APDU object
     */
Process the PIV 'VERIFY' command
@param apdu The incoming APDU object
Process the PIV ' VERIFY ' command @param apdu The incoming APDU object
private void processPIV_VERIFY(APDU apdu) {
        final byte CONST_P1_AUTH 	= (byte)0x00;
        final byte CONST_P1_RESET 	= (byte)0xFF;
        final byte CONST_P2 		= (byte)0xFF;
        final byte CONST_LC			= (byte)0x08;
        byte[] buffer = apdu.getBuffer();
        short length = (short)(buffer[ISO7816.OFFSET_LC] & 0xFF);
        /*
         * PRE-CONDITIONS
         */
        /*
         * EXECUTION STEPS
         */
        if (buffer[ISO7816.OFFSET_P1] == CONST_P1_AUTH && length == ZERO_SHORT) {
            piv.verifyGetStatus(buffer[ISO7816.OFFSET_P2]);
            return;
        };
        if (buffer[ISO7816.OFFSET_P1] == CONST_P1_RESET && length == ZERO_SHORT) {
            piv.verifyResetStatus(buffer[ISO7816.OFFSET_P2]);
            return;
        };
        if (buffer[ISO7816.OFFSET_P1] == CONST_P1_AUTH && length != ZERO_SHORT) {
            piv.verify(buffer[ISO7816.OFFSET_P2], buffer, ISO7816.OFFSET_CDATA, length);
            return;
        };
        ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2);
    }
private void processPIV_VERIFY ( APDU apdu ) { final byte CONST_P1_AUTH = ( byte ) 0x00 ; final byte CONST_P1_RESET = ( byte ) 0xFF ; final byte CONST_P2 = ( byte ) 0xFF ; final byte CONST_LC = ( byte ) 0x08 ; byte [ ] buffer = apdu . getBuffer ( ) ; short length = ( short ) ( buffer [ ISO7816 . OFFSET_LC ] & 0xFF ) ; /*
         * PRE-CONDITIONS
         */ /*
         * EXECUTION STEPS
         */ if ( buffer [ ISO7816 . OFFSET_P1 ] == CONST_P1_AUTH && length == ZERO_SHORT ) { piv . verifyGetStatus ( buffer [ ISO7816 . OFFSET_P2 ] ) ; return ; } ; if ( buffer [ ISO7816 . OFFSET_P1 ] == CONST_P1_RESET && length == ZERO_SHORT ) { piv . verifyResetStatus ( buffer [ ISO7816 . OFFSET_P2 ] ) ; return ; } ; if ( buffer [ ISO7816 . OFFSET_P1 ] == CONST_P1_AUTH && length != ZERO_SHORT ) { piv . verify ( buffer [ ISO7816 . OFFSET_P2 ] , buffer , ISO7816 . OFFSET_CDATA , length ) ; return ; } ; ISOException . throwIt ( ISO7816 . SW_INCORRECT_P1P2 ) ; }
Process the PIV 'VERIFY' command
 @param apdu The incoming APDU object
Process the PIV ' VERIFY ' command @param apdu The incoming APDU object
// PRE-CONDITION 1 - The P1 value must be equal to the constant CONST_P1_AUTH or CONST_P1_RESET // PRE-CONDITION 2 - If the P1 value is set to CONST_P1_RESET, the data field must be absent // NOTE: This is handled by the cases below // PRE-CONDITION 3 - If the P1 value is set to CONST_P1_AUTH and the data field is present, the //					 length must be equal to CONST_LC // NOTE: This is handled inside the PIVProvider // STEP 1 - Call the appropriate PIV 'Verify' command // CASE 1 - If P1='00', and Lc and the command data field are absent, the command can be // 			used to retrieve the number of further retries allowed ('63 CX'), or to check whether // 			verification is not needed ('90 00'). // Retrieve the authentication status using the key reference supplied in P2 // CASE 2 - If P1='FF', and Lc and the command data field are absent, the command shall reset // 			the security status of the key reference in P2. // Reset the authentication status using the key reference supplied in P2 // CASE 3 - If P1='00', and Lc and the command data field are present, then the authentication data //			in the command data field shall be compared against the reference data associated with //			the key reference [...] // Verify using the key reference supplied in P2 // If we reached here, then none of the cases applied