From fd6adb6bc46ea858a1659b725b7f057b7d520a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Thu, 14 Sep 2023 19:40:58 +0200 Subject: [PATCH] Add common error type --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- api/Cargo.toml | 2 +- api/src/lib.rs | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b004758..a4f9675 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -640,7 +640,7 @@ dependencies = [ [[package]] name = "zipsign" -version = "0.1.0-a.0" +version = "0.1.0-a.1" dependencies = [ "clap", "ed25519-dalek", @@ -652,7 +652,7 @@ dependencies = [ [[package]] name = "zipsign-api" -version = "0.1.0-a.0" +version = "0.1.0-a.1" dependencies = [ "base64", "ed25519-dalek", diff --git a/Cargo.toml b/Cargo.toml index c3f7ad2..c73e57b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "zipsign" description = "Sign and verify `.zip` and `.tar.gz` files with an ed25519 signing key" -version = "0.1.0-a.0" +version = "0.1.0-a.1" edition = "2021" authors = ["René Kijewski "] repository = "https://github.com/Kijewski/zipsign" @@ -22,7 +22,7 @@ thiserror = "1" zip = { version = "0.6", default-features = false } [workspace.dependencies.zipsign-api] -version = "0.1.0-a.0" +version = "0.1.0-a.1" path = "api" default-features = false features = ["verify-tar", "verify-zip", "sign-tar", "sign-zip"] diff --git a/api/Cargo.toml b/api/Cargo.toml index af0d949..4c58635 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "zipsign-api" description = "Sign and verify `.zip` and `.tar.gz` files with an ed25519 signing key" -version = "0.1.0-a.0" +version = "0.1.0-a.1" edition = "2021" authors = ["René Kijewski "] repository = "https://github.com/Kijewski/zipsign" diff --git a/api/src/lib.rs b/api/src/lib.rs index 8eea711..6cc34d0 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -91,3 +91,41 @@ where let _: u64 = copy(input, &mut prehashed_message)?; Ok(prehashed_message) } + +/// A collection of all error this library can return +#[non_exhaustive] +#[derive(Debug, thiserror::Error)] +#[error(transparent)] +pub enum ZipsignError { + /// An error returned by [`gather_signature_data()`][sign::gather_signature_data] + #[cfg_attr(docsrs, doc(cfg(feature = "sign")))] + GatherSignatureData(#[from] sign::GatherSignatureDataError), + /// An error returned by [`read_signing_keys()`][sign::read_signing_keys] + #[cfg_attr(docsrs, doc(cfg(feature = "sign")))] + ReadSigningKeys(#[from] sign::ReadSigningKeysError), + /// An error returned by [`copy_and_sign_tar()`][sign::copy_and_sign_tar] + #[cfg_attr(docsrs, doc(cfg(feature = "sign-tar")))] + SignTar(#[from] sign::SignTarError), + /// An error returned by [`copy_and_sign_zip()`][sign::copy_and_sign_zip] + #[cfg_attr(docsrs, doc(cfg(feature = "sign-zip")))] + SignZip(#[from] sign::SignZipError), + + /// No matching key/signature pair found + #[cfg_attr(docsrs, doc(cfg(feature = "verify")))] + NoMatch(#[from] verify::NoMatch), + /// An error returned by [`collect_keys()`][verify::collect_keys] + #[cfg_attr(docsrs, doc(cfg(feature = "verify")))] + CollectKeys(#[from] verify::CollectKeysError), + /// An error returned by [`read_signatures()`][verify::read_signatures] + #[cfg_attr(docsrs, doc(cfg(feature = "verify")))] + ReadSignatures(#[from] verify::ReadSignaturesError), + /// An error returned by [`verify_tar()`][verify::verify_tar] + #[cfg_attr(docsrs, doc(cfg(feature = "verify-tar")))] + VerifyTar(#[from] verify::VerifyTarError), + /// An error retuned by [`verify_zip()`][verify::verify_zip] + #[cfg_attr(docsrs, doc(cfg(feature = "verify-zip")))] + VerifyZip(#[from] verify::VerifyZipError), + + /// An I/O occurred + Io(#[from] std::io::Error), +}