v1.1.0, update openpgp-card versions
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use openpgp_card::Hash;
|
||||
use openpgp_card::crypto_data::Hash;
|
||||
use openpgp_card::OpenPgp;
|
||||
use rust_util::util_clap::{Command, CommandError};
|
||||
use rust_util::XResult;
|
||||
|
||||
use crate::pgpcardutil;
|
||||
|
||||
pub struct CommandImpl;
|
||||
|
||||
impl Command for CommandImpl {
|
||||
@@ -37,13 +36,19 @@ impl Command for CommandImpl {
|
||||
if sha256.is_none() && sha384.is_none() && sha512.is_none() {
|
||||
return simple_error!("SHA256, SHA384 or SHA512 must assign at least one");
|
||||
}
|
||||
let user = opt_result!(pgpcardutil::get_card_user_sw1_81(pin), "Verify user pin failed: {}");
|
||||
|
||||
let mut card = crate::pgpcardutil::get_card()?;
|
||||
let mut pgp = OpenPgp::new(&mut card);
|
||||
let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}");
|
||||
|
||||
opt_result!(trans.verify_pw1_sign(pin.as_ref()), "User sign pin verify failed: {}");
|
||||
success!("User sign pin verify success!");
|
||||
|
||||
let mut json = BTreeMap::new();
|
||||
if let Some(sha256) = sha256 {
|
||||
let sha256_hex = opt_result!(hex::decode(sha256.trim()), "Decode sha256 failed: {}");
|
||||
let sha256_hex = copy_sha256(&sha256_hex)?;
|
||||
let sig = user.signature_for_hash(Hash::SHA256(sha256_hex))?;
|
||||
let sig = trans.signature_for_hash(Hash::SHA256(sha256_hex))?;
|
||||
success!("SHA256 signature HEX: {}", hex::encode(&sig));
|
||||
success!("SHA256 signature base64: {}", base64::encode(&sig));
|
||||
if json_output {
|
||||
@@ -56,7 +61,7 @@ impl Command for CommandImpl {
|
||||
if let Some(sha384) = sha384 {
|
||||
let sha384_hex = opt_result!(hex::decode(sha384.trim()), "Decode sha384 failed: {}");
|
||||
let sha384_hex = copy_sha384(&sha384_hex)?;
|
||||
let sig = user.signature_for_hash(Hash::SHA384(sha384_hex))?;
|
||||
let sig = trans.signature_for_hash(Hash::SHA384(sha384_hex))?;
|
||||
success!("SHA384 signature HEX: {}", hex::encode(&sig));
|
||||
success!("SHA384 signature base64: {}", base64::encode(&sig));
|
||||
if json_output {
|
||||
@@ -69,7 +74,7 @@ impl Command for CommandImpl {
|
||||
if let Some(sha512) = sha512 {
|
||||
let sha512_hex = opt_result!(hex::decode(sha512.trim()), "Decode sha512 failed: {}");
|
||||
let sha512_hex = copy_sha512(&sha512_hex)?;
|
||||
let sig = user.signature_for_hash(Hash::SHA512(sha512_hex))?;
|
||||
let sig = trans.signature_for_hash(Hash::SHA512(sha512_hex))?;
|
||||
success!("SHA512 signature HEX: {}", hex::encode(&sig));
|
||||
success!("SHA512 signature base64: {}", base64::encode(&sig));
|
||||
if json_output {
|
||||
|
||||
Reference in New Issue
Block a user