CCID now bounds initial XfrBlock APDU responses to the advertised payload budget and converts oversized responses into 61xx chaining instead of cutting off the status word.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2026-07-12 22:00:55 +02:00
parent a613edd638
commit 7c38eced51
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -57,6 +57,7 @@
#define CCID_MSG_CHAIN_OFFSET 9
#define CCID_MSG_DATA_OFFSET 10 /* == CCID_MSG_HEADER_SIZE */
#define CCID_MAX_MSG_DATA_SIZE USB_BUF_SIZE
#define CCID_MAX_XFR_BLOCK_DATA_SIZE (USB_BUFFER_SIZE - CCID_MSG_DATA_OFFSET)
#define CCID_STATUS_RUN 0x00
#define CCID_STATUS_PRESENT 0x01
@@ -336,6 +337,12 @@ void driver_exec_finished_ccid(uint8_t itf, uint16_t size_next) {
}
void driver_exec_finished_cont_ccid(uint8_t itf, uint16_t size_next, uint16_t offset) {
if (offset == 0) {
size_next = apdu_limit_response(size_next, CCID_MAX_XFR_BLOCK_DATA_SIZE);
}
else if (size_next > CCID_MAX_XFR_BLOCK_DATA_SIZE) {
size_next = CCID_MAX_XFR_BLOCK_DATA_SIZE;
}
ccid_response[itf] = (ccid_header_t *) (ccid_tx[itf].buffer + ccid_tx[itf].w_ptr + offset);
ccid_response[itf]->bMessageType = CCID_DATA_BLOCK_RET;
ccid_response[itf]->dwLength = size_next;
+1 -1
View File
@@ -118,7 +118,7 @@ extern void driver_exec_finished_cont_emul(uint8_t itf, uint16_t size_next, uint
#endif
#ifndef USB_BUFFER_SIZE
#define USB_BUFFER_SIZE 2048
#define USB_BUFFER_SIZE 2048u
#endif
PACK(