APDU for Java
=============
This package provides utilities for generating and parsing APDU commmands and
responses as specified in ISO/IEC 7816. These utilities may be useful for
implementers of smart card readers, smart card tracers and debuggers, or
smart card emulation (such as Android's Host Card Emulation, or HCE).
Real-world smart card implementations sometimes deviate from the formal
specifications in ISO/IEC 7186, so these packages strike a balance between
strict adherence to the specification and flexibility to handle non-compliant
implementations in the real world.
Some care has been taken to ensure that the implementations in these packages
perform well, particularly in the context of contactless smart cards (i.e.
ISO/IEC 14443), where interaction time between card and reader is limited.
The apdu4j package provides high-level utilities for constructing and parsing
APDU commands and responses.
The bertlv package provides utilities for constructing and parsing sequences
of BER-TLV objects, nested composite BER-TLV objects, and the PDOL lists of
tags and lengths (omitting value fields) that are common in EMV applications.
The utilities package provides classes and utility methods that support the
implementation of the apdu4j and bertlv packages, and which implementers may
find useful on their own:
The Bar class implements slices of byte arrays as an atomic data type. As
many operations in smart card processing involve progressively extracting
data from APDU buffers, the Bar package allows array slices to be passed by
reference without copying the underlying array elements.
The ByteUtil class provides utility methods that can be used to marshall
numeric data types to and from APDU buffers.
The HexUtil class provides utility methods to convert between integer and
byte array types, and hexadecimal character strings. Smart card processing
often uses static byte array values, and implementers may find that coding
these as character strings with the conversion utilities makes them easier to
read and maintain than literal byte array initializers. In addition, the
conversion from byte arrays to hexadecimal strings simplifies output for
logging and debugging.
Distribution
------------
The source code for this package is available from SourceForge:
https://sourceforge.net/p/apdu-for-java/
License
-------
Copyright (c) 2016 Weydstone LLC dba Sutton Abinger
See the NOTICE file distributed with this work for additional information
regarding copyright ownership. Sutton Abinger licenses this file to you under
the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License
at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
Additional Resources
--------------------
The ISO/IEC 7816 specifications are available for purchase from ISO (or your
local affiliate) at https://www.iso.org/committee/45144/x/catalogue/. For the
code in these packages, ISO/IEC 7816 Parts 3 and 4 are relevant.
The Smart Card Basics web site provides a good overview of relevant smart
card standards and specifications:
http://www.smartcardbasics.com/smart-card-standards.html