|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Go to the source code of this file.
Functions | |
| static size_t | encode_rblock (t1_state_t *state, uint8_t nr, t1_r_error_t err) |
| static size_t | encode_sblock_response (t1_state_t *state, t1_s_subtype_t subtype, const uint8_t *inf, uint8_t inf_len) |
| void | t1_state_init (t1_state_t *state, bool use_crc) |
| Initialise the state machine. Sets sequence numbers to 0, IFSC/IFSD to defaults. | |
| static t1_feed_t | handle_iblock (t1_state_t *state, const t1_block_t *blk) |
| static t1_feed_t | handle_rblock (t1_state_t *state, const t1_block_t *blk) |
| static t1_feed_t | handle_sblock (t1_state_t *state, const t1_block_t *blk) |
| t1_feed_t | t1_state_feed (t1_state_t *state, const t1_block_t *blk) |
| Feed an incoming decoded block to the state machine. | |
| bool | t1_state_queue_response (t1_state_t *state, const uint8_t *resp, size_t resp_len) |
| Register the application's APDU response so the state machine can chunk it into I-blocks. | |
| size_t | t1_state_next_outbound (t1_state_t *state, uint8_t *out, size_t out_cap) |
| Emit the next outbound block (control reply or response chunk). | |
|
static |
Definition at line 19 of file t1_state.cpp.
References t1_state_t::control_block, t1_state_t::control_len, t1_block_encode_r(), and t1_state_t::use_crc.
Referenced by handle_iblock(), handle_rblock(), and handle_sblock().
|
static |
Definition at line 27 of file t1_state.cpp.
References t1_state_t::control_block, t1_state_t::control_len, t1_block_encode_s(), and t1_state_t::use_crc.
Referenced by handle_iblock(), and handle_sblock().
|
static |
Definition at line 46 of file t1_state.cpp.
References t1_state_t::apdu_buf, t1_state_t::apdu_in_progress, t1_state_t::apdu_len, t1_block_t::edc_ok, encode_rblock(), encode_sblock_response(), t1_block_t::i_more, t1_block_t::i_ns, t1_block_t::inf, t1_block_t::inf_len, t1_state_t::ns_expected, T1_FEED_APDU_READY, T1_FEED_NEED_OUT, T1_FEED_WAIT_MORE, T1_R_EDC_ERR, T1_R_OK, T1_R_OTHER_ERR, and T1_S_ABORT_RESP.
Referenced by t1_state_feed().
|
static |
Definition at line 84 of file t1_state.cpp.
References t1_block_t::edc_ok, encode_rblock(), t1_state_t::ns_expected, t1_state_t::ns_send, t1_block_t::r_nr, t1_state_t::resp_pending, T1_FEED_IGNORED, T1_FEED_NEED_OUT, and T1_R_EDC_ERR.
Referenced by t1_state_feed().
|
static |
Definition at line 98 of file t1_state.cpp.
References t1_state_t::apdu_in_progress, t1_state_t::apdu_len, t1_block_t::edc_ok, encode_rblock(), encode_sblock_response(), t1_state_t::ifsd, t1_block_t::inf, t1_block_t::inf_len, t1_state_t::ns_expected, t1_state_t::ns_send, t1_state_t::resp_len, t1_state_t::resp_pending, t1_state_t::resp_sent, t1_block_t::s_subtype, T1_FEED_IGNORED, T1_FEED_NEED_OUT, T1_R_EDC_ERR, T1_R_OTHER_ERR, T1_S_ABORT_REQ, T1_S_ABORT_RESP, T1_S_IFS_REQ, T1_S_IFS_RESP, T1_S_RESYNCH_REQ, T1_S_RESYNCH_RESP, T1_S_WTX_REQ, and T1_S_WTX_RESP.
Referenced by t1_state_feed().
| t1_feed_t t1_state_feed | ( | t1_state_t * | state, |
| const t1_block_t * | block ) |
Feed an incoming decoded block to the state machine.
On EDC errors or unexpected sequence numbers the function queues an R-block (control_block). Mainline I-blocks either complete an APDU (T1_FEED_APDU_READY) or ACK chained pieces (T1_FEED_WAIT_MORE). S-blocks are handled and their responses queued.
Definition at line 142 of file t1_state.cpp.
References handle_iblock(), handle_rblock(), handle_sblock(), t1_block_t::kind, T1_BLOCK_I, T1_BLOCK_R, T1_BLOCK_S, and T1_FEED_IGNORED.
| void t1_state_init | ( | t1_state_t * | state, |
| bool | use_crc ) |
Initialise the state machine. Sets sequence numbers to 0, IFSC/IFSD to defaults.
| state | State storage (caller-owned, will be zeroed). |
| use_crc | EDC choice; must match what's negotiated with the reader via ATR. |
Definition at line 36 of file t1_state.cpp.
References t1_state_t::ifsc, t1_state_t::ifsd, t1_state_t::ns_expected, t1_state_t::ns_send, T1_DEFAULT_IFSC, and t1_state_t::use_crc.
| size_t t1_state_next_outbound | ( | t1_state_t * | state, |
| uint8_t * | out, | ||
| size_t | out_cap ) |
Emit the next outbound block (control reply or response chunk).
| state | State machine. |
| out | Output buffer. |
| out_cap | Output buffer capacity. |
Definition at line 167 of file t1_state.cpp.
References t1_state_t::control_block, t1_state_t::control_len, t1_state_t::ifsd, t1_state_t::ns_send, t1_state_t::resp_buf, t1_state_t::resp_len, t1_state_t::resp_pending, t1_state_t::resp_sent, t1_block_encode_i(), T1_DEFAULT_IFSC, T1_OK, and t1_state_t::use_crc.
| bool t1_state_queue_response | ( | t1_state_t * | state, |
| const uint8_t * | resp, | ||
| size_t | resp_len ) |
Register the application's APDU response so the state machine can chunk it into I-blocks.
Must only be called after t1_state_feed returned T1_FEED_APDU_READY.
Definition at line 155 of file t1_state.cpp.
References t1_state_t::resp_buf, t1_state_t::resp_len, t1_state_t::resp_pending, and t1_state_t::resp_sent.