From d25cd72b34d4a50e5b03ec382afcd9730281da7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Thu, 30 Mar 2023 16:40:32 +0200 Subject: [PATCH] Rename virtual to vpicc --- Cargo.toml | 6 +++--- Makefile | 4 ++-- examples/{virtual.rs => vpicc.rs} | 6 +++--- src/lib.rs | 2 +- src/vpicc.rs | 10 +++++----- tests/card/mod.rs | 8 ++++---- tests/command_response.rs | 2 +- tests/opensc.rs | 2 +- tests/pivy.rs | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) rename examples/{virtual.rs => vpicc.rs} (82%) diff --git a/Cargo.toml b/Cargo.toml index 237cfb3..902a8d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,8 @@ repository = "https://github.com/solokeys/piv-authenticator" documentation = "https://docs.rs/piv-authenticator" [[example]] -name = "virtual" -required-features = ["virtual"] +name = "vpicc" +required-features = ["vpicc"] [[example]] @@ -60,7 +60,7 @@ rand = "0.8.5" default = [] strict-pin = [] std = [] -virtual = ["std", "vpicc", "trussed-rsa-alloc/virt"] +vpicc = ["std", "dep:vpicc", "trussed-rsa-alloc/virt"] pivy-tests = [] opensc-tests = [] diff --git a/Makefile b/Makefile index be2d68e..f0fd8e8 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ .NOTPARALLEL: export RUST_LOG ?= info,cargo_tarpaulin=off -TEST_FEATURES ?=virtual,pivy-tests,opensc-tests +TEST_FEATURES ?=vpicc,pivy-tests,opensc-tests .PHONY: build-cortex-m4 build-cortex-m4: @@ -32,7 +32,7 @@ tarpaulin: .PHONY: example example: - cargo run --example virtual --features virtual + cargo run --example vpicc --features vpicc .PHONY: ci ci: lint tarpaulin diff --git a/examples/virtual.rs b/examples/vpicc.rs similarity index 82% rename from examples/virtual.rs rename to examples/vpicc.rs index 8404d1c..e4002d8 100644 --- a/examples/virtual.rs +++ b/examples/vpicc.rs @@ -18,10 +18,10 @@ fn main() { trussed_rsa_alloc::virt::with_ram_client("piv-authenticator", |client| { let card = Authenticator::new(client, Options::default()); - let mut virtual_card = piv_authenticator::vpicc::VirtualCard::new(card); + let mut vpicc_card = piv_authenticator::vpicc::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 d5bb245..08a7c58 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ mod tlv; pub use piv_types::{AsymmetricAlgorithms, Pin, Puk}; -#[cfg(feature = "virtual")] +#[cfg(feature = "vpicc")] pub mod vpicc; use core::convert::TryInto; diff --git a/src/vpicc.rs b/src/vpicc.rs index e7b82bb..f2a2b9c 100644 --- a/src/vpicc.rs +++ b/src/vpicc.rs @@ -12,17 +12,17 @@ use crate::Authenticator; const REQUEST_LEN: usize = 7609; const RESPONSE_LEN: usize = 7609; -/// Virtual PIV smartcard implementation. +/// Vpicc PIV smartcard implementation. /// -/// This struct provides a virtual PIV smart card implementation that can be used with +/// This struct provides a vpicc PIV smart card implementation that can be used with /// `vpicc-rs` and [`vsmartcard`](https://frankmorgner.github.io/vsmartcard/) to emulate the card. -pub struct VirtualCard { +pub struct VpiccCard { request_buffer: RequestBuffer, response_buffer: ResponseBuffer, card: Authenticator>, } -impl VirtualCard { +impl VpiccCard { /// Creates a new virtual smart card from the given card. pub fn new(card: Authenticator>) -> Self { Self { @@ -47,7 +47,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/card/mod.rs b/tests/card/mod.rs index bdfd344..6c22b8b 100644 --- a/tests/card/mod.rs +++ b/tests/card/mod.rs @@ -1,7 +1,7 @@ // Copyright (C) 2022 Nitrokey GmbH // SPDX-License-Identifier: LGPL-3.0-only -use piv_authenticator::{vpicc::VirtualCard, Authenticator, Options}; +use piv_authenticator::{vpicc::VpiccCard, Authenticator, Options}; use std::{sync::mpsc, thread::sleep, time::Duration}; use stoppable_thread::spawn; @@ -19,10 +19,10 @@ pub fn with_vsc R, R>(f: F) -> R { let handle = spawn(move |stopped| { trussed_rsa_alloc::virt::with_ram_client("opcard", |client| { let card = Authenticator::new(client, Options::default()); - let mut virtual_card = VirtualCard::new(card); + let mut vpicc_card = 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"); } @@ -41,6 +41,6 @@ pub fn with_vsc R, R>(f: F) -> R { .stop() .join() .expect("failed to join vpicc thread") - .expect("failed to run virtual smartcard"); + .expect("failed to run vpicc smartcard"); result } diff --git a/tests/command_response.rs b/tests/command_response.rs index 9c3334d..1cf95f1 100644 --- a/tests/command_response.rs +++ b/tests/command_response.rs @@ -1,6 +1,6 @@ // Copyright (C) 2022 Nicolas Stalder AND Nitrokey GmbH // SPDX-License-Identifier: LGPL-3.0-only -#![cfg(feature = "virtual")] +#![cfg(feature = "vpicc")] mod setup; diff --git a/tests/opensc.rs b/tests/opensc.rs index 86dd036..b065a00 100644 --- a/tests/opensc.rs +++ b/tests/opensc.rs @@ -1,7 +1,7 @@ // Copyright (C) 2022 Nitrokey GmbH // SPDX-License-Identifier: LGPL-3.0-only -#![cfg(all(feature = "virtual", feature = "opensc-tests"))] +#![cfg(all(feature = "vpicc", feature = "opensc-tests"))] mod card; diff --git a/tests/pivy.rs b/tests/pivy.rs index 5544eb0..ab166c6 100644 --- a/tests/pivy.rs +++ b/tests/pivy.rs @@ -1,7 +1,7 @@ // Copyright (C) 2022 Nitrokey GmbH // SPDX-License-Identifier: LGPL-3.0-only -#![cfg(all(feature = "virtual", feature = "pivy-tests"))] +#![cfg(all(feature = "vpicc", feature = "pivy-tests"))] mod card;