adjust to changed openpgp-card-sequoia API
This commit is contained in:
parent
db682c45db
commit
fd441dbd14
17 changed files with 29 additions and 27 deletions
|
@ -4,7 +4,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use openpgp_card_pcsc::PcscBackend;
|
use openpgp_card_pcsc::PcscBackend;
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
println!("The following OpenPGP cards are connected to your system:");
|
println!("The following OpenPGP cards are connected to your system:");
|
||||||
|
|
|
@ -16,10 +16,11 @@ use sequoia_openpgp::Cert;
|
||||||
use openpgp_card::algorithm::AlgoSimple;
|
use openpgp_card::algorithm::AlgoSimple;
|
||||||
use openpgp_card::card_do::{KeyGenerationTime, Sex};
|
use openpgp_card::card_do::{KeyGenerationTime, Sex};
|
||||||
use openpgp_card::{Error, KeyType, OpenPgp, OpenPgpTransaction, StatusBytes};
|
use openpgp_card::{Error, KeyType, OpenPgp, OpenPgpTransaction, StatusBytes};
|
||||||
use openpgp_card_sequoia::card::{Card, Transaction};
|
use openpgp_card_sequoia::sq_util;
|
||||||
use openpgp_card_sequoia::util::{
|
use openpgp_card_sequoia::util::{
|
||||||
make_cert, public_key_material_and_fp_to_key, public_key_material_to_key,
|
make_cert, public_key_material_and_fp_to_key, public_key_material_to_key,
|
||||||
};
|
};
|
||||||
|
use openpgp_card_sequoia::{state::Transaction, Card};
|
||||||
|
|
||||||
use crate::cards::TestCardData;
|
use crate::cards::TestCardData;
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
@ -72,7 +73,7 @@ pub fn test_decrypt(pgp: &mut OpenPgp, param: &[&str]) -> Result<TestOutput, Tes
|
||||||
let mut user = transaction.user_card().unwrap();
|
let mut user = transaction.user_card().unwrap();
|
||||||
let d = user.decryptor(&|| {})?;
|
let d = user.decryptor(&|| {})?;
|
||||||
|
|
||||||
let res = openpgp_card_sequoia::util::decrypt(d, msg.into_bytes(), &p)?;
|
let res = sq_util::decrypt(d, msg.into_bytes(), &p)?;
|
||||||
let plain = String::from_utf8_lossy(&res);
|
let plain = String::from_utf8_lossy(&res);
|
||||||
|
|
||||||
assert_eq!(plain, "Hello world!\n");
|
assert_eq!(plain, "Hello world!\n");
|
||||||
|
@ -96,7 +97,7 @@ pub fn test_sign(pgp: &mut OpenPgp, param: &[&str]) -> Result<TestOutput, TestEr
|
||||||
let s = sign.signer(&|| {})?;
|
let s = sign.signer(&|| {})?;
|
||||||
|
|
||||||
let msg = "Hello world, I am signed.";
|
let msg = "Hello world, I am signed.";
|
||||||
let sig = openpgp_card_sequoia::util::sign(s, &mut msg.as_bytes())?;
|
let sig = sq_util::sign(s, &mut msg.as_bytes())?;
|
||||||
|
|
||||||
// validate sig
|
// validate sig
|
||||||
assert!(util::verify_sig(&cert, msg.as_bytes(), sig.as_bytes())?);
|
assert!(util::verify_sig(&cert, msg.as_bytes(), sig.as_bytes())?);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||||
|
|
||||||
use openpgp_card_pcsc::PcscBackend;
|
use openpgp_card_pcsc::PcscBackend;
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
|
|
||||||
use openpgp::parse::{stream::DecryptorBuilder, Parse};
|
use openpgp::parse::{stream::DecryptorBuilder, Parse};
|
||||||
use openpgp::policy::StandardPolicy;
|
use openpgp::policy::StandardPolicy;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||||
|
|
||||||
use openpgp_card_pcsc::PcscBackend;
|
use openpgp_card_pcsc::PcscBackend;
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
|
|
||||||
use openpgp::serialize::stream::{Armorer, Message, Signer};
|
use openpgp::serialize::stream::{Armorer, Message, Signer};
|
||||||
use sequoia_openpgp as openpgp;
|
use sequoia_openpgp as openpgp;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use clap::{Parser, ValueEnum};
|
use clap::{Parser, ValueEnum};
|
||||||
use openpgp_card_sequoia::card::{Admin, Open, Transaction};
|
use openpgp_card_sequoia::state::{Admin, Open, Transaction};
|
||||||
use openpgp_card_sequoia::util::public_key_material_to_key;
|
use openpgp_card_sequoia::util::public_key_material_to_key;
|
||||||
use sequoia_openpgp::types::{HashAlgorithm, SymmetricAlgorithm};
|
use sequoia_openpgp::types::{HashAlgorithm, SymmetricAlgorithm};
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ use sequoia_openpgp::serialize::SerializeInto;
|
||||||
use sequoia_openpgp::Cert;
|
use sequoia_openpgp::Cert;
|
||||||
|
|
||||||
use openpgp_card_sequoia::types::AlgoSimple;
|
use openpgp_card_sequoia::types::AlgoSimple;
|
||||||
use openpgp_card_sequoia::{card::Card, types::KeyType};
|
use openpgp_card_sequoia::{types::KeyType, Card};
|
||||||
|
|
||||||
use crate::versioned_output::{OutputBuilder, OutputFormat, OutputVersion};
|
use crate::versioned_output::{OutputBuilder, OutputFormat, OutputVersion};
|
||||||
use crate::{output, util, ENTER_ADMIN_PIN, ENTER_USER_PIN};
|
use crate::{output, util, ENTER_ADMIN_PIN, ENTER_USER_PIN};
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{Parser, ValueEnum};
|
use clap::{Parser, ValueEnum};
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
|
|
||||||
use openpgp_card_sequoia::types::KeyType;
|
use openpgp_card_sequoia::types::KeyType;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use clap::Parser;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
use sequoia_openpgp::{
|
use sequoia_openpgp::{
|
||||||
parse::{stream::DecryptorBuilder, Parse},
|
parse::{stream::DecryptorBuilder, Parse},
|
||||||
policy::StandardPolicy,
|
policy::StandardPolicy,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
|
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
|
|
||||||
use crate::output;
|
use crate::output;
|
||||||
use crate::pick_card_for_reading;
|
use crate::pick_card_for_reading;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::path::PathBuf;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use openpgp_card_sequoia::card::{Card, Open, Transaction};
|
use openpgp_card_sequoia::{state::Open, state::Transaction, Card};
|
||||||
|
|
||||||
use crate::util;
|
use crate::util;
|
||||||
use crate::util::{load_pin, print_gnuk_note};
|
use crate::util::{load_pin, print_gnuk_note};
|
||||||
|
|
|
@ -8,7 +8,7 @@ use clap::Parser;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
use sequoia_openpgp::serialize::SerializeInto;
|
use sequoia_openpgp::serialize::SerializeInto;
|
||||||
|
|
||||||
use openpgp_card_sequoia::types::KeyType;
|
use openpgp_card_sequoia::types::KeyType;
|
||||||
|
@ -58,7 +58,7 @@ pub fn print_pubkey(
|
||||||
|
|
||||||
let user_pin = util::get_pin(&mut card, command.user_pin, crate::ENTER_USER_PIN)?;
|
let user_pin = util::get_pin(&mut card, command.user_pin, crate::ENTER_USER_PIN)?;
|
||||||
|
|
||||||
let pkm = card.public_key(KeyType::Signing)?;
|
let pkm = card.public_key_material(KeyType::Signing)?;
|
||||||
let times = card.key_generation_times()?;
|
let times = card.key_generation_times()?;
|
||||||
let fps = card.fingerprints()?;
|
let fps = card.fingerprints()?;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ pub fn print_pubkey(
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut key_dec = None;
|
let mut key_dec = None;
|
||||||
if let Ok(pkm) = card.public_key(KeyType::Decryption) {
|
if let Ok(pkm) = card.public_key_material(KeyType::Decryption) {
|
||||||
if let Some(ts) = times.decryption() {
|
if let Some(ts) = times.decryption() {
|
||||||
key_dec = Some(public_key_material_and_fp_to_key(
|
key_dec = Some(public_key_material_and_fp_to_key(
|
||||||
&pkm,
|
&pkm,
|
||||||
|
@ -82,7 +82,7 @@ pub fn print_pubkey(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut key_aut = None;
|
let mut key_aut = None;
|
||||||
if let Ok(pkm) = card.public_key(KeyType::Authentication) {
|
if let Ok(pkm) = card.public_key_material(KeyType::Authentication) {
|
||||||
if let Some(ts) = times.authentication() {
|
if let Some(ts) = times.authentication() {
|
||||||
key_aut = Some(public_key_material_and_fp_to_key(
|
key_aut = Some(public_key_material_and_fp_to_key(
|
||||||
&pkm,
|
&pkm,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{Parser, ValueEnum};
|
use clap::{Parser, ValueEnum};
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
|
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use clap::Parser;
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
use sequoia_openpgp::serialize::stream::{Armorer, Message, Signer};
|
use sequoia_openpgp::serialize::stream::{Armorer, Message, Signer};
|
||||||
|
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
|
|
||||||
use openpgp_card_sequoia::types::KeyType;
|
use openpgp_card_sequoia::types::KeyType;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ pub fn print_ssh(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show authentication subkey as openssh public key string
|
// Show authentication subkey as openssh public key string
|
||||||
if let Ok(pkm) = card.public_key(KeyType::Authentication) {
|
if let Ok(pkm) = card.public_key_material(KeyType::Authentication) {
|
||||||
if let Ok(ssh) = util::get_ssh_pubkey_string(&pkm, ident) {
|
if let Ok(ssh) = util::get_ssh_pubkey_string(&pkm, ident) {
|
||||||
output.ssh_public_key(ssh);
|
output.ssh_public_key(ssh);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use openpgp_card_sequoia::card::{Card, Open};
|
use openpgp_card_sequoia::{state::Open, Card};
|
||||||
|
|
||||||
use openpgp_card_sequoia::types::KeyType;
|
use openpgp_card_sequoia::types::KeyType;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ pub fn print_status(
|
||||||
}
|
}
|
||||||
|
|
||||||
if command.pkm {
|
if command.pkm {
|
||||||
if let Ok(pkm) = card.public_key(KeyType::Signing) {
|
if let Ok(pkm) = card.public_key_material(KeyType::Signing) {
|
||||||
signature_key.public_key_material(pkm.to_string());
|
signature_key.public_key_material(pkm.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ pub fn print_status(
|
||||||
decryption_key.status(format!("{}", ks));
|
decryption_key.status(format!("{}", ks));
|
||||||
}
|
}
|
||||||
if command.pkm {
|
if command.pkm {
|
||||||
if let Ok(pkm) = card.public_key(KeyType::Decryption) {
|
if let Ok(pkm) = card.public_key_material(KeyType::Decryption) {
|
||||||
decryption_key.public_key_material(pkm.to_string());
|
decryption_key.public_key_material(pkm.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ pub fn print_status(
|
||||||
authentication_key.status(format!("{}", ks));
|
authentication_key.status(format!("{}", ks));
|
||||||
}
|
}
|
||||||
if command.pkm {
|
if command.pkm {
|
||||||
if let Ok(pkm) = card.public_key(KeyType::Authentication) {
|
if let Ok(pkm) = card.public_key_material(KeyType::Authentication) {
|
||||||
authentication_key.public_key_material(pkm.to_string());
|
authentication_key.public_key_material(pkm.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ use clap::Parser;
|
||||||
|
|
||||||
use sequoia_openpgp::Cert;
|
use sequoia_openpgp::Cert;
|
||||||
|
|
||||||
use openpgp_card_sequoia::card::{Card, Open, Transaction};
|
|
||||||
use openpgp_card_sequoia::types::CardBackend;
|
use openpgp_card_sequoia::types::CardBackend;
|
||||||
use openpgp_card_sequoia::util::make_cert;
|
use openpgp_card_sequoia::util::make_cert;
|
||||||
use openpgp_card_sequoia::PublicKey;
|
use openpgp_card_sequoia::PublicKey;
|
||||||
|
use openpgp_card_sequoia::{state::Open, state::Transaction, Card};
|
||||||
|
|
||||||
mod cli;
|
mod cli;
|
||||||
mod commands;
|
mod commands;
|
||||||
|
|
|
@ -5,10 +5,11 @@ use anyhow::{anyhow, Context, Result};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use openpgp_card_pcsc::PcscBackend;
|
use openpgp_card_pcsc::PcscBackend;
|
||||||
use openpgp_card_sequoia::card::{Admin, Card, Sign, Transaction, User};
|
use openpgp_card_sequoia::state::{Admin, Sign, Transaction, User};
|
||||||
use openpgp_card_sequoia::types::{
|
use openpgp_card_sequoia::types::{
|
||||||
Algo, CardBackend, Curve, EccType, Error, PublicKeyMaterial, StatusBytes,
|
Algo, CardBackend, Curve, EccType, Error, PublicKeyMaterial, StatusBytes,
|
||||||
};
|
};
|
||||||
|
use openpgp_card_sequoia::Card;
|
||||||
|
|
||||||
pub(crate) fn cards() -> Result<Vec<Box<dyn CardBackend + Send + Sync>>, Error> {
|
pub(crate) fn cards() -> Result<Vec<Box<dyn CardBackend + Send + Sync>>, Error> {
|
||||||
PcscBackend::cards(None).map(|cards| cards.into_iter().map(|c| c.into()).collect())
|
PcscBackend::cards(None).map(|cards| cards.into_iter().map(|c| c.into()).collect())
|
||||||
|
|
Loading…
Reference in a new issue