Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8226317

Incomplete 6CXY handling in sun.security.smartcardio.ChannelImpl#doTransmit

    Details

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10, Ubuntu 18

      A DESCRIPTION OF THE PROBLEM :
      A case 1 APDU is send, but turns out to be a case 2 APDU. Although this might be considered as a programmer mistake, UICCs are handling this gracefully and are reporting a 6C00 status word to send the command again with proper Le byte.
      sun.security.smartcardio.ChannelImpl#doTransmit is overwriting blindly the last byte of the command APDU and resents the command, also if the APDU had only 4 bytes. The command is now invalid because the P2 parameters is overwritten. In addition the UICC is still not receiving the correct Le byte.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Install the HelloWorld applet from https://sourceforge.net/projects/globalplatform/files/GPShell/
      (NOTE: The HelloWorld applet does not parse the APDU command, it simply returns always "Hello World!", i.e. the P2 param does not matter)
      2. Send APDUs:
         * 00A4040C08D0D1D2D3D4D50101
         * 80CAFF40




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The UICC returns 6C0C, the doTransmit logic resends 80CAFF40_0C_, so is recreating a command APDU with 5 bytes, not reusing the 4 byte command APDU. This is a special handling for case 1 APDUs.
      ACTUAL -
      The UICC returns 6C0C, the doTransmit logic resends 80CAFF0C, the UICC is again returning 6C0C. This loop is aborted by the PC/SC library and an error is reported.

      CUSTOMER SUBMITTED WORKAROUND :
      Always pass an Le byte.

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              igerasim Ivan Gerasimov
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: