Rename virtual to vpicc

This commit is contained in:
Sosthène Guédon
2023-03-30 16:40:32 +02:00
parent cda99c9da7
commit d25cd72b34
9 changed files with 21 additions and 21 deletions
+3 -3
View File
@@ -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 = []
+2 -2
View File
@@ -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
+3 -3
View File
@@ -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");
});
}
+1 -1
View File
@@ -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;
+5 -5
View File
@@ -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<REQUEST_LEN>,
response_buffer: ResponseBuffer<RESPONSE_LEN>,
card: Authenticator<Client<Ram>>,
}
impl VirtualCard {
impl VpiccCard {
/// Creates a new virtual smart card from the given card.
pub fn new(card: Authenticator<Client<Ram>>) -> 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) {
+4 -4
View File
@@ -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<F: FnOnce() -> 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<F: FnOnce() -> 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
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;