質問

スマートカードリーダーでMaestro / Mastercardからアカウント番号を読み取る必要があります。 Java 1.6とそのjavax.smartcardioパッケージを使用しています。カードのチップに保存されているEMVアプリケーションにPAN番号を尋ねるAPDUコマンドを送信する必要があります。問題は、必要なデータをどこにでも返すAPDUコマンドを構築するための通常のバイト配列が見つからないことです...

役に立ちましたか?

解決

APDUをさらにラップする必要はありません。 API層がそれを処理する必要があります。

0x6D00応答は、アプリケーションがINSをサポートしなかったことを意味するようです。

今はトラブルシューティングだけですが、MasterCardアプリケーションを選択することから始めましたか?

つまりこのようなもの:

void selectApplication(CardChannel channel) throws CardException {
  byte[] masterCardRid = new byte[]{0xA0, 0x00, 0x00, 0x00, 0x04};
  CommandAPDU command = new CommandAPDU(0x00, 0xA4, 0x04, 0x00, masterCardRid);
  ResponseAPDU response = channel.transmit(command);
  return response.getData();
}

他のヒント

実際の例を次に示します。

CardChannel channel = card.getBasicChannel(); 

 byte[] selectMaestro={(byte)0x00, (byte)0xA4,(byte)0x04,(byte)0x00 ,(byte)0x07 ,(byte)0xA0 ,(byte)0x00 ,(byte)0x00 ,(byte)0x00 ,(byte)0x04 ,(byte)0x30 ,(byte)0x60 ,(byte)0x00};
  byte[] getProcessingOptions={(byte)0x80,(byte)0xA8,(byte)0x00,(byte)0x00,(byte)0x02,(byte)0x83,(byte)0x00,(byte)0x00};
  byte[] readRecord={(byte)0x00,(byte)0xB2,(byte)0x02,(byte)0x0C,(byte)0x00};

  ResponseAPDU r=null;

   try {
     ATR atr = card.getATR(); //reset kartice

      CommandAPDU capdu=new CommandAPDU( selectMaestro   );

       r=card.getBasicChannel().transmit( capdu );

      capdu=new CommandAPDU(getProcessingOptions);
      r=card.getBasicChannel().transmit( capdu );


      capdu=new CommandAPDU(readRecord);
      r=card.getBasicChannel().transmit( capdu );

これはMaestroカードで動作します。PAN番号を読み取ることができますが、MasterCardのPAN番号を読み取る必要があります。読み取りレコードAPDUを変更するか、アプリケーションAPDUを選択する必要があるかはわかりません。 APDUに精通している人はいますか?

atr = open();
prints(atr);

prints("[Step 1] Select 1PAY.SYS.DDF01 to get the PSE directory");
cmd = new ISOSelect(ISOSelect.SELECT_AID, EMV4_1.AID_1PAY_SYS_DDF01);
card_response = execute(cmd);
prints(card_response);
SFI = NumUtil.hex2String((byte)((1 < < 3) | 4));

// try SFI 1 record 1
prints("[Step 2] Send READ RECORD with 0 to find out where the record is");
read = new EMVReadRecord(SFI, "01", "00");
card_response = execute(read);
prints(card_response);
byte_size = NumUtil.hex2String(card_response.getStatusWord().getSw2());

prints("[Step 3] Send READ RECORD with 1C to get the PSE data");
read = new EMVReadRecord(SFI, "01", byte_size);
card_response = execute(read);
prints(card_response);
// the AID is A0000000031010
prints("[Step 4] Now that we know the AID, select the application");

cmd = new ISOSelect(ISOSelect.SELECT_AID, "A0000000031010");
card_response = execute(cmd);
prints(card_response);
prints("[Step 5] Send GET PROCESSING OPTIONS command");

cmd = new EMVGetProcessingOptions();
card_response = execute(cmd);
prints(card_response);

// SFI for the first group of AFL is 0C

prints("[Step 6] Send READ RECORD with 0 to find out where the record is");
read = new EMVReadRecord("0C", "01", "00");
card_response = execute(read);
prints(card_response);
byte_size = NumUtil.hex2String(card_response.getStatusWord().getSw2());

prints("[Step 7] Use READ RECORD with the given number of bytes to retrieve the data");
read = new EMVReadRecord("0C", "01", byte_size);
card_response = execute(read);
prints(card_response);

data = new TLV(card_response.getData());

close();

CommandAPDUオブジェクトを作成し、それをtransmit()コマンドに渡す必要があります。

スマートカードのドキュメントで正確なコマンドを見つけることができるはずですが、以下に例を示します:

byte[] readFile(CardChannel channel) throws CardException {
  CommandAPDU command = new CommandAPDU(0xB0, 0x60, 0x10, 0x00);
  ResponseAPDU response = channel.transmit(command);
  return response.getData();
}

ドキュメントで0x6D00の意味を調べてみましたか? ENVELOPEコマンドがサポートされていないことを意味するようです。 T = 1ではなくT = 0プロトコルを使用してみましたか?

私の例があなたのカードで機能するとは思わないでしょう。 Maestro / MasterCardがサポートしているAPDUがわからないので、実例を示すことはできませんでした。

次のように、コマンドに明示的に予想される長さを指定してみてください:

byte[] readPan(CardChannel channel) throws CardException {
  CommandAPDU command = new CommandAPDU(0x00, 0xB2, 0x5a, 0x14, 250);
  ResponseAPDU response = channel.transmit(command);
  return response.getData();
}

スキャナの使用、カードの写真の取得、適切なjava ocrライブラリ( http://ocr4j.sourceforge.net/ など)および(通常)16桁のシーケンスXXXX-XXXX-XXXX-XXXXを検索すると、Javaを使用してEMVカードからPANを取得します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top