1
1
//! Catalyst Signed Document Metadata.
2
2
use std:: fmt:: { Display , Formatter } ;
3
3
4
- mod algorithm;
5
4
mod content_encoding;
6
5
mod content_type;
7
6
mod document_ref;
8
7
mod extra_fields;
9
8
mod section;
10
9
pub ( crate ) mod utils;
11
10
12
- pub use algorithm:: Algorithm ;
13
11
use catalyst_types:: {
14
12
problem_report:: ProblemReport ,
15
13
uuid:: { UuidV4 , UuidV7 } ,
@@ -42,8 +40,6 @@ pub struct Metadata(InnerMetadata);
42
40
/// An actual representation of all metadata fields.
43
41
#[ derive( Clone , Debug , PartialEq , serde:: Deserialize , Default ) ]
44
42
pub ( crate ) struct InnerMetadata {
45
- /// Cryptographic Algorithm
46
- alg : Option < Algorithm > ,
47
43
/// Document Type `UUIDv4`.
48
44
#[ serde( rename = "type" ) ]
49
45
doc_type : Option < UuidV4 > ,
@@ -63,14 +59,6 @@ pub(crate) struct InnerMetadata {
63
59
}
64
60
65
61
impl Metadata {
66
- /// Return Document Cryptographic Algorithm
67
- ///
68
- /// # Errors
69
- /// - Missing 'alg' field.
70
- pub fn algorithm ( & self ) -> anyhow:: Result < Algorithm > {
71
- self . 0 . alg . ok_or ( anyhow:: anyhow!( "Missing 'alg' field" ) )
72
- }
73
-
74
62
/// Return Document Type `UUIDv4`.
75
63
///
76
64
/// # Errors
@@ -121,9 +109,6 @@ impl Metadata {
121
109
122
110
/// Build `Metadata` object from the metadata fields, doing all necessary validation.
123
111
pub ( crate ) fn from_metadata_fields ( metadata : InnerMetadata , report : & ProblemReport ) -> Self {
124
- if metadata. alg . is_none ( ) {
125
- report. missing_field ( "alg" , "Missing alg field in COSE protected header" ) ;
126
- }
127
112
if metadata. doc_type . is_none ( ) {
128
113
report. missing_field ( "type" , "Missing type field in COSE protected header" ) ;
129
114
}
@@ -181,20 +166,6 @@ impl InnerMetadata {
181
166
..Self :: default ( )
182
167
} ;
183
168
184
- if let Some ( coset:: RegisteredLabelWithPrivate :: Assigned ( alg) ) = protected. header . alg {
185
- match Algorithm :: try_from ( alg) {
186
- Ok ( alg) => metadata. alg = Some ( alg) ,
187
- Err ( e) => {
188
- report. conversion_error (
189
- "COSE protected header algorithm" ,
190
- & format ! ( "{alg:?}" ) ,
191
- & format ! ( "Expected Algorithm: {e}" ) ,
192
- & format ! ( "{COSE_DECODING_CONTEXT}, Algorithm" ) ,
193
- ) ;
194
- } ,
195
- }
196
- }
197
-
198
169
if let Some ( value) = protected. header . content_type . as_ref ( ) {
199
170
match ContentType :: try_from ( value) {
200
171
Ok ( ct) => metadata. content_type = Some ( ct) ,
@@ -260,7 +231,6 @@ impl Display for Metadata {
260
231
writeln ! ( f, " type: {:?}," , self . 0 . doc_type) ?;
261
232
writeln ! ( f, " id: {:?}," , self . 0 . id) ?;
262
233
writeln ! ( f, " ver: {:?}," , self . 0 . ver) ?;
263
- writeln ! ( f, " alg: {:?}," , self . 0 . alg) ?;
264
234
writeln ! ( f, " content_type: {:?}" , self . 0 . content_type) ?;
265
235
writeln ! ( f, " content_encoding: {:?}" , self . 0 . content_encoding) ?;
266
236
writeln ! ( f, " additional_fields: {:?}," , self . 0 . extra) ?;
@@ -273,7 +243,6 @@ impl TryFrom<&Metadata> for coset::Header {
273
243
274
244
fn try_from ( meta : & Metadata ) -> Result < Self , Self :: Error > {
275
245
let mut builder = coset:: HeaderBuilder :: new ( )
276
- . algorithm ( meta. algorithm ( ) ?. into ( ) )
277
246
. content_format ( CoapContentFormat :: from ( meta. content_type ( ) ?) ) ;
278
247
279
248
if let Some ( content_encoding) = meta. content_encoding ( ) {
0 commit comments