Skip to content

Commit

Permalink
Bump dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Wiktor Kwapisiewicz <[email protected]>
  • Loading branch information
wiktor-k committed Nov 4, 2024
1 parent a8d7825 commit bc946e7
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 81 deletions.
89 changes: 49 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ authors = ["Wiktor Kwapisiewicz <[email protected]>"]
repository = "https://github.com/wiktor-k/age-plugin-openpgp-card"

[dependencies]
age-core = "0.10.0"
age-plugin = "0.5.0"
age-core = "0.11.0"
age-plugin = "0.6.0"
base64 = "0.22.1"
bech32 = "0.11"
card-backend-pcsc = "0.5.0"
clap = { version = "4.5.20", features = ["derive"] }
openpgp-card = "0.5.0"
subtle = "2.6.1"
thiserror = "1.0.64"
thiserror = "1.0.67"
x25519-dalek = "2.0.1"
zeroize = "1.8.1"
55 changes: 17 additions & 38 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
use std::collections::HashMap;
use std::io;

use age_core::format::{FileKey, Stanza};
use age_core::secrecy::ExposeSecret;
use age_core::{
format::FILE_KEY_BYTES,
primitives::{aead_decrypt, hkdf},
};
use age_core::{
format::{FileKey, Stanza},
secrecy::Zeroize as _,
};
use age_plugin::PluginHandler;
use age_plugin::{
identity::{self, IdentityPluginV1},
recipient::{self, RecipientPluginV1},
run_state_machine, Callbacks,
};
use bech32::{Bech32, Hrp};
Expand All @@ -29,6 +27,7 @@ use openpgp_card::{
};
use subtle::ConstantTimeEq;
use x25519_dalek::PublicKey;
use zeroize::Zeroize as _;

// Use lower-case HRP to avoid https://github.com/rust-bitcoin/rust-bech32/issues/40
const IDENTITY_PREFIX: Hrp = Hrp::parse_unchecked("age-plugin-openpgp-card-");
Expand All @@ -40,35 +39,6 @@ const X25519_RECIPIENT_KEY_LABEL: &[u8] = b"age-encryption.org/v1/X25519";

pub const EPK_LEN_BYTES: usize = 32;
pub const ENCRYPTED_FILE_KEY_BYTES: usize = FILE_KEY_BYTES + 16;
struct RecipientPlugin;

impl RecipientPluginV1 for RecipientPlugin {
fn add_recipient(
&mut self,
_index: usize,
_plugin_name: &str,
_bytes: &[u8],
) -> Result<(), recipient::Error> {
todo!()
}

fn add_identity(
&mut self,
_index: usize,
_plugin_name: &str,
_bytes: &[u8],
) -> Result<(), recipient::Error> {
todo!()
}

fn wrap_file_keys(
&mut self,
_file_keys: Vec<FileKey>,
_callbacks: impl Callbacks<recipient::Error>,
) -> io::Result<Result<Vec<Vec<Stanza>>, Vec<recipient::Error>>> {
todo!()
}
}

struct CardStub {
ident: String,
Expand Down Expand Up @@ -165,7 +135,11 @@ impl IdentityPlugin {
return Err(DecryptError::NonEccCard.into());
};
tx.verify_user_pin(
callbacks.request_secret(&format!("Unlock card {}", card_stub.ident))??,
callbacks
.request_secret(&format!("Unlock card {}", card_stub.ident))??
.expose_secret()
.to_string()
.into(),
)?;

if let Ok(Some(uif)) = tx.user_interaction_flag(Decryption) {
Expand Down Expand Up @@ -202,7 +176,7 @@ impl IdentityPlugin {
// It's ours!
let file_key: [u8; FILE_KEY_BYTES] = pt[..].try_into().unwrap();
pt.zeroize();
FileKey::from(file_key)
FileKey::new(Box::new(file_key))
})
{
return Ok(Some(result));
Expand All @@ -212,6 +186,12 @@ impl IdentityPlugin {
}
}

impl PluginHandler for IdentityPlugin {
type RecipientV1 = std::convert::Infallible;

type IdentityV1 = Self;
}

impl IdentityPluginV1 for IdentityPlugin {
fn add_identity(
&mut self,
Expand Down Expand Up @@ -275,8 +255,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
if let Some(state_machine) = opts.age_plugin {
return Ok(run_state_machine(
&state_machine,
Some(|| RecipientPlugin),
Some(|| IdentityPlugin { cards: vec![] }),
IdentityPlugin { cards: vec![] },
)?);
}

Expand Down

0 comments on commit bc946e7

Please sign in to comment.