Class APDUUtil


  • public class APDUUtil
    extends Object
    The APDUUtil class contains utility methods to parse CLA byte from a command APDU. All methods in APDUUtil, class are static methods.

    Since:
    3.0.5
    See Also:
    APDU
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte getCLAChannel​(byte CLAbyte)
      Returns the logical channel number encoded in the CLAbyte parameter which represents a CLA byte from a command APDU.
      static boolean isCommandChainingCLA​(byte CLAbyte)
      Based on encoding of the CLAByte parameter which represents a CLA byte from a command APDU, returns whether an APDU command is the first or part of a command chain.
      static boolean isISOInterindustryCLA​(byte CLAbyte)
      Returns whether the CLAByte parameter which represents a CLA bye from a command APDU, corresponds to an interindustry command as defined in ISO 7816-4:2013 specification.
      static boolean isSecureMessagingCLA​(byte CLAbyte)
      Returns true if encoding of the CLAbyte parameter, which represents a CLA byte from a command APDU, indicates secure messaging.
      static boolean isValidCLA​(byte CLAbyte)
      Returns whether the current CLAByte parameter represents a valid CLA byte.
    • Method Detail

      • getCLAChannel

        public static byte getCLAChannel​(byte CLAbyte)
        Returns the logical channel number encoded in the CLAbyte parameter which represents a CLA byte from a command APDU. A number in the range 0-19 based on the CLA byte encoding is returned if the CLA contains logical channel encoding. If the CLA byte does not contain logical channel information, 0 is returned.

        Note:

        • This method returns 0 if the CLA bits (b8,b7,b6) is %b001 which is a CLA encoding reserved for future use(RFU), or if CLA is 0xFF which is an invalid value as defined in the ISO 7816-4:2013 specification.

        See Runtime Environment Specification, Java Card Platform, Classic Edition, section 4.3 for encoding details.

        Parameters:
        CLAbyte - is CLA byte from a command APDU
        Returns:
        logical channel number, if present, within the CLA byte, 0 otherwise
        Since:
        3.0.5
        See Also:
        APDU.getCLAChannel()
      • isSecureMessagingCLA

        public static boolean isSecureMessagingCLA​(byte CLAbyte)
        Returns true if encoding of the CLAbyte parameter, which represents a CLA byte from a command APDU, indicates secure messaging. The secure messaging information is in bits (b4,b3) for commands with origin channel numbers 0-3, and in bit b6 for origin channel numbers 4-19.

        Note:

        • This method returns false if the CLA bits (b8,b7,b6) is %b001 which is a CLA encoding reserved for future use(RFU), or if CLA is 0xFF which is an invalid value as defined in the ISO 7816-4:2013 specification.

        See Runtime Environment Specification, Java Card Platform, Classic Edition, section 4.3 for encoding details.

        Parameters:
        CLAbyte - is CLA byte from a command APDU
        Returns:
        true if the secure messaging bit(s) is(are) nonzero, false otherwise
        Since:
        3.0.5
        See Also:
        APDU.isSecureMessagingCLA()
      • isCommandChainingCLA

        public static boolean isCommandChainingCLA​(byte CLAbyte)
        Based on encoding of the CLAByte parameter which represents a CLA byte from a command APDU, returns whether an APDU command is the first or part of a command chain. Bit b5 of the CLA byte if set, indicates that the APDU is the first or part of a chain of commands.

        Note:

        • This method returns false if the CLA bits (b8,b7,b6) is %b001 which is a CLA encoding reserved for future use(RFU), or if CLA is 0xFF which is an invalid value as defined in the ISO 7816-4:2013 specification.

        See Runtime Environment Specification, Java Card Platform, Classic Edition, section 4.3 for encoding details.

        Parameters:
        CLAbyte - is CLA byte from a command APDU
        Returns:
        true if the CLA byte encoding indicates if an APDU is not the last APDU of a command chain, false otherwise.
        Since:
        3.0.5
        See Also:
        APDU.isCommandChainingCLA()
      • isISOInterindustryCLA

        public static boolean isISOInterindustryCLA​(byte CLAbyte)
        Returns whether the CLAByte parameter which represents a CLA bye from a command APDU, corresponds to an interindustry command as defined in ISO 7816-4:2013 specification. Bit b8 of the CLA byte if 0, indicates that the APDU is an interindustry command.
        Parameters:
        CLAbyte - is CLA byte from a command APDU
        Returns:
        true if this APDU CLA byte corresponds to an ISO interindustry command, false otherwise.
        Since:
        3.0.5
        See Also:
        APDU.isISOInterindustryCLA()
      • isValidCLA

        public static boolean isValidCLA​(byte CLAbyte)
        Returns whether the current CLAByte parameter represents a valid CLA byte. The CLA byte is invalid if the CLA bits (b8,b7,b6) is %b001, which is a CLA encoding reserved for future use(RFU), or if CLA is 0xFF which is an invalid value as defined in the ISO 7816-4:2013 specification.

        See Runtime Environment Specification, Java Card Platform, Classic Edition, section 4.3 for encoding details.

        Parameters:
        CLAbyte - is CLA byte from a command APDU
        Returns:
        true if CLA byte is valid, false otherwise.
        Since:
        3.0.5
        See Also:
        APDU.isValidCLA()