openpgp-card: handle backend capability hints in Card::new
This commit is contained in:
parent
b88caa2471
commit
f659a623d2
2 changed files with 16 additions and 10 deletions
|
@ -101,7 +101,7 @@ fn send_command_low_level<C>(
|
||||||
where
|
where
|
||||||
C: CardTransaction + ?Sized,
|
C: CardTransaction + ?Sized,
|
||||||
{
|
{
|
||||||
let (ext_support, chaining_support, mut max_cmd_bytes, max_rsp_bytes) =
|
let (ext_support, chaining_support, max_cmd_bytes, max_rsp_bytes) =
|
||||||
if let Some(caps) = card_caps {
|
if let Some(caps) = card_caps {
|
||||||
log::trace!("found card caps data!");
|
log::trace!("found card caps data!");
|
||||||
|
|
||||||
|
@ -118,15 +118,6 @@ where
|
||||||
(false, false, 255, 255)
|
(false, false, 255, 255)
|
||||||
};
|
};
|
||||||
|
|
||||||
// If the CardTransaction implementation has an inherent limit for the cmd
|
|
||||||
// size, take that limit into account.
|
|
||||||
// (E.g. when using scdaemon as a CardTransaction backend, there is a
|
|
||||||
// limitation to 1000 bytes length for Assuan commands, which
|
|
||||||
// translates to maximum command length of a bit under 500 bytes)
|
|
||||||
if let Some(max_card_cmd_bytes) = card_tx.max_cmd_len() {
|
|
||||||
max_cmd_bytes = usize::min(max_cmd_bytes, max_card_cmd_bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
log::trace!(
|
log::trace!(
|
||||||
"ext le/lc {}, chaining {}, max cmd {}, max rsp {}",
|
"ext le/lc {}, chaining {}, max cmd {}, max rsp {}",
|
||||||
ext_support,
|
ext_support,
|
||||||
|
|
|
@ -180,6 +180,21 @@ impl Card {
|
||||||
let pw1_max = pw_status.pw1_max_len();
|
let pw1_max = pw_status.pw1_max_len();
|
||||||
let pw3_max = pw_status.pw3_max_len();
|
let pw3_max = pw_status.pw3_max_len();
|
||||||
|
|
||||||
|
// If the CardTransaction implementation has an inherent limit for the cmd
|
||||||
|
// size, take that limit into account.
|
||||||
|
// (E.g. when using scdaemon as a CardTransaction backend, there is a
|
||||||
|
// limitation to 1000 bytes length for Assuan commands, which
|
||||||
|
// translates to maximum command length of a bit under 500 bytes)
|
||||||
|
if let Some(max_card_cmd_bytes) = tx.tx.max_cmd_len() {
|
||||||
|
max_cmd_bytes = u16::min(max_cmd_bytes, max_card_cmd_bytes as u16);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: add a more general mechanism to ask the backend for
|
||||||
|
// amendments to the CardCaps (e.g. to change support for
|
||||||
|
// "extended length")
|
||||||
|
//
|
||||||
|
// Also see https://blog.apdu.fr/posts/2011/05/extended-apdu-status-per-reader/
|
||||||
|
|
||||||
let caps = CardCaps::new(
|
let caps = CardCaps::new(
|
||||||
ext_support,
|
ext_support,
|
||||||
chaining_support,
|
chaining_support,
|
||||||
|
|
Loading…
Reference in a new issue