|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include "mod_gpg/openpgp/t1/t1_block.h"Go to the source code of this file.
Classes | |
| struct | t1_state_t |
| Card-side T=1 state. Embedded entirely in caller-provided storage. More... | |
Macros | |
| #define | T1_MAX_APDU_LEN 4096 |
| ISO 7816-3 T=1 transport state machine (card side). | |
| #define | T1_MAX_RESPONSE_LEN 4096 |
| Maximum response size that can be chunked back. | |
Enumerations | |
| enum | t1_feed_t { T1_FEED_NEED_OUT , T1_FEED_APDU_READY , T1_FEED_WAIT_MORE , T1_FEED_IGNORED } |
| Outcome of feeding a block to the state machine. More... | |
Functions | |
| void | t1_state_init (t1_state_t *state, bool use_crc) |
| Initialise the state machine. Sets sequence numbers to 0, IFSC/IFSD to defaults. | |
| t1_feed_t | t1_state_feed (t1_state_t *state, const t1_block_t *block) |
| 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). | |
| #define T1_MAX_APDU_LEN 4096 |
ISO 7816-3 T=1 transport state machine (card side).
Layered on top of t1_block.h. Owns:
The CCID layer (ccid.cpp) drives this state machine through three calls:
Maximum APDU size we accept across chained I-blocks (extended-length cap).
Definition at line 27 of file t1_state.h.
| #define T1_MAX_RESPONSE_LEN 4096 |
Maximum response size that can be chunked back.
Definition at line 32 of file t1_state.h.
| enum t1_feed_t |
Outcome of feeding a block to the state machine.
Definition at line 36 of file t1_state.h.
| 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.