Move the sq key subkey password implementation to its own module.

This commit is contained in:
Neal H. Walfield 2024-11-05 15:19:11 +01:00
parent 70f7a6f402
commit 4cfea470b8
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3
2 changed files with 19 additions and 16 deletions

View File

@ -17,11 +17,9 @@ use openpgp::Result;
use crate::Sq;
use crate::cli::key::subkey::Command;
use crate::cli::key::subkey::expire::Command as ExpireCommand;
use crate::cli::key::subkey::password::Command as PasswordCommand;
use crate::cli::key::subkey::revoke::Command as RevokeCommand;
use crate::commands::key::bind;
use crate::common::key::expire;
use crate::common::key::password;
use crate::common::NULL_POLICY;
use crate::common::RevocationOutput;
use crate::common::get_secret_signer;
@ -30,13 +28,14 @@ use crate::parse_notations;
mod add;
mod delete;
mod export;
mod password;
pub fn dispatch(sq: Sq, command: Command) -> Result<()> {
match command {
Command::Add(c) => add::dispatch(sq, c)?,
Command::Export(c) => export::dispatch(sq, c)?,
Command::Delete(c) => delete::dispatch(sq, c)?,
Command::Password(c) => subkey_password(sq, c)?,
Command::Password(c) => password::dispatch(sq, c)?,
Command::Expire(c) => subkey_expire(sq, c)?,
Command::Revoke(c) => subkey_revoke(sq, c)?,
Command::Bind(c) => bind::bind(sq, c)?,
@ -45,19 +44,6 @@ pub fn dispatch(sq: Sq, command: Command) -> Result<()> {
Ok(())
}
fn subkey_password(sq: Sq, command: PasswordCommand)
-> Result<()>
{
let handle =
sq.resolve_cert(&command.cert, sequoia_wot::FULLY_TRUSTED)?.1;
assert!(! command.key.is_empty());
password(sq, handle, command.key,
command.clear_password, command.new_password_file.as_deref(),
command.output, command.binary)
}
fn subkey_expire(sq: Sq, command: ExpireCommand)
-> Result<()>
{

View File

@ -0,0 +1,17 @@
use crate::Result;
use crate::Sq;
use crate::common::key::password;
pub fn dispatch(sq: Sq, command: crate::cli::key::subkey::password::Command)
-> Result<()>
{
let handle =
sq.resolve_cert(&command.cert, sequoia_wot::FULLY_TRUSTED)?.1;
assert!(! command.key.is_empty());
password(sq, handle, command.key,
command.clear_password, command.new_password_file.as_deref(),
command.output, command.binary)
}