Keyple Util C++ Library 2.0.0
Reference Terminal Reader API for C++
Static Public Member Functions | List of all members
keyple::core::util::ApduUtil Class Referencefinal

#include <ApduUtil.h>

Static Public Member Functions

static const std::vector< uint8_t > build (const uint8_t cla, const uint8_t ins, const uint8_t p1, const uint8_t p2, const std::vector< uint8_t > &dataIn, const uint8_t le)
 
static const std::vector< uint8_t > build (const uint8_t cla, const uint8_t ins, const uint8_t p1, const uint8_t p2, const std::vector< uint8_t > &dataIn)
 
static const std::vector< uint8_t > build (const uint8_t cla, const uint8_t ins, const uint8_t p1, const uint8_t p2, const uint8_t le)
 
static const std::vector< uint8_t > build (const uint8_t cla, const uint8_t ins, const uint8_t p1, const uint8_t p2)
 
static std::vector< uint8_t > allocateBuffer (const std::vector< uint8_t > &data, const uint8_t le)
 
static std::vector< uint8_t > allocateBuffer (const std::vector< uint8_t > &data)
 
static std::vector< uint8_t > allocateBuffer (const uint8_t le)
 
static std::vector< uint8_t > allocateBuffer ()
 
static bool isCase4 (const std::vector< uint8_t > &apduCommand)
 

Detailed Description

Util to build APDUs and check case 4.

Since
2.0.0

Definition at line 30 of file ApduUtil.h.

Member Function Documentation

◆ allocateBuffer() [1/4]

std::vector< uint8_t > keyple::core::util::ApduUtil::allocateBuffer ( )
static

(private)
Returns a byte array having the expected length according the APDU construction rules.

Returns
A new byte array.

Definition at line 167 of file ApduUtil.cpp.

◆ allocateBuffer() [2/4]

std::vector< uint8_t > keyple::core::util::ApduUtil::allocateBuffer ( const std::vector< uint8_t > &  data)
static

(private)
Returns a byte array having the expected length according the APDU construction rules.

Parameters
dataData array
Returns
A new byte array.

Definition at line 147 of file ApduUtil.cpp.

◆ allocateBuffer() [3/4]

std::vector< uint8_t > keyple::core::util::ApduUtil::allocateBuffer ( const std::vector< uint8_t > &  data,
const uint8_t  le 
)
static

(private)
Returns a byte array having the expected length according the APDU construction rules.

Parameters
dataData array
leExpected outgoing length
Returns
A new byte array.

Definition at line 135 of file ApduUtil.cpp.

◆ allocateBuffer() [4/4]

std::vector< uint8_t > keyple::core::util::ApduUtil::allocateBuffer ( const uint8_t  le)
static

(private)
Returns a byte array having the expected length according the APDU construction rules.

Parameters
leExpected outgoing length
Returns
A new byte array.

Definition at line 156 of file ApduUtil.cpp.

◆ build() [1/4]

const std::vector< uint8_t > keyple::core::util::ApduUtil::build ( const uint8_t  cla,
const uint8_t  ins,
const uint8_t  p1,
const uint8_t  p2 
)
static

Builds an APDU request from its elements as defined by the ISO 7816 standard.

Parameters
claThe class byte.
insThe instruction byte.
p1The parameter 1.
p2The parameter 2.
Returns
A byte array containing the resulting apdu command data.
Since
2.0.0

Definition at line 112 of file ApduUtil.cpp.

◆ build() [2/4]

const std::vector< uint8_t > keyple::core::util::ApduUtil::build ( const uint8_t  cla,
const uint8_t  ins,
const uint8_t  p1,
const uint8_t  p2,
const std::vector< uint8_t > &  dataIn 
)
static

Builds an APDU request from its elements as defined by the ISO 7816 standard.

Parameters
claThe class byte.
insThe instruction byte.
p1The parameter 1.
p2The parameter 2.
dataInThe data field of the command (optional).
Returns
A byte array containing the resulting apdu command data.
Since
2.0.0

Definition at line 58 of file ApduUtil.cpp.

◆ build() [3/4]

const std::vector< uint8_t > keyple::core::util::ApduUtil::build ( const uint8_t  cla,
const uint8_t  ins,
const uint8_t  p1,
const uint8_t  p2,
const std::vector< uint8_t > &  dataIn,
const uint8_t  le 
)
static

Builds an APDU request from its elements as defined by the ISO 7816 standard.

Parameters
claThe class byte.
insThe instruction byte.
p1The parameter 1.
p2The parameter 2.
dataInThe data field of the command (optional). If empty, then LC will be set to 0.
leThe maximum number of bytes expected in the data field of the response to the command (optional).
Returns
A byte array containing the resulting apdu command data.
Since
2.0.0

Definition at line 26 of file ApduUtil.cpp.

◆ build() [4/4]

const std::vector< uint8_t > keyple::core::util::ApduUtil::build ( const uint8_t  cla,
const uint8_t  ins,
const uint8_t  p1,
const uint8_t  p2,
const uint8_t  le 
)
static

Builds an APDU request from its elements as defined by the ISO 7816 standard.

Parameters
claThe class byte.
insThe instruction byte.
p1The parameter 1.
p2The parameter 2.
leThe maximum number of bytes expected in the data field of the response to the command (optional).
Returns
A byte array containing the resulting apdu command data.
Since
2.0.0

Definition at line 88 of file ApduUtil.cpp.

◆ isCase4()

bool keyple::core::util::ApduUtil::isCase4 ( const std::vector< uint8_t > &  apduCommand)
static

Indicates if the provided byte array contains a case4 APDU command.

The ISO7816 case for data in a command-response pair is determined from the provided arguments:

  • dataIn  = null, le  = null  →  case 1: no command data, no response data expected.
  • dataIn  = null, le != null  →  case 2: no command data, expected response data.
  • dataIn != null, le  = null  →  case 3: command data, no response data expected.
  • dataIn != null, le  = 0      →  case 4: command data, expected response data.

Only the indication for case 4 is retained in the end.
In this case (incoming and outgoing data for the card), Le is set to 0, letting the lower layer (see API plugin) take care of recovering the exact length of the outgoing data.

Parameters
apduCommandThe apduCommand to check.
Returns
true the APDU command is case 4.
Since
2.0.0

Definition at line 177 of file ApduUtil.cpp.


The documentation for this class was generated from the following files: