1 use cbor::CborType;
2
3 /// Sig_structure is a CBOR array:
4 ///
5 /// Sig_structure = [
6 /// context : "Signature" / "Signature1" / "CounterSignature",
7 /// body_protected : empty_or_serialized_map,
8 /// ? sign_protected : empty_or_serialized_map,
9 /// external_aad : bstr,
10 /// payload : bstr
11 /// ]
12 ///
13 /// In this case, the context is "Signature". There is no external_aad, so this defaults to a
14 /// zero-length bstr.
get_sig_struct_bytes( protected_body_header_serialized: CborType, protected_signature_header_serialized: CborType, payload: &[u8], ) -> Vec<u8>15 pub fn get_sig_struct_bytes(
16 protected_body_header_serialized: CborType,
17 protected_signature_header_serialized: CborType,
18 payload: &[u8],
19 ) -> Vec<u8> {
20 let sig_structure_array: Vec<CborType> = vec![CborType::String(String::from("Signature")),
21 protected_body_header_serialized,
22 protected_signature_header_serialized,
23 CborType::Null,
24 CborType::Bytes(payload.to_vec())];
25
26 CborType::Array(sig_structure_array).serialize()
27 }
28