feat: v1.3.3, remove dependency lazy_static

This commit is contained in:
2022-05-01 13:53:06 +08:00
parent 07ff1d8187
commit 57df2177cc
4 changed files with 9 additions and 22 deletions

3
Cargo.lock generated
View File

@@ -366,7 +366,7 @@ dependencies = [
[[package]]
name = "card-cli"
version = "1.3.2"
version = "1.3.3"
dependencies = [
"authenticator",
"base64 0.13.0",
@@ -374,7 +374,6 @@ dependencies = [
"clap",
"digest 0.10.3",
"hex",
"lazy_static",
"openpgp-card",
"openpgp-card-pcsc",
"openpgp-card-sequoia",

View File

@@ -1,6 +1,6 @@
[package]
name = "card-cli"
version = "1.3.2"
version = "1.3.3"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018"
@@ -31,6 +31,6 @@ yubico_manager = "0.9"
x509 = "0.2"
x509-parser = "0.13"
ssh-agent = { version = "0.2.3", features = ["agent"] }
lazy_static = "1.4.0"
#lazy_static = "1.4.0"
#ssh-key = "0.4.0"
#ctap-hid-fido2 = "2.1.3"

View File

@@ -16,13 +16,10 @@ use ssh_agent::proto::message::{self, Message};
use ssh_agent::proto::public_key::PublicKey;
use crate::digest::{copy_sha256, copy_sha512};
use crate::sshutil::with_sign;
lazy_static! {
static ref CARD: Mutex<Option<PcscBackend>> = Mutex::new(None);
}
use crate::sshutil::{generate_ssh_string, with_sign};
struct SshAgent {
card: Mutex<PcscBackend>,
use_sign: bool,
pin: String,
public_key: PublicKey,
@@ -54,13 +51,10 @@ impl SshAgent {
n: with_sign(n.to_vec()),
});
let comment = format!("pgp-card:{}:{}", iff!(use_sign, "sign", "auth"), serial);
(public_key, comment.clone(), crate::sshutil::generate_ssh_string(e, n, &comment))
(public_key, comment.clone(), generate_ssh_string(e, n, &comment))
};
{
let mut card_mutex = CARD.lock().unwrap();
*card_mutex = Some(card);
}
Ok(Self {
card: Mutex::new(card),
use_sign,
pin,
public_key,
@@ -104,12 +98,8 @@ impl SshAgent {
};
information!("SSH request, algorithm: {}", algorithm);
let mut card_mutex = CARD.lock().unwrap();
let card_mut = match card_mutex.as_mut() {
Some(card) => card,
None => return Err(From::from("Illegal card status: none")),
};
let mut pgp = OpenPgp::new(card_mut);
let mut card_mut = self.card.lock().unwrap();
let mut pgp = OpenPgp::new(&mut *card_mut);
let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}");
let sig = if self.use_sign {
debugging!("User pin verify for pw1 sign, use sign: {}", self.use_sign);

View File

@@ -1,7 +1,5 @@
#[macro_use]
extern crate rust_util;
#[macro_use]
extern crate lazy_static;
use clap::{App, AppSettings, ArgMatches};
use rust_util::util_clap::{Command, CommandError};