Skip to content
Tools to help you work with the ISO7816 standard.
C#
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src APDU classes are now immutable Sep 21, 2018
test/Iso7816.Tests APDU classes are now immutable Sep 21, 2018
.gitignore Initial commit Oct 17, 2017
LICENSE Initial commit Oct 17, 2017
README.md Update README.md Apr 19, 2018

README.md

Iso7816 Build status

A library of tools to help you work with the ISO7816 standard, mainly revolving around the building and parsing of APDU commands (ISO7816-4).

Getting started

Grab the package from NuGet, which will install all dependencies.

Install-Package Iso7816

The library is compiled against .NET Standard 2.0 - see here for information on your project's runtime requirements.

Usage

Both Command and Response APDUs can be built using the library. Constraints imposed by the specification will be imposed at the time of building and parsing, such as trying to exceed an acceptable size for certain fields. The following Command APDU cases are supported:

  • Case1
  • Case2S
  • Case3S
  • Case4S
  • Case2E
  • Case3E
  • Case4E

To use Extended mode you must opt in to it by doing the following. This will globally configure the ability to use extended commands:

CommandApdu.AllowExtendedMode = true

ResponseApdu.AllowExtendedMode = true

APDUs can be built from individual elements/fields or parsed from existing collections of bytes:

CommandApdu.Case1(0x00, 0xA4, 0x00, 0x00)

\\ -> 00-A4-00-00

CommandApdu.Parse(new byte[] { 0x00, 0xA4, 0x00, 0x00 })

\\ -> 00-A4-00-00

Once an APDU has been created, its various properties can be mutated - for example, you could add command data to a Case1 Command APDU - doing so would automatically change it to be a Case3S APDU in this instance.

Serialisation

All APDU objects are marked as [Serializable]. The library also includes a handful of Json.NET JsonConverter classes which can be used when serialising APDUs; included are converters that will deal with APDUs whose buffers are in base64 or hex pairs formats.

You can’t perform that action at this time.