Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
FlutterCrypto committed Apr 7, 2023
1 parent 8d6f2ee commit ed04ba8
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,23 @@ public void onTagDiscovered(Tag tag) {
* step 1 code start
*/


printStepHeader(1, "select PPSE");
byte[] PPSE = "2PAY.SYS.DDF01".getBytes(StandardCharsets.UTF_8); // PPSE
byte[] selectPpseCommand = selectApdu(PPSE);
byte[] selectPpseResponse = nfc.transceive(selectPpseCommand);
writeToUiAppend("01 select PPSE command length " + selectPpseCommand.length + " data: " + bytesToHexNpe(selectPpseCommand));
writeToUiAppend("01 select PPSE response length " + selectPpseResponse.length + " data: " + bytesToHexNpe(selectPpseResponse));
writeToUiAppend(etData, "01 select PPSE completed");
writeToUiAppend(prettyPrintDataToString(selectPpseResponse));

byte[] selectPpseResponseOk = checkResponse(selectPpseResponse);
// proceed only when te do have a positive read result = 0x'9000' at the end of response data
if (selectPpseResponseOk != null) {

} else {
// if (isoDepInTechList) {
writeToUiAppend("The discovered NFC tag does not have an IsoDep interface.");
}

/**
* step 1 code end
Expand Down Expand Up @@ -173,6 +189,31 @@ public void onTagDiscovered(Tag tag) {
* section for emv reading
*/

/**
* step 1 code start
*/

/**
* build a select apdu command
*
* @param data
* @return
*/
private byte[] selectApdu(@NonNull byte[] data) {
byte[] commandApdu = new byte[6 + data.length];
commandApdu[0] = (byte) 0x00; // CLA
commandApdu[1] = (byte) 0xA4; // INS
commandApdu[2] = (byte) 0x04; // P1
commandApdu[3] = (byte) 0x00; // P2
commandApdu[4] = (byte) (data.length & 0x0FF); // Lc
System.arraycopy(data, 0, commandApdu, 5, data.length);
commandApdu[commandApdu.length - 1] = (byte) 0x00; // Le
return commandApdu;
}

/**
* step 1 code end
*/

/**
* add blanks to a string on right side up to a length of len
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Talk to your CreditCard part 0"
android:text="Talk to your CreditCard part 1"
android:textAlignment="center"
android:textSize="20sp"
android:textStyle="bold" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<string name="app_name">Talk to your Credit Card</string>
<string name="action_licenses">Used libraries and their licenses</string>
<string name="copy_right" translatable="false">Copyrights © %1$d</string>
<string name="app_description">This is the basic app (part 0) for the \"Talk to your Credit Card\" application.\n\nThe full app reads your Credit Card and retrieves the card number and expiration date.</string>
<string name="app_description">This is the first app (part 1) for the \"Talk to your Credit Card\" application.\n\nThe full app reads your Credit Card and retrieves the card number and expiration date.</string>
</resources>
Binary file removed docs/app00.png
Binary file not shown.
Binary file added docs/app01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/full/app00.png
Binary file not shown.
Binary file added docs/full/app01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 26 additions & 1 deletion logfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```plaintext
NFC tag discovered
TagId: 0585921afb9100
TagId: 028eedb17074b0
TechList found with these entries:
android.nfc.tech.IsoDep
android.nfc.tech.NfcA
Expand All @@ -16,6 +16,31 @@ increase IsoDep timeout for long lasting reading
timeout old: 2000 ms
timeout new: 10000 ms
*********************************
************ step 01 ************
* select PPSE *
*********************************
01 select PPSE command length 20 data: 00a404000e325041592e5359532e444446303100
01 select PPSE response length 64 data: 6f3c840e325041592e5359532e4444463031a52abf0c2761254f07a000000004101050104465626974204d6173746572436172648701019f0a04000101019000
------------------------------------
6F 3C -- File Control Information (FCI) Template
84 0E -- Dedicated File (DF) Name
32 50 41 59 2E 53 59 53 2E 44 44 46 30 31 (BINARY)
A5 2A -- File Control Information (FCI) Proprietary Template
BF 0C 27 -- File Control Information (FCI) Issuer Discretionary Data
61 25 -- Application Template
4F 07 -- Application Identifier (AID) - card
A0 00 00 00 04 10 10 (BINARY)
50 10 -- Application Label
44 65 62 69 74 20 4D 61 73 74 65 72 43 61 72 64 (=Debit MasterCard)
87 01 -- Application Priority Indicator
01 (BINARY)
9F 0A 04 -- [UNKNOWN TAG]
00 01 01 01 (BINARY)
90 00 -- Command successfully executed (OK)
------------------------------------
*********************************
************ step 99 ************
* our journey ends *
Expand Down
7 changes: 3 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Talk to your Credit Card part 0
# Talk to your Credit Card part 1

This app shows how to talk with a Credit Card and get information's like the Credit Card number,
the card's expiration date and some other data.
Expand All @@ -18,8 +18,7 @@ The app uses the NFC **ReaderMode** to get access to the card.

There are apps available for each step in my GitHub repository - the naming shows the step that has the code including this step.

This is the app for the general overview, means it is the basic app that has a very limited functionality: it detects the presence of a Credit Card
near the device's NFC reader: **TalkToYourCreditCardPart0**.
This is the app for the first step 1: **select the Paypass Payment System Environment (PPSE)** in **TalkToYourCreditCardPart1**.

The app is tested on real Android devices running Android versions 5.0.1, 8.0 and 13.

Expand All @@ -32,7 +31,7 @@ These are the steps to read a payment card, it is a kind of "question & answer"
- read all files given in the AFL list and find the file where there are the elements "Application Primary Account Number" and "Application Expiration Date"
- print out the "Application Primary Account Number" ("PAN") = card number and "Application Expiration Date" = expiration date of the card.

![step 0: after reading a Credit Card](docs/app00.png?raw=true)
![step 1: after reading a Credit Card](docs/app01.png?raw=true)

In AndroidManifest.xml grant these permissions:
```plaintext
Expand Down

0 comments on commit ed04ba8

Please sign in to comment.