Skip to content

Commit

Permalink
Update src/cose/sign1.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob <[email protected]>
  • Loading branch information
radumarias and cobward authored Aug 5, 2024
1 parent 83280a7 commit bcde4d9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/cose/sign1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,12 @@ impl PreparedCoseSign1 {

// Check if the payload is present and if it is attached or detached.
// Needs to be exclusively attached or detached.
let payload = match (cose_sign1.payload.as_ref(), detached_payload) {
let payload = match (cose_sign1.payload.as_ref(), detached_payload.as_ref()) {
(Some(_), Some(_)) => return Err(Error::DoublePayload),
(None, None) => return Err(Error::NoPayload),
(Some(payload), None) => Some(payload.clone()),
(None, Some(payload)) => Some(payload),
(Some(payload), None) => payload,
(None, Some(payload)) => payload,
};
let payload = payload
// If payload is None, use cbor null as payload.
.unwrap_or_else(|| vec![246u8]);
// Create the signature payload ot be used later on signing.
let signature_payload = sig_structure_data(
SignatureContext::CoseSign1,
Expand Down

0 comments on commit bcde4d9

Please sign in to comment.