Skip to content

Commit bb0e29a

Browse files
remove cose_raw
Co-authored-by: Joaquín Rosales <[email protected]>
1 parent 8ee9a67 commit bb0e29a

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

rust/signed_doc/src/lib.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
sync::Arc,
66
};
77

8-
use coset::{CborSerializable, TaggedCborSerializable};
8+
use coset::CborSerializable;
99

1010
mod metadata;
1111
mod payload;
@@ -24,8 +24,6 @@ struct InnerCatalystSignedDocument {
2424
payload: JsonContent,
2525
/// Raw COSE Sign data
2626
cose_sign: coset::CoseSign,
27-
/// Raw COSE Sign bytes
28-
cose_bytes: Vec<u8>,
2927
/// Content Errors found when parsing the Document
3028
content_errors: Vec<String>,
3129
}
@@ -66,21 +64,20 @@ impl TryFrom<Vec<u8>> for CatalystSignedDocument {
6664

6765
fn try_from(cose_bytes: Vec<u8>) -> Result<Self, Self::Error> {
6866
// Try reading as a tagged COSE SIGN, otherwise try reading as untagged.
69-
let cose = coset::CoseSign::from_tagged_slice(&cose_bytes)
70-
.or(coset::CoseSign::from_slice(&cose_bytes))
67+
let cose_sign = coset::CoseSign::from_slice(&cose_bytes)
7168
.map_err(|e| anyhow::anyhow!("Invalid COSE Sign document: {e}"))?;
7269

7370
let mut content_errors = Vec::new();
7471

75-
let metadata = Metadata::from(&cose.protected);
72+
let metadata = Metadata::from(&cose_sign.protected);
7673

7774
if metadata.is_valid() {
7875
content_errors.extend_from_slice(metadata.content_errors());
7976
}
8077

8178
let mut payload = JsonContent::default();
8279

83-
if let Some(bytes) = &cose.payload {
80+
if let Some(bytes) = &cose_sign.payload {
8481
match JsonContent::try_from((bytes, metadata.content_encoding())) {
8582
Ok(c) => payload = c,
8683
Err(e) => {
@@ -94,8 +91,7 @@ impl TryFrom<Vec<u8>> for CatalystSignedDocument {
9491
let inner = InnerCatalystSignedDocument {
9592
metadata,
9693
payload,
97-
cose_sign: cose,
98-
cose_bytes,
94+
cose_sign,
9995
content_errors,
10096
};
10197
Ok(CatalystSignedDocument {
@@ -154,10 +150,4 @@ impl CatalystSignedDocument {
154150
pub fn doc_section(&self) -> Option<String> {
155151
self.inner.metadata.doc_section()
156152
}
157-
158-
/// Return Raw COSE SIGN bytes.
159-
#[must_use]
160-
pub fn cose_sign_bytes(&self) -> &[u8] {
161-
self.inner.cose_bytes.as_ref()
162-
}
163153
}

0 commit comments

Comments
 (0)