feat: 1.9.7, add pinentry support
This commit is contained in:
@@ -5,11 +5,11 @@ use std::io::{ErrorKind, Read};
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use digest::Digest;
|
||||
use openpgp_card::crypto_data::Hash;
|
||||
use rust_util::util_clap::{Command, CommandError};
|
||||
use rust_util::{util_msg, XResult};
|
||||
use rust_util::util_clap::{Command, CommandError};
|
||||
use sha2::{Sha256, Sha384, Sha512};
|
||||
|
||||
use crate::pgpcardutil;
|
||||
use crate::{pgpcardutil, pinutil};
|
||||
use crate::util::base64_encode;
|
||||
|
||||
const BUFF_SIZE: usize = 512 * 1024;
|
||||
@@ -39,7 +39,7 @@ impl Command for CommandImpl {
|
||||
|
||||
fn subcommand<'a>(&self) -> App<'a, 'a> {
|
||||
SubCommand::with_name(self.name()).about("OpenPGP Card sign subcommand")
|
||||
.arg(Arg::with_name("pin").short("p").long("pin").takes_value(true).default_value("123456").help("OpenPGP card user pin"))
|
||||
.arg(Arg::with_name("pin").short("p").long("pin").takes_value(true).help("OpenPGP card user pin"))
|
||||
.arg(Arg::with_name("pass").long("pass").takes_value(true).help("[deprecated] now OpenPGP card user pin"))
|
||||
.arg(Arg::with_name("sha256").short("2").long("sha256").takes_value(true).help("Digest SHA256 HEX"))
|
||||
.arg(Arg::with_name("sha384").short("3").long("sha384").takes_value(true).help("Digest SHA384 HEX"))
|
||||
@@ -57,6 +57,8 @@ impl Command for CommandImpl {
|
||||
if json_output { util_msg::set_logger_std_out(false); }
|
||||
|
||||
let pin_opt = sub_arg_matches.value_of("pass").or_else(|| sub_arg_matches.value_of("pin"));
|
||||
let pin_opt = pinutil::get_pin(pin_opt);
|
||||
let pin_opt = pin_opt.as_deref();
|
||||
let pin = opt_value_result!(pin_opt, "User pin must be assigned");
|
||||
if pin.len() < 6 { return simple_error!("User pin length:{}, must >= 6!", pin.len()); }
|
||||
|
||||
@@ -177,7 +179,10 @@ impl Command for CommandImpl {
|
||||
}
|
||||
}
|
||||
|
||||
fn calc_file_digest<D>(file_name: &str) -> XResult<Vec<u8>> where D: Digest {
|
||||
fn calc_file_digest<D>(file_name: &str) -> XResult<Vec<u8>>
|
||||
where
|
||||
D: Digest,
|
||||
{
|
||||
let mut hasher = D::new();
|
||||
let mut buf: [u8; BUFF_SIZE] = [0u8; BUFF_SIZE];
|
||||
let mut f = File::open(file_name)?;
|
||||
|
||||
Reference in New Issue
Block a user