When the card doesn't support command chaining, throw CommandTooLong error if the command is too long.
(This currently happens with the scdc backend when uploading rsa4096 keys, because scdc additionally limits command size)
This commit is contained in:
parent
dbf2e9e3fb
commit
56f4459932
2 changed files with 11 additions and 0 deletions
|
@ -183,6 +183,14 @@ fn send_command_low_level(
|
|||
} else {
|
||||
let serialized = cmd.serialize(ext)?;
|
||||
|
||||
// Can't send this command to the card, because it is too long and
|
||||
// the card doesn't support command chaining.
|
||||
if serialized.len() > max_cmd_bytes {
|
||||
return Err(OpenpgpCardError::CommandTooLong(serialized.len()));
|
||||
}
|
||||
|
||||
log::debug!(" -> APDU command: {:x?}", &serialized);
|
||||
|
||||
let resp = card_client.transmit(&serialized, buf_size)?;
|
||||
|
||||
log::debug!(" <- APDU response: {:x?}", resp);
|
||||
|
|
|
@ -11,6 +11,9 @@ pub enum OpenpgpCardError {
|
|||
#[error("OpenPGP card error status {0}")]
|
||||
OcStatus(OcErrorStatus),
|
||||
|
||||
#[error("Command too long ({0} bytes)")]
|
||||
CommandTooLong(usize),
|
||||
|
||||
#[error("Internal error {0}")]
|
||||
InternalError(anyhow::Error),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue