Skip to content

Commit

Permalink
Hashes revocation review: base64-encode instead of serde roundtrip.
Browse files Browse the repository at this point in the history
  • Loading branch information
amanjeev committed May 22, 2024
1 parent 0065677 commit 7733b97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 0 additions & 2 deletions crates/criticaltrust/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,4 @@ pub enum Error {
aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
),
#[error("failed verification while converting signature to string")]
SignatureConversionFailure,
}
9 changes: 4 additions & 5 deletions crates/criticaltrust/src/keys/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::manifests::RevocationInfo;
use crate::sha256::hash_sha256;
use crate::signatures::{PublicKeysRepository, Signable, SignedPayload};
use crate::Error;
use base64::Engine;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;

Expand Down Expand Up @@ -51,13 +52,11 @@ impl PublicKey {
return Err(Error::VerificationFailed);
}

let signature_as_string = match serde_json::to_string(signature) {
Ok(sig) => sig,
Err(_) => return Err(Error::SignatureConversionFailure),
};
let based_signature =
base64::engine::general_purpose::STANDARD.encode(signature.as_bytes());
if verified_revoked_content
.revoked_content_sha256
.contains(&signature_as_string)
.contains(&based_signature)
{
return Err(Error::VerificationFailed);
}
Expand Down

0 comments on commit 7733b97

Please sign in to comment.