element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Internet of Things
  • Technologies
  • More
Internet of Things
Blog Blockchain - Talk Directly to the Infineon 2Go Smart Cards API
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Internet of Things to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 21 Mar 2020 1:55 PM Date Created
  • Views 1514 views
  • Likes 4 likes
  • Comments 5 comments
  • infineon
  • security_2go
  • apdu
  • ethereum
  • rt
  • cryptocurrency
Related
Recommended

Blockchain - Talk Directly to the Infineon 2Go Smart Cards API

Jan Cumps
Jan Cumps
21 Mar 2020

This post is part of the Infineon Blockchain Starter Kit road test.

Blockchain - outside of the bitcoin context - is new to me.

Follow along with me on this path to learn the technology....

 

 

You talk to the Security 2Go cards with an API called Smart Card Application Protocol Data Unit (APDU).

According to Wikipedia "an application protocol data unit (APDU) is the communication unit between a smart card reader and a smart card"

image

 

The Security 2Go Starter Kit User Manual describes the specifics for the cards of the Road Test.

And it comes with an example communication. I'll review part of that example here.

 

 

The commands that are supported by the Infineon cards and documented in the user guide are these:

image

image source: User Manual Blockchain Security 2Go Starter Kit + the envelope that my reader came in

 

What you need to test APDU (and the example from the user guide) is an NFC reader/writer that supports ISO/IEC 14443, and software that allows you to send and receive data via that reader.

I'm using Digital Logic's µFR Nano as reader, and their µFR APDU Send/Receive test application.

image

The app is easy to use. It's a minimal wrapper, accepting APDU commands, returning reply and status code.

Ideal for testing scenarios as the one in the user guide.

If you happen to have a PC/SC compatible reader, there are device independent test programs for this on various operating systems.

 

 

APDU Example: Open an Application Session with the Card

 

Send the SELECT APP command

 

This is the first command you have to send to the card before it can be used in a scenario.

The APDU command will be: 00A404000DD276000004150200010000000100.

It looks magical now, but it's explained below.

image

image source: User Manual Blockchain Security 2Go Starter Kit

 

APDU Send / Receive Communication Script

image

 

  • 00 this is the instruction's class
  • A4 this is instruction A4: SELECT APP (open application session)
  • 0400 parameters 1 and 2 (both a byte). 04 indicates that the app is determined by the DF name. Second parameter is not used in this function.
  • 0D the AID data field hereafter has a length of 13, (0x0D)
  • D2760000041502000100000001 the AID of the Infineon cards.
  • 00 length of the reply. The value Infineon's guide suggests here surprises me. The instruction doc says it expects 18 (0x12). The test app says we got 15 bytes back...

image

Analyse the Reply

 

This is what what the card sends back: 0002090C2900020040001576312E309000.

  • 00 the pin isn't active - pin not set (by me)
  • 02 09 0C 29 00 02 00 40 00 15  the ID of this particular card - If I tap another card this is different
  • 76 31 2E 30 the ascii version string. Strange enough different than what's documented and what the card returns in the user guide's example. v1.0. That's 2 bytes shorter.
  • 90 00 the return code. Success

image

 

So I get a successful reply but the version part of the reply puzzles me.

In particular because the definition with length 7 and then the example returning 6 bytes are in the same document, a few pages appart.

image

 

Now my own test: Get a public Key

 

The command should be, for the key with index 1: 0016010000.

image

 

Here's the test:

image

The answer is 9000, so that's a success. Let's look at the rest of the reply: 000F42360001869604D82CCB636938D3B7C721796BDB005C06D267881EF45C7989E43E96DF321CDAB14E69385C2D20BEC02C401274EA1C3EC77BFF090CD02E6D29AA160782CD73580D.

 

  • 000F4236 how many signatures left for this card: 999990
  • 00018696 how many for key #1: 99990
  • 04D82CCB636938D3B7C721796BDB005C06D267881EF45C7989E43E96DF321CDAB14E69385C2D20BEC02C401274EA1C3EC77BFF090CD02E6D29AA160782CD73580D 65 bytes
    • 04: fixed value
    • D82CCB636938D3B7C721796BDB005C06D267881EF45C7989E43E96DF321CDAB1: 32 bit x-coordinate
    • 4E69385C2D20BEC02C401274EA1C3EC77BFF090CD02E6D29AA160782CD73580D: 32 bit y-coordinate

 

