diff --git a/card-functionality/src/cards.rs b/card-functionality/src/cards.rs index 7f2c563..2a8a5c1 100644 --- a/card-functionality/src/cards.rs +++ b/card-functionality/src/cards.rs @@ -41,7 +41,7 @@ pub struct TestCardData { } impl TestCardData { - pub(crate) fn get_card(&self) -> Result> { + pub(crate) fn get_card(&self) -> Result> { self.tc.open() } @@ -92,7 +92,7 @@ pub enum TestCard { } impl TestCard { - pub fn open(&self) -> Result> { + pub fn open(&self) -> Result> { match self { Self::Pcsc(ident) => { // Attempt to shutdown SCD, if it is running. @@ -103,7 +103,7 @@ impl TestCard { // Make three attempts to open the card before failing // (this can be useful in ShareMode::Exclusive) let mut i = 1; - let card: Result, Error> = loop { + let card: Result, Error> = loop { let res = PcscBackend::open_by_ident(ident, SHARE_MODE); if i == 3 { diff --git a/card-functionality/src/tests.rs b/card-functionality/src/tests.rs index f79cc68..fa57d07 100644 --- a/card-functionality/src/tests.rs +++ b/card-functionality/src/tests.rs @@ -49,7 +49,10 @@ pub enum TestError { } /// Run after each "upload keys", if key *was* uploaded (?) -pub fn test_decrypt(card: &mut dyn CardBackend, param: &[&str]) -> Result { +pub fn test_decrypt( + card: &mut (dyn CardBackend + Send + Sync), + param: &[&str], +) -> Result { let mut pgp = OpenPgp::new(card); let mut pgpt = pgp.transaction()?; @@ -75,7 +78,10 @@ pub fn test_decrypt(card: &mut dyn CardBackend, param: &[&str]) -> Result Result { +pub fn test_sign( + card: &mut (dyn CardBackend + Send + Sync), + param: &[&str], +) -> Result { let mut pgp = OpenPgp::new(card); let mut pgpt = pgp.transaction()?; @@ -139,7 +145,7 @@ fn check_key_upload_algo_attrs() -> Result<()> { } pub fn test_print_caps( - card: &mut dyn CardBackend, + card: &mut (dyn CardBackend + Send + Sync), _param: &[&str], ) -> Result { let mut pgp = OpenPgp::new(card); @@ -163,7 +169,7 @@ pub fn test_print_caps( } pub fn test_print_algo_info( - card: &mut dyn CardBackend, + card: &mut (dyn CardBackend + Send + Sync), _param: &[&str], ) -> Result { let mut pgp = OpenPgp::new(card); @@ -185,7 +191,7 @@ pub fn test_print_algo_info( } pub fn test_upload_keys( - card: &mut dyn CardBackend, + card: &mut (dyn CardBackend + Send + Sync), param: &[&str], ) -> Result { let mut pgp = OpenPgp::new(card); @@ -215,7 +221,10 @@ pub fn test_upload_keys( } /// Generate keys for each of the three KeyTypes -pub fn test_keygen(card: &mut dyn CardBackend, param: &[&str]) -> Result { +pub fn test_keygen( + card: &mut (dyn CardBackend + Send + Sync), + param: &[&str], +) -> Result { let mut pgp = OpenPgp::new(card); let mut pgpt = pgp.transaction()?; @@ -257,7 +266,10 @@ pub fn test_keygen(card: &mut dyn CardBackend, param: &[&str]) -> Result Result { +pub fn test_get_pub( + card: &mut (dyn CardBackend + Send + Sync), + _param: &[&str], +) -> Result { let mut pgp = OpenPgp::new(card); let mut pgpt = pgp.transaction()?; @@ -296,7 +308,10 @@ pub fn test_get_pub(card: &mut dyn CardBackend, _param: &[&str]) -> Result Result { +pub fn test_reset( + card: &mut (dyn CardBackend + Send + Sync), + _param: &[&str], +) -> Result { let mut pgp = OpenPgp::new(card); let mut pgpt = pgp.transaction()?; @@ -310,7 +325,7 @@ pub fn test_reset(card: &mut dyn CardBackend, _param: &[&str]) -> Result Result { let mut pgp = OpenPgp::new(card); @@ -347,7 +362,7 @@ pub fn test_set_user_data( } pub fn test_private_data( - card: &mut dyn CardBackend, + card: &mut (dyn CardBackend + Send + Sync), _param: &[&str], ) -> Result { let mut pgp = OpenPgp::new(card); @@ -443,7 +458,7 @@ pub fn test_private_data( // } pub fn test_pw_status( - card: &mut dyn CardBackend, + card: &mut (dyn CardBackend + Send + Sync), _param: &[&str], ) -> Result { let mut pgp = OpenPgp::new(card); @@ -473,7 +488,10 @@ pub fn test_pw_status( /// Outputs: /// - verify pw3 (check) -> Status /// - verify pw1 (check) -> Status -pub fn test_verify(card: &mut dyn CardBackend, _param: &[&str]) -> Result { +pub fn test_verify( + card: &mut (dyn CardBackend + Send + Sync), + _param: &[&str], +) -> Result { let mut pgp = OpenPgp::new(card); let mut pgpt = pgp.transaction()?; @@ -540,7 +558,7 @@ pub fn test_verify(card: &mut dyn CardBackend, _param: &[&str]) -> Result Result { let mut pgp = OpenPgp::new(card); @@ -601,7 +619,7 @@ pub fn test_change_pw( } pub fn test_reset_retry_counter( - card: &mut dyn CardBackend, + card: &mut (dyn CardBackend + Send + Sync), _param: &[&str], ) -> Result { let mut pgp = OpenPgp::new(card); @@ -666,7 +684,7 @@ pub fn test_reset_retry_counter( pub fn run_test( tc: &mut TestCardData, - t: fn(&mut (dyn CardBackend), &[&str]) -> Result, + t: fn(&mut (dyn CardBackend + Send + Sync), &[&str]) -> Result, param: &[&str], ) -> Result { let mut card = tc.get_card()?; diff --git a/openpgp-card/src/openpgp.rs b/openpgp-card/src/openpgp.rs index 328129a..518575d 100644 --- a/openpgp-card/src/openpgp.rs +++ b/openpgp-card/src/openpgp.rs @@ -23,11 +23,11 @@ use crate::{ /// Users of this crate can keep a long lived OpenPgp object. All operations must be performed on /// a short lived `OpenPgpTransaction`. pub struct OpenPgp<'a> { - card: &'a mut dyn CardBackend, + card: &'a mut (dyn CardBackend + Send + Sync), } impl<'a> OpenPgp<'a> { - pub fn new(card: &'a mut dyn CardBackend) -> Self { + pub fn new(card: &'a mut (dyn CardBackend + Send + Sync)) -> Self { Self { card } } diff --git a/tools/src/bin/opgpcard/main.rs b/tools/src/bin/opgpcard/main.rs index c3e5261..5e1b051 100644 --- a/tools/src/bin/opgpcard/main.rs +++ b/tools/src/bin/opgpcard/main.rs @@ -154,7 +154,7 @@ fn set_identity(ident: &str, id: u8) -> Result<(), Box> { } fn print_status(ident: Option, verbose: bool) -> Result<()> { - let mut card: Box = if let Some(ident) = ident { + let mut card: Box = if let Some(ident) = ident { Box::new(util::open_card(&ident)?) } else { let mut cards = util::cards()?;