From 84ee2a64f1a9d9170b53ef3a89a740db16a7bc85 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Mon, 28 Aug 2023 12:00:35 +0200 Subject: [PATCH] openpgp-card: explicitly limit command chunk size to 255 if extended length is unsupported --- openpgp-card/src/apdu.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpgp-card/src/apdu.rs b/openpgp-card/src/apdu.rs index 6fc9d9d..569481c 100644 --- a/openpgp-card/src/apdu.rs +++ b/openpgp-card/src/apdu.rs @@ -158,8 +158,10 @@ where log::trace!("chained command mode"); + let cmd_chunk_size = if ext_support { max_cmd_bytes } else { 255 }; + // Break up payload into chunks that fit into one command, each - let chunks: Vec<_> = cmd.data().chunks(max_cmd_bytes).collect(); + let chunks: Vec<_> = cmd.data().chunks(cmd_chunk_size).collect(); for (i, d) in chunks.iter().enumerate() { let last = i == chunks.len() - 1;