Skip to content

Commit

Permalink
chore(naming): rename LanzabooteSigner into Signer
Browse files Browse the repository at this point in the history
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
  • Loading branch information
RaitoBezarius committed Aug 28, 2024
1 parent d3185d6 commit a2ecf9d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions rust/tool/shared/src/signature/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use std::process::Command;
use anyhow::{Context, Result};
use tempfile::tempdir;

use super::LanzabooteSigner;

use super::Signer;

/// A local keypair is a signer that reuses private key material
/// on the disk.
Expand All @@ -36,7 +35,7 @@ impl LocalKeyPair {
}
}

impl LanzabooteSigner for LocalKeyPair {
impl Signer for LocalKeyPair {
fn get_public_key(&self) -> Result<Vec<u8>> {
Ok(std::fs::read(&self.public_key)?)
}
Expand Down
2 changes: 1 addition & 1 deletion rust/tool/shared/src/signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::path::Path;

use crate::pe::StubParameters;

pub trait LanzabooteSigner {
/// This trait abstracts the concept of a signer.
///
/// On a high-level, the signer only needs to know how to:
Expand All @@ -22,6 +21,7 @@ pub trait LanzabooteSigner {
/// To implement a new signer, provide a minimal implementation of this trait
/// and pass this implementation to any front-facing tool of Lanzaboote, e.g. `lzbt-systemd`
/// as all tools does not have to support a new signature scheme.
pub trait Signer {
/// Tries to sign a Nix store path at this location.
/// The implementation can fail if the provided path is not a Nix store path,
/// or, is not a trusted Nix store path, or is not a PE binary.
Expand Down
10 changes: 5 additions & 5 deletions rust/tool/systemd/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ use lanzaboote_tool::gc::Roots;
use lanzaboote_tool::generation::{Generation, GenerationLink};
use lanzaboote_tool::os_release::OsRelease;
use lanzaboote_tool::pe::{self, append_initrd_secrets, lanzaboote_image};
use lanzaboote_tool::signature::LanzabooteSigner;
use lanzaboote_tool::signature::Signer;
use lanzaboote_tool::utils::{file_hash, SecureTempDirExt};

pub struct Installer<S: LanzabooteSigner> {
pub struct Installer<S: Signer> {
broken_gens: BTreeSet<u64>,
gc_roots: Roots,
lanzaboote_stub: PathBuf,
Expand All @@ -38,7 +38,7 @@ pub struct Installer<S: LanzabooteSigner> {
}

#[allow(clippy::too_many_arguments)]
impl<S: LanzabooteSigner> Installer<S> {
impl<S: Signer> Installer<S> {
pub fn new(
lanzaboote_stub: PathBuf,
arch: Architecture,
Expand Down Expand Up @@ -373,7 +373,7 @@ fn resolve_efi_path(esp: &Path, efi_path: &[u8]) -> Result<PathBuf> {
/// Compute the file name to be used for the stub of a certain generation, signed with the given key.
///
/// The generated name is input-addressed by the toplevel corresponding to the generation and the public part of the signing key.
fn stub_name<S: LanzabooteSigner>(generation: &Generation, signer: &S) -> Result<PathBuf> {
fn stub_name<S: Signer>(generation: &Generation, signer: &S) -> Result<PathBuf> {
let bootspec = &generation.spec.bootspec.bootspec;
let public_key = signer.get_public_key()?;
let stub_inputs = [
Expand Down Expand Up @@ -407,7 +407,7 @@ fn stub_name<S: LanzabooteSigner>(generation: &Generation, signer: &S) -> Result
/// This is implemented as an atomic write. The file is first written to the destination with a
/// `.tmp` suffix and then renamed to its final name. This is atomic, because a rename is an atomic
/// operation on POSIX platforms.
fn install_signed(signer: &impl LanzabooteSigner, from: &Path, to: &Path) -> Result<()> {
fn install_signed(signer: &impl Signer, from: &Path, to: &Path) -> Result<()> {
log::debug!("Signing and installing {to:?}...");
let to_tmp = to.with_extension(".tmp");
ensure_parent_dir(&to_tmp);
Expand Down

0 comments on commit a2ecf9d

Please sign in to comment.