Generic utility class for building and handling of smart card APDUs according to ISO 7816-4. Command APDUs and response APDUs are implemented.

Namespace: CardWerk.SmartCard
Assembly: CardWerk.SmartCard (in CardWerk.SmartCard.dll)

Public Class CardCommandAPDU 
Implements ICloneable
This language is not supported or no code example is available.
public class CardCommandAPDU : ICloneable
This language is not supported or no code example is available.
public ref class CardCommandAPDU  : public ICloneable^
This language is not supported or no code example is available.
public class CardCommandAPDU 
implements ICloneable
This language is not supported or no code example is available.
Name Description
Public constructor CardCommandAPDU(byte, byte, byte, byte) Construct CardCommandAPDU instance for an ISO 7816-4 case 1 "NODATA_NODATA" command.
Public constructor CardCommandAPDU(byte, byte, byte, byte, byte[]) Construct CardCommandAPDU instance for an ISO 7816-4 (short or extended) case 3 "DATA_NODATA" command.
Public constructor CardCommandAPDU(byte, byte, byte, byte, byte[], int) Construct CardCommandAPDU instance for an ISO 7816-4 (short or extended) case 4 "DATA_DATA" command.
Public constructor CardCommandAPDU(byte, byte, byte, byte, int) Construct CardCommandAPDU instance for an ISO 7816-4 (short or extended) case 2 "NODATA_DATA" command.
Top
Name Description
Public property CLA Access to the class byte of an ISO 7816-4 command APDU.
Public property Case Indicates the "case" of this ISO 7816-4 command APDU.
Public property INS Access to the instruction byte of an ISO 7816-4 command APDU.
Public property IsExtended Indicates whether this is an extended ISO 7816-4 command APDU.
Public property Lc Access to the length field Lc of an ISO 7816-4 command APDU. This is the actual length of the data field.
Public property Le Access to the length field Le of an ISO 7816-4 command APDU. This is the expected length of the response data field.
Public property P1 Access to the first parameter byte of an ISO 7816-4 command APDU.
Public property P2 Access to the second parameter byte of an ISO 7816-4 command APDU.
Top
Name Description
Public method AppendData(byte) Appends a single data byte to the data field of this command APDU.
Public method AppendData(byte[]) Appends the given data block to the data field of this command APDU.
Public method AppendData(byte[], int, int) Appends a single data byte to the data field of this command APDU.
Public method Clone() Creates a new object that is a copy of the current instance.
Public method GenerateBytes() Builds the final command APDU into a newly allocated byte array.
Public method GetData() Returns the data field of an ISO 7816-4 command APDU.
Public method Static GetInstructionName(byte, byte) Returns the instruction name for a given instruction byte. We currently support names defined in ISO 7816-4 1995 as well as PC/SC part 3. PC/SC part 3 kicks in, when CLA=0xFF is detected.
Public method GetInstructionName() Returns the ISO 7816-4 instruction name for the instruction byte in this command APDU.
Public method Static ParseBytes(byte[]) Creates a CardCommandAPDU instance by parsing a command APDU given as a byte array.
Public method Static ParseBytes(byte[], int, int) Creates a CardCommandAPDU instance by parsing a command APDU given as a range inside a byte array.
Public method SetData(byte[]) Adds or replaces the data field of this command APDU.
Public method SetData(byte[], int, int) Adds or replaces the data field of this command APDU.
Public method ToString() Returns a string that represents the current object.
Top
Name Description
Public field Static MAXEXTENDEDLC (Immutable) The max size of the data field of an ISO 7816-4 command APDU with extended length fields.
Public field Static MAXEXTENDEDLE (Immutable) The max value for the field Le of an ISO 7816-4 command APDU with extended length fields.
Public field Static MAXEXTENDEDLENGTH (Immutable) The max length in bytes of an ISO 7816-4 command APDU with extended length fields.
Public field Static MAXSHORTLC (Immutable) The max size of the data field of an ISO 7816-4 command APDU with short length fields.
Public field Static MAXSHORTLE (Immutable) The max value for the field Le of an ISO 7816-4 command APDU with short length fields.
Public field Static MAXSHORTLENGTH (Immutable) The max length in bytes of an ISO 7816-4 command APDU with short length fields.
Public field Static MINLENGTH (Immutable) The min length of any ISO 7816-4 command APDU.
Top

This class supports command APDUs with short and extended length fields. If the data field size is up to and including a maximum size of 255 bytes, and the length of the expected data Le is in the range from 1 through 256, then a command APDU with a short length fields will be built. If either the data field size is 256 bytes or more, or Le is 257 or larger, then a command APDU with extended length fields will be built.

This class defines several useful constants that provide minimum and maximum limits of command APDU sizes and fields.

In order to create an all new command APDU from scratch start with one of the constructors of this class. In order to parse a raw command APDU from a byte array use one of the overloaded static ParseBytes methods.

Use the method GenerateBytes in order to build a raw command APDU byte array to be sent to a smart card. Note that parsing and rebuilding a command APDU may lead to a different byte representation.

.NET Framework

Supported in: 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

.NET Core

Supported in: 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0

.NET Standard

Supported in: 2.0