Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: remove inconsistent use of outcome enums, add another error v… #122

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ pub enum RPMError {
key_ref: String,
},

#[error("digests from content did not match those in the header")]
DigestMismatchError,

#[error("unable to find key with key-ref: {key_ref}")]
KeyNotFoundError { key_ref: String },

Expand Down
19 changes: 5 additions & 14 deletions src/rpm/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ use crate::sequential_cursor::SeqCursor;
#[cfg(feature = "signature-meta")]
use crate::signature;

pub enum SignatureVerificationOutcome {
Pass,
Failure,
}

pub enum DigestVerificationOutcome {
Match,
Mismatch,
}

/// Combined digest of signature header tags `RPMSIGTAG_MD5` and `RPMSIGTAG_SHA1`
///
/// Succinct to cover to "verify" the content of the rpm file. Quotes because
Expand Down Expand Up @@ -191,7 +181,7 @@ impl RPMPackage {
///
///
#[cfg(feature = "signature-meta")]
pub fn verify_signature<V>(&self, verifier: V) -> Result<SignatureVerificationOutcome, RPMError>
pub fn verify_signature<V>(&self, verifier: V) -> Result<(), RPMError>
where
V: signature::Verifying<signature::algorithm::RSA, Signature = Vec<u8>>,
{
Expand Down Expand Up @@ -222,7 +212,7 @@ impl RPMPackage {

verifier.verify(header_and_content_cursor, signature_header_and_content)?;

Ok(SignatureVerificationOutcome::Pass)
Ok(())
}

pub fn verify_digest(&self) -> Result<DigestVerificationOutcome, RPMError> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove it from this signature too

Expand All @@ -236,10 +226,11 @@ impl RPMPackage {
)?;

let package_contained = self.metadata.get_digests()?;

if recreated_from_content == package_contained {
Ok(DigestVerificationOutcome::Match)
Ok(())
} else {
Ok(DigestVerificationOutcome::Mismatch)
Err(RPMError::DigestMismatchError)
}
}
}
Expand Down