diff --git a/Cargo.toml b/Cargo.toml index 5ece3c2d..83bdd545 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,8 +16,8 @@ members = [ ] [[example]] -name = "virtual" -required-features = ["virtual"] +name = "vpicc" +required-features = ["vpicc"] [dependencies] heapless = "0.7" @@ -56,7 +56,7 @@ hex = { version = "0.4", features = ["serde"] } [features] default = [] std = [] -virtual = ["std", "vpicc", "virt"] +vpicc = ["std", "dep:vpicc", "virt"] virt = ["std", "trussed/virt"] rsa = ["trussed-rsa-alloc"] diff --git a/Makefile b/Makefile index c7da9562..ec613576 100644 --- a/Makefile +++ b/Makefile @@ -33,8 +33,8 @@ fix: .PHONY: test test: - cargo test --features virtual,rsa2048,rsa4096-gen gpg_crypto,sequoia_gen_key - cargo test --features virtual,rsa2048,rsa4096 + cargo test --features vpicc,rsa2048,rsa4096-gen gpg_crypto,sequoia_gen_key + cargo test --features vpicc,rsa2048,rsa4096 .PHONY: test @@ -63,7 +63,7 @@ fuzz-cov: .PHONY: tarpaulin tarpaulin: - cargo tarpaulin --features virtual,rsa4096-gen -o Html -o Xml + cargo tarpaulin --features vpicc,rsa4096-gen -o Html -o Xml .PHONY: ci ci: lint tarpaulin diff --git a/examples/virtual.rs b/examples/vpicc.rs similarity index 90% rename from examples/virtual.rs rename to examples/vpicc.rs index 14f21c37..ef8c6ba1 100644 --- a/examples/virtual.rs +++ b/examples/vpicc.rs @@ -30,10 +30,10 @@ fn main() { opcard::virt::with_ram_client("opcard", |client| { let card = opcard::Card::new(client, opcard::Options::default()); - let mut virtual_card = opcard::VirtualCard::new(card); + let mut vpicc_card = opcard::VpiccCard::new(card); let vpicc = vpicc::connect().expect("failed to connect to vpicc"); vpicc - .run(&mut virtual_card) - .expect("failed to run virtual smartcard"); + .run(&mut vpicc_card) + .expect("failed to run vpicc smartcard"); }); } diff --git a/src/lib.rs b/src/lib.rs index 9a82d058..b27f6c10 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,7 +24,7 @@ //! //! - If the `apdu-dispatch` feature is enabled, [`Card`] implements the `apdu_dispatch::App` //! trait and can be used with `apdu_dispatch`. -//! - If the `virtual` feature is enabled, [`VirtualCard`] can be used to emulate a smart card +//! - If the `vpicc` feature is enabled, [`VpiccCard`] can be used to emulate a smart card //! using [`vsmartcard`](https://frankmorgner.github.io/vsmartcard/) and `vpicc-rs`. #![cfg_attr(not(any(feature = "std", test)), no_std)] @@ -56,13 +56,13 @@ mod state; mod tlv; mod types; mod utils; -#[cfg(feature = "virtual")] +#[cfg(feature = "vpicc")] mod vpicc; #[cfg(feature = "virt")] pub mod virt; -#[cfg(feature = "virtual")] -pub use self::vpicc::VirtualCard; +#[cfg(feature = "vpicc")] +pub use self::vpicc::VpiccCard; pub use card::{Card, Options}; pub use state::{DEFAULT_ADMIN_PIN, DEFAULT_USER_PIN}; diff --git a/src/vpicc.rs b/src/vpicc.rs index c12a0384..af9d8039 100644 --- a/src/vpicc.rs +++ b/src/vpicc.rs @@ -9,18 +9,18 @@ use crate::card::Card; const REQUEST_LEN: usize = 7609; const RESPONSE_LEN: usize = 7609; -/// Virtual OpenPGP smart card implementation. +/// Vpicc OpenPGP smart card implementation. /// -/// This struct provides a virtual OpenPGP smart card implementation that can be used with +/// This struct provides a vpicc OpenPGP smart card implementation that can be used with /// `vpicc-rs` and [`vsmartcard`](https://frankmorgner.github.io/vsmartcard/) to emulate the card. #[derive(Clone, Debug)] -pub struct VirtualCard { +pub struct VpiccCard { request_buffer: RequestBuffer, response_buffer: ResponseBuffer, card: Card, } -impl VirtualCard { +impl VpiccCard { /// Creates a new virtual smart card from the given card. pub fn new(card: Card) -> Self { Self { @@ -45,7 +45,7 @@ impl VirtualCard { } } -impl vpicc::VSmartCard for VirtualCard { +impl vpicc::VSmartCard for VpiccCard { fn power_on(&mut self) {} fn power_off(&mut self) { diff --git a/tests/crypto-gpg-import.rs b/tests/crypto-gpg-import.rs index 1d54d809..7128ce1a 100644 --- a/tests/crypto-gpg-import.rs +++ b/tests/crypto-gpg-import.rs @@ -1,6 +1,6 @@ // Copyright (C) 2022 Nitrokey GmbH // SPDX-License-Identifier: LGPL-3.0-only -#![cfg(any(feature = "virtual", feature = "dangerous-test-real-card"))] +#![cfg(any(feature = "vpicc", feature = "dangerous-test-real-card"))] mod virt; @@ -10,7 +10,7 @@ use test_log::test; use virt::gnupg_test; use virt::GpgCommand::*; -#[cfg(feature = "virtual")] +#[cfg(feature = "vpicc")] #[allow(unused)] use virt::with_vsc; @@ -1205,7 +1205,7 @@ fn gpg_rsa_4096() { ); } -#[cfg(all(feature = "virtual", not(feature = "dangerous-test-real-card")))] +#[cfg(all(feature = "vpicc", not(feature = "dangerous-test-real-card")))] #[test] fn gpg_crypto() { #[cfg(feature = "rsa2048")] diff --git a/tests/crypto-gpg.rs b/tests/crypto-gpg.rs index 748a3811..d75977a8 100644 --- a/tests/crypto-gpg.rs +++ b/tests/crypto-gpg.rs @@ -1,6 +1,6 @@ // Copyright (C) 2022 Nitrokey GmbH // SPDX-License-Identifier: LGPL-3.0-only -#![cfg(any(feature = "virtual", feature = "dangerous-test-real-card"))] +#![cfg(any(feature = "vpicc", feature = "dangerous-test-real-card"))] mod virt; @@ -12,7 +12,7 @@ use test_log::test; use virt::gnupg_test; use virt::GpgCommand::*; -#[cfg(feature = "virtual")] +#[cfg(feature = "vpicc")] #[allow(unused)] use virt::with_vsc; @@ -1031,7 +1031,7 @@ fn gpg_rsa_4096() { ); } -#[cfg(all(feature = "virtual", not(feature = "dangerous-test-real-card")))] +#[cfg(all(feature = "vpicc", not(feature = "dangerous-test-real-card")))] #[test] fn gpg_crypto() { with_vsc(gpg_255); diff --git a/tests/crypto-sequoia.rs b/tests/crypto-sequoia.rs index 46df91d8..4e44664d 100644 --- a/tests/crypto-sequoia.rs +++ b/tests/crypto-sequoia.rs @@ -1,6 +1,6 @@ // Copyright (C) 2022 Nitrokey GmbH // SPDX-License-Identifier: LGPL-3.0-only -#![cfg(any(feature = "virtual", feature = "dangerous-test-real-card"))] +#![cfg(any(feature = "vpicc", feature = "dangerous-test-real-card"))] mod card; mod virt; @@ -16,7 +16,7 @@ use sequoia_openpgp::types::HashAlgorithm; use test_log::test; -#[cfg(all(feature = "virtual", not(feature = "dangerous-test-real-card")))] +#[cfg(all(feature = "vpicc", not(feature = "dangerous-test-real-card")))] const IDENT: &str = "0000:00000000"; #[cfg(feature = "dangerous-test-real-card")] const IDENT: &str = concat!( @@ -284,7 +284,7 @@ fn curve25519() { open.factory_reset().unwrap(); } -#[cfg(all(feature = "virtual", not(feature = "dangerous-test-real-card")))] +#[cfg(all(feature = "vpicc", not(feature = "dangerous-test-real-card")))] #[test] fn sequoia_gen_key() { #[cfg(feature = "rsa2048")] diff --git a/tests/gpg-status.rs b/tests/gpg-status.rs index 6f29c8ac..8dc2370e 100644 --- a/tests/gpg-status.rs +++ b/tests/gpg-status.rs @@ -1,7 +1,7 @@ // Copyright (C) 2022 Nitrokey GmbH // SPDX-License-Identifier: LGPL-3.0-only -#![cfg(feature = "virtual")] +#![cfg(feature = "vpicc")] mod virt; diff --git a/tests/virt/mod.rs b/tests/virt/mod.rs index afa072c9..ee823a84 100644 --- a/tests/virt/mod.rs +++ b/tests/virt/mod.rs @@ -1,6 +1,6 @@ // Copyright (C) 2022 Nitrokey GmbH // SPDX-License-Identifier: LGPL-3.0-only -#![cfg(any(feature = "virtual", feature = "dangerous-test-real-card"))] +#![cfg(any(feature = "vpicc", feature = "dangerous-test-real-card"))] use std::{ io::{BufRead, BufReader, Write}, @@ -9,12 +9,12 @@ use std::{ thread, }; -#[cfg(feature = "virtual")] +#[cfg(feature = "vpicc")] use std::{sync::mpsc, thread::sleep, time::Duration}; use regex::{Regex, RegexSet}; -#[cfg(feature = "virtual")] +#[cfg(feature = "vpicc")] use stoppable_thread::spawn; const STDOUT_FILTER: &[&str] = &[ @@ -36,7 +36,7 @@ const STDERR_FILTER: &[&str] = &[ r"There is NO WARRANTY, to the extent permitted by law.", ]; -#[cfg(feature = "virtual")] +#[cfg(feature = "vpicc")] #[allow(unused)] pub fn with_vsc R, R>(f: F) -> R { let mut vpicc = vpicc::connect().expect("failed to connect to vpcd"); @@ -45,10 +45,10 @@ pub fn with_vsc R, R>(f: F) -> R { let handle = spawn(move |stopped| { opcard::virt::with_ram_client("opcard", |client| { let card = opcard::Card::new(client, opcard::Options::default()); - let mut virtual_card = opcard::VirtualCard::new(card); + let mut vpicc_card = opcard::VpiccCard::new(card); let mut result = Ok(()); while !stopped.get() && result.is_ok() { - result = vpicc.poll(&mut virtual_card); + result = vpicc.poll(&mut vpicc_card); if result.is_ok() { tx.send(()).expect("failed to send message"); } @@ -167,7 +167,7 @@ pub fn gpg_status(key: KeyType, sign_count: usize) -> Vec<&'static str> { }; let fprtimes = r"fprtime:\d*:\d*:\d*:"; - #[cfg(feature = "virtual")] + #[cfg(feature = "vpicc")] let (reader, serial, vendor) = ( r"Reader:Virtual PCD \d\d \d\d:AID:D276000124010304[A-Z0-9]*:openpgp-card", r"vendor:0000:test card:",