That's it. Talk to the card's on-board microcontroller via the APDU protocol. Initialise a session, then ask some data (one of the public keys).

That's the basis for all applications dealing with the card. You'll find exactly the same commands back in the Android app discussed before.

 

How does this link to blockchain?

 

Several of the functions in the card can play a role (and do play a role in the coinfinity app).

In blockchain, you work with smart contracts (it's actually executable code that's accepted by parties to perform a certain transaction in the ledger).

When submitting such a transaction, using such an agreed smart contract, you use the keys and API.

The public key (retrieved via the API) is used to determine your blockchain address.

The private key (not available via the API) is used internally in the card to sign the (hash representation of) the data inside the smart contract (calculated via the API).

Your blockchain application will talk to the chain to get info and submit transactions. And talk to the RFC reader to get addresses, keys, and signed hashes.

Your application will orchestrate the services of both the blockchain and the RFC-reader+card to or complete a full blockchain transaction.

 

Thanks for following along. This is the end of the story.

 

 

Related Blog
Blockchain - HyperLedger Fabric pt 1: post and search transactions on a distributed trusted ledger
Blockchain - Hyperledger Burrow: set up a distributed ledger
Blockchain - Get Some Crypto Currency on an Infineon Security 2Go Card
Blockchain - Debug the Infineon Demo App with Android Studio and Your Phone
Blockchain - Analyse the Infineon Android Demo App - part a: Detect Card
Blockchain - Analyse the Infineon Android Demo App - part b: Retrieve Ethereum Crypto Currency Balance
Blockchain - Analyse the Infineon Android Demo App - part c: Transaction, Move Crypto Currency to Another Account
Blockchain - Talk Directly to the Infineon 2Go Smart Cards API
Blockchain - Smart Contract Test
Road Test notepad: Infineon Blockchain Starter Kit
Infineon Blockchain Starter Kit - Review
Blockchain - HyperLedger Fabric pt 2: application using blockchain and smart contract
Blockchain - HyperLedger Fabric pt 3: web console

 

 

For the Digital Logic µFR Reader:

Related Blog
Blockchain - Talk Directly to the Infineon 2Go Smart Cards API
NFC Card Reader Protocol of Digital Logic µFR - part 0: intent
µFR NFC Card Reader - part 1: first C program for Linux (RPi, BB, ...)
µFR NFC Card Reader - part 2: first C++ program
µFR NFC Card Reader - part 3: C++ Class to handle ISO14443 / APDU cards
µFR NFC Card Reader - part 4: first meaningful ISO14443 / APDU conversation
µFR NFC Card Reader - part 5: refactor, look back at initial design
Attachments:
digitallogic_rfc_cpp_20201215.zip
  • Sign in to reply

Top Comments

  • DAB
    DAB over 5 years ago +1
    Great series Jan. I now better understand Block chain and its uses. Thanks DAB
  • Jan Cumps
    Jan Cumps over 4 years ago

    If you have a set of these cards and a smartphone, you can test them with the NFC Tools app from wak dev.

    Install the app, start it.

    Go to other-> Advanced NFC commands.

    In I/O Class, select IsoDep (ISO 14443-4)

    Paste this in the data field (the command to start an application session with the card and get the card ID)

    00A404000DD276000004150200010000000100

     

    Tap and keep your card to the NFC reader of your phone.

     

    Send Command.

     

    You get the card ID. Check the post above to learn where the ID is in the return string.

    image

    Exactly the same result as in the post above.

    You can keep on talking to the card. Let it show its public keys, sign data, ...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago

    I'm going to try and write a command line tool or service that allows to use my Digital Logic µFR card reader from other programs.

    I first need access to the license of their library though. That's not publicly available as far as I can see. I raised an issue for that: https://github.com/nfc-rfid-reader-sdk/ufr-lib/issues/1

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to DAB

    That was one of my goal too. Understand the mechanism behind it.

    Starting from zero , installing a plain block chain and learn how to use it - without the currency connotation - helped getting it.

    I still have a lot of questions - how to run it reliably, what if you want to keep the data distributed yet private, ...

    But I think I've taken the steep bump of the learning path.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 5 years ago

    Great series Jan.

     

    I now better understand Block chain and its uses.

     

    Thanks

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago

    The comparable code in the Android coinfinity app:

     

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube