SE050 Driver
API reference
Loading...
Searching...
No Matches
Classes | Functions
se050::apdu Namespace Reference

Classes

struct  StatusWords
 Parsed status words from a response APDU. More...
 

Functions

Error BuildCaseShort (std::uint8_t cla, std::uint8_t ins, std::uint8_t p1, std::uint8_t p2, const std::uint8_t *data, std::uint8_t data_len, bool le_present, std::uint8_t le, std::uint8_t *out, std::size_t out_cap, std::size_t *out_len) noexcept
 Build a CASE 3/4 short command when data_len ≤ 255 and a 1-byte Le is enough.
 
Error BuildCase4Extended (std::uint8_t cla, std::uint8_t ins, std::uint8_t p1, std::uint8_t p2, const std::uint8_t *data, std::size_t data_len, std::uint8_t *out, std::size_t out_cap, std::size_t *out_len) noexcept
 Build a CASE 4 command APDU with extended length encoding.
 
Error ParseResponse (const std::uint8_t *rsp, std::size_t rsp_len, const std::uint8_t **data_out, std::size_t *data_len_out, StatusWords *sw_out) noexcept
 Parse a simple R-APDU: optional response data followed by SW1 SW2.
 
bool IsSuccess (const StatusWords &sw) noexcept
 Return true when SW1 == 0x90 and SW2 == 0x00.
 
bool IsMoreData (const StatusWords &sw) noexcept
 SW1 == 0x61 — more data available via GET RESPONSE (common GlobalPlatform pattern).
 

Function Documentation

◆ BuildCase4Extended()

Error se050::apdu::BuildCase4Extended ( std::uint8_t  cla,
std::uint8_t  ins,
std::uint8_t  p1,
std::uint8_t  p2,
const std::uint8_t *  data,
std::size_t  data_len,
std::uint8_t *  out,
std::size_t  out_cap,
std::size_t *  out_len 
)
inlinenoexcept

Build a CASE 4 command APDU with extended length encoding.

Layout: CLA INS P1 P2 00 Lc_hi Lc_lo [data...] Le_hi Le_lo (ISO/IEC 7816-4 section 5.1, case 4E). With an extended Lc present, Le is two bytes; 00 00 asks for up to 65536 bytes. (The three-byte 00 Le_hi Le_lo form is only for case 2E, which has no Lc.)

Parameters
claINS class byte.
insInstruction byte.
p1First parameter.
p2Second parameter.
dataCommand data field (may be nullptr if data_len == 0).
data_lenLength of data (0 … kMaxApduCommandBytes - 9).
outSerialized APDU.
out_capCapacity of out.
out_lenWritten length on success.

◆ BuildCaseShort()

Error se050::apdu::BuildCaseShort ( std::uint8_t  cla,
std::uint8_t  ins,
std::uint8_t  p1,
std::uint8_t  p2,
const std::uint8_t *  data,
std::uint8_t  data_len,
bool  le_present,
std::uint8_t  le,
std::uint8_t *  out,
std::size_t  out_cap,
std::size_t *  out_len 
)
inlinenoexcept

Build a CASE 3/4 short command when data_len ≤ 255 and a 1-byte Le is enough.

Layout: CLA INS P1 P2 Lc [data...] [Le]. If le_present is false, the Le byte is omitted (CASE 3). If le_present is true, le is appended (CASE 4 short).

◆ IsMoreData()

bool se050::apdu::IsMoreData ( const StatusWords &  sw)
inlinenoexcept

SW1 == 0x61 — more data available via GET RESPONSE (common GlobalPlatform pattern).

◆ IsSuccess()

bool se050::apdu::IsSuccess ( const StatusWords &  sw)
inlinenoexcept

Return true when SW1 == 0x90 and SW2 == 0x00.

◆ ParseResponse()

Error se050::apdu::ParseResponse ( const std::uint8_t *  rsp,
std::size_t  rsp_len,
const std::uint8_t **  data_out,
std::size_t *  data_len_out,
StatusWords *  sw_out 
)
inlinenoexcept

Parse a simple R-APDU: optional response data followed by SW1 SW2.

Parameters
rspFull response INF from the T=1 layer (typically T1Session::ExchangeInformation).
rsp_lenLength of rsp (must be ≥ 2).
data_outOptional pointer into rsp where payload starts (may equal rsp).
data_len_outLength of payload excluding status bytes.
sw_outStatus words.