As discussed previously on this mailing list this bug will be fixed in OCF 1.2:

1.) new CardID constructor
  ----------------------------
  The CardID constructor so far assumed that the TCK byte in the ATR was
  always present.
  The last byte is not a historical byte,
  but the check character TCK as defined in ISO 7816-3 6.4 and 6.4.3.

  "The value of TCK shall be such that the exclusive-oring of all
  bytes from T0 to TCK included is null" ...  "If only T=0 is
  indicated, TCK shall not be sent. In all other cases, TCK shall be
  sent".

  It is correct that opencard.core.CardID does not correctly respect this.
  It always assumes the presence of byte TCK.

  The right way to do this is to parse the ATR from the beginning
  (counting which interface characters are present)
  instead of counting from the back end.

  /**
   * Instantiates a new card ID representing the given ATR.
   *
   * @param     answerToResetResponse
   *            a byte array holding the ATR to represent
   * @exception CardTerminalException
   *            if the ATR is invalid
   */
  public CardID (byte[] answerToResetResponse)
    throws CardTerminalException {

    atr = (byte[]) answerToResetResponse.clone();
    // ... assert minimum length: TS + T0 character must be present
    if (atr.length < 2)
      throw new CardTerminalException
        ("Illegal ATR response (length " + atr.length +
         " < 2): " + HexString.hexify(answerToResetResponse));

    if ((atr[1] & 0x0f) > 0) {
      historicals = new byte[atr[1] & 0x0f];

      // count interface characters, calculate offset of historicals
      int offset=1; // position of current TDi, start with T0
      boolean tdiPresent = true;
      while (tdiPresent) {
        if ((atr[offset] & 0x80)!=0) tdiPresent = true; else tdiPresent = false;
        offset+= ((atr[offset] & 0x80) >>> 7) +
                 ((atr[offset] & 0x40) >>> 6) +
                 ((atr[offset] & 0x20) >>> 5) +
                 ((atr[offset] & 0x10) >>> 4);
      }
      offset++;


      // retrieve the historical bytes
      System.arraycopy(atr, offset,historicals, 0, historicals.length);
      int histCtr = historicals.length-1;
    }
  }


  Quote from the mailing list:
  I have tried your patch and it works perfectly for both MFC cards
  (T=1) and several Gemplus T=0 cards (MPCOS, GemXpresso, etc.).
  Thanks a lot for a small and efficient fix. I am looking forward
  to seeing it integrated into 1.2.

Peter Bendel, Smartcard Solutions,       Tel.: +49-7031-16-4650, Fax -4888
Dept. 4969, Bldg. 7103-01, Room 01-109        Lotus Notes:  bed@ibmde
IBM Pervasive Computing Division         Internet: [EMAIL PROTECTED]

Please visit the OpenCard Framework's homepage at http://www.opencard.org




---
> Visit the OpenCard web site at http://www.opencard.org/ for more
> information on OpenCard---binaries, source code, documents.
> This list is being archived at http://www.opencard.org/archive/opencard/

Reply via email to