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