feat: v1.3.3, remove dependency lazy_static
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -366,7 +366,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "card-cli"
|
name = "card-cli"
|
||||||
version = "1.3.2"
|
version = "1.3.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"authenticator",
|
"authenticator",
|
||||||
"base64 0.13.0",
|
"base64 0.13.0",
|
||||||
@@ -374,7 +374,6 @@ dependencies = [
|
|||||||
"clap",
|
"clap",
|
||||||
"digest 0.10.3",
|
"digest 0.10.3",
|
||||||
"hex",
|
"hex",
|
||||||
"lazy_static",
|
|
||||||
"openpgp-card",
|
"openpgp-card",
|
||||||
"openpgp-card-pcsc",
|
"openpgp-card-pcsc",
|
||||||
"openpgp-card-sequoia",
|
"openpgp-card-sequoia",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "card-cli"
|
name = "card-cli"
|
||||||
version = "1.3.2"
|
version = "1.3.3"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
@@ -31,6 +31,6 @@ yubico_manager = "0.9"
|
|||||||
x509 = "0.2"
|
x509 = "0.2"
|
||||||
x509-parser = "0.13"
|
x509-parser = "0.13"
|
||||||
ssh-agent = { version = "0.2.3", features = ["agent"] }
|
ssh-agent = { version = "0.2.3", features = ["agent"] }
|
||||||
lazy_static = "1.4.0"
|
#lazy_static = "1.4.0"
|
||||||
#ssh-key = "0.4.0"
|
#ssh-key = "0.4.0"
|
||||||
#ctap-hid-fido2 = "2.1.3"
|
#ctap-hid-fido2 = "2.1.3"
|
||||||
|
|||||||
@@ -16,13 +16,10 @@ use ssh_agent::proto::message::{self, Message};
|
|||||||
use ssh_agent::proto::public_key::PublicKey;
|
use ssh_agent::proto::public_key::PublicKey;
|
||||||
|
|
||||||
use crate::digest::{copy_sha256, copy_sha512};
|
use crate::digest::{copy_sha256, copy_sha512};
|
||||||
use crate::sshutil::with_sign;
|
use crate::sshutil::{generate_ssh_string, with_sign};
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
static ref CARD: Mutex<Option<PcscBackend>> = Mutex::new(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SshAgent {
|
struct SshAgent {
|
||||||
|
card: Mutex<PcscBackend>,
|
||||||
use_sign: bool,
|
use_sign: bool,
|
||||||
pin: String,
|
pin: String,
|
||||||
public_key: PublicKey,
|
public_key: PublicKey,
|
||||||
@@ -54,13 +51,10 @@ impl SshAgent {
|
|||||||
n: with_sign(n.to_vec()),
|
n: with_sign(n.to_vec()),
|
||||||
});
|
});
|
||||||
let comment = format!("pgp-card:{}:{}", iff!(use_sign, "sign", "auth"), serial);
|
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 {
|
Ok(Self {
|
||||||
|
card: Mutex::new(card),
|
||||||
use_sign,
|
use_sign,
|
||||||
pin,
|
pin,
|
||||||
public_key,
|
public_key,
|
||||||
@@ -104,12 +98,8 @@ impl SshAgent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
information!("SSH request, algorithm: {}", algorithm);
|
information!("SSH request, algorithm: {}", algorithm);
|
||||||
let mut card_mutex = CARD.lock().unwrap();
|
let mut card_mut = self.card.lock().unwrap();
|
||||||
let card_mut = match card_mutex.as_mut() {
|
let mut pgp = OpenPgp::new(&mut *card_mut);
|
||||||
Some(card) => card,
|
|
||||||
None => return Err(From::from("Illegal card status: none")),
|
|
||||||
};
|
|
||||||
let mut pgp = OpenPgp::new(card_mut);
|
|
||||||
let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}");
|
let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}");
|
||||||
let sig = if self.use_sign {
|
let sig = if self.use_sign {
|
||||||
debugging!("User pin verify for pw1 sign, use sign: {}", self.use_sign);
|
debugging!("User pin verify for pw1 sign, use sign: {}", self.use_sign);
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rust_util;
|
extern crate rust_util;
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
|
|
||||||
use clap::{App, AppSettings, ArgMatches};
|
use clap::{App, AppSettings, ArgMatches};
|
||||||
use rust_util::util_clap::{Command, CommandError};
|
use rust_util::util_clap::{Command, CommandError};
|
||||||
|
|||||||
Reference in New Issue
Block a